You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2021/03/23 07:34:12 UTC
svn commit: r1887954 -
/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDStream.java
Author: tilman
Date: Tue Mar 23 07:34:12 2021
New Revision: 1887954
URL: http://svn.apache.org/viewvc?rev=1887954&view=rev
Log:
PDFBOX-4892: remove double code
Modified:
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDStream.java
Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDStream.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDStream.java?rev=1887954&r1=1887953&r2=1887954&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDStream.java (original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDStream.java Tue Mar 23 07:34:12 2021
@@ -349,11 +349,28 @@ public class PDStream implements COSObje
public List<Object> getDecodeParms() throws IOException
{
// See PDF Ref 1.5 implementation note 7, the DP is sometimes used instead.
- COSBase dp = stream.getDictionaryObject(COSName.DECODE_PARMS, COSName.DP);
+ return internalGetDecodeParams(COSName.DECODE_PARMS, COSName.DP);
+ }
+
+ /**
+ * Get the list of decode parameters. Each entry in the list will refer to
+ * an entry in the filters list.
+ *
+ * @return The list of decode parameters.
+ * @throws IOException if there is an error retrieving the parameters.
+ */
+ public List<Object> getFileDecodeParams() throws IOException
+ {
+ return internalGetDecodeParams(COSName.F_DECODE_PARMS, null);
+ }
+
+ private List<Object> internalGetDecodeParams(COSName name1, COSName name2) throws IOException
+ {
+ COSBase dp = stream.getDictionaryObject(name1, name2);
if (dp instanceof COSDictionary)
{
Map<?, ?> map = COSDictionaryMap.convertBasicTypesToMap((COSDictionary) dp);
- return new COSArrayList<Object>(map, dp, stream, COSName.DECODE_PARMS);
+ return new COSArrayList<Object>(map, dp, stream, name1);
}
if (dp instanceof COSArray)
@@ -448,44 +465,6 @@ public class PDStream implements COSObje
}
/**
- * Get the list of decode parameters. Each entry in the list will refer to
- * an entry in the filters list.
- *
- * @return The list of decode parameters.
- * @throws IOException if there is an error retrieving the parameters.
- */
- public List<Object> getFileDecodeParams() throws IOException
- {
- COSBase dp = stream.getDictionaryObject(COSName.F_DECODE_PARMS);
- if (dp instanceof COSDictionary)
- {
- Map<?, ?> map = COSDictionaryMap.convertBasicTypesToMap((COSDictionary) dp);
- return new COSArrayList<Object>(map, dp, stream, COSName.F_DECODE_PARMS);
- }
-
- if (dp instanceof COSArray)
- {
- COSArray array = (COSArray) dp;
- List<Object> actuals = new ArrayList<Object>(array.size());
- for (int i = 0; i < array.size(); i++)
- {
- COSBase base = array.getObject(i);
- if (base instanceof COSDictionary)
- {
- actuals.add(COSDictionaryMap.convertBasicTypesToMap((COSDictionary) base));
- }
- else
- {
- LOG.warn("Expected COSDictionary, got " + base + ", ignored");
- }
- }
- return new COSArrayList<Object>(actuals, array);
- }
-
- return null;
- }
-
- /**
* This will set the list of decode params.
*
* @param decodeParams The list of decode params.