You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by le...@apache.org on 2021/03/17 16:43:52 UTC
svn commit: r1887756 - in /pdfbox/trunk/pdfbox/src:
main/java/org/apache/pdfbox/cos/
main/java/org/apache/pdfbox/pdmodel/common/filespecification/
main/java/org/apache/pdfbox/pdmodel/common/function/
test/java/org/apache/pdfbox/cos/
Author: lehmi
Date: Wed Mar 17 16:43:52 2021
New Revision: 1887756
URL: http://svn.apache.org/viewvc?rev=1887756&view=rev
Log:
PDFBOX-4892: use convenience methods to simplify code, add new constants, optimize COSDictionary methods
Modified:
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDictionary.java
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSName.java
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/UnmodifiableCOSDictionary.java
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/filespecification/PDEmbeddedFile.java
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/function/PDFunction.java
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/function/PDFunctionType0.java
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/function/PDFunctionType2.java
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/function/PDFunctionType3.java
pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/cos/UnmodifiableCOSDictionaryTest.java
Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDictionary.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDictionary.java?rev=1887756&r1=1887755&r2=1887756&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDictionary.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDictionary.java Wed Mar 17 16:43:52 2021
@@ -317,27 +317,15 @@ public class COSDictionary extends COSBa
}
/**
- * Set the value of a date entry in the dictionary.
- *
- * @param embedded The embedded dictionary.
- * @param key The key to the date value.
- * @param date The date value.
- */
- public void setEmbeddedDate(String embedded, String key, Calendar date)
- {
- setEmbeddedDate(embedded, COSName.getPDFName(key), date);
- }
-
- /**
* Set the date object.
*
* @param embedded The embedded dictionary.
* @param key The key to the date.
* @param date The date to set.
*/
- public void setEmbeddedDate(String embedded, COSName key, Calendar date)
+ public void setEmbeddedDate(COSName embedded, COSName key, Calendar date)
{
- COSDictionary dic = getCOSDictionary(COSName.getPDFName(embedded));
+ COSDictionary dic = getCOSDictionary(embedded);
if (dic == null && date != null)
{
dic = new COSDictionary();
@@ -386,22 +374,9 @@ public class COSDictionary extends COSBa
* @param key The key to the object,
* @param value The string value for the name.
*/
- public void setEmbeddedString(String embedded, String key, String value)
+ public void setEmbeddedString(COSName embedded, COSName key, String value)
{
- setEmbeddedString(embedded, COSName.getPDFName(key), value);
- }
-
- /**
- * This is a convenience method that will convert the value to a COSString object. If it is null then the object
- * will be removed.
- *
- * @param embedded The embedded dictionary to set the item in.
- * @param key The key to the object,
- * @param value The string value for the name.
- */
- public void setEmbeddedString(String embedded, COSName key, String value)
- {
- COSDictionary dic = getCOSDictionary(COSName.getPDFName(embedded));
+ COSDictionary dic = getCOSDictionary(embedded);
if (dic == null && value != null)
{
dic = new COSDictionary();
@@ -465,21 +440,9 @@ public class COSDictionary extends COSBa
* @param key The key to the object,
* @param value The int value for the name.
*/
- public void setEmbeddedInt(String embeddedDictionary, String key, int value)
+ public void setEmbeddedInt(COSName embeddedDictionary, COSName key, int value)
{
- setEmbeddedInt(embeddedDictionary, COSName.getPDFName(key), value);
- }
-
- /**
- * This is a convenience method that will convert the value to a COSInteger object.
- *
- * @param embeddedDictionary The embedded dictionary.
- * @param key The key to the object,
- * @param value The int value for the name.
- */
- public void setEmbeddedInt(String embeddedDictionary, COSName key, int value)
- {
- COSDictionary embedded = getCOSDictionary(COSName.getPDFName(embeddedDictionary));
+ COSDictionary embedded = getCOSDictionary(embeddedDictionary);
if (embedded == null)
{
embedded = new COSDictionary();
@@ -787,20 +750,7 @@ public class COSDictionary extends COSBa
* @param key The key to the item in the dictionary.
* @return The name converted to a string.
*/
- public String getEmbeddedString(String embedded, String key)
- {
- return getEmbeddedString(embedded, COSName.getPDFName(key), null);
- }
-
- /**
- * This is a convenience method that will get the dictionary object that is expected to be a name and convert it to
- * a string. Null is returned if the entry does not exist in the dictionary.
- *
- * @param embedded The embedded dictionary.
- * @param key The key to the item in the dictionary.
- * @return The name converted to a string.
- */
- public String getEmbeddedString(String embedded, COSName key)
+ public String getEmbeddedString(COSName embedded, COSName key)
{
return getEmbeddedString(embedded, key, null);
}
@@ -814,23 +764,9 @@ public class COSDictionary extends COSBa
* @param defaultValue The default value to return.
* @return The name converted to a string.
*/
- public String getEmbeddedString(String embedded, String key, String defaultValue)
+ public String getEmbeddedString(COSName embedded, COSName key, String defaultValue)
{
- return getEmbeddedString(embedded, COSName.getPDFName(key), defaultValue);
- }
-
- /**
- * This is a convenience method that will get the dictionary object that is expected to be a name and convert it to
- * a string.
- *
- * @param embedded The embedded dictionary.
- * @param key The key to the item in the dictionary.
- * @param defaultValue The default value to return.
- * @return The name converted to a string.
- */
- public String getEmbeddedString(String embedded, COSName key, String defaultValue)
- {
- COSDictionary eDic = getCOSDictionary(COSName.getPDFName(embedded));
+ COSDictionary eDic = getCOSDictionary(embedded);
return eDic != null ? eDic.getString(key, defaultValue) : defaultValue;
}
@@ -900,20 +836,7 @@ public class COSDictionary extends COSBa
* @param key The key to the item in the dictionary.
* @return The name converted to a string.
*/
- public Calendar getEmbeddedDate(String embedded, String key)
- {
- return getEmbeddedDate(embedded, COSName.getPDFName(key), null);
- }
-
- /**
- * This is a convenience method that will get the dictionary object that is expected to be a name and convert it to
- * a string. Null is returned if the entry does not exist in the dictionary.
- *
- * @param embedded The embedded dictionary to get.
- * @param key The key to the item in the dictionary.
- * @return The name converted to a string.
- */
- public Calendar getEmbeddedDate(String embedded, COSName key)
+ public Calendar getEmbeddedDate(COSName embedded, COSName key)
{
return getEmbeddedDate(embedded, key, null);
}
@@ -923,25 +846,13 @@ public class COSDictionary extends COSBa
*
* @param embedded The embedded dictionary to get.
* @param key The key to the item in the dictionary.
- * @param defaultValue The default value to return if the entry does not exist in the dictionary or if the date was invalid.
- * @return The name converted to a string.
- */
- public Calendar getEmbeddedDate(String embedded, String key, Calendar defaultValue)
- {
- return getEmbeddedDate(embedded, COSName.getPDFName(key), defaultValue);
- }
-
- /**
- * This is a convenience method that will get the dictionary object that is expected to be a date.
- *
- * @param embedded The embedded dictionary to get.
- * @param key The key to the item in the dictionary.
- * @param defaultValue The default value to return if the entry does not exist in the dictionary or if the date was invalid.
+ * @param defaultValue The default value to return if the entry does not exist in the dictionary or if the date was
+ * invalid.
* @return The name converted to a string.
*/
- public Calendar getEmbeddedDate(String embedded, COSName key, Calendar defaultValue)
+ public Calendar getEmbeddedDate(COSName embedded, COSName key, Calendar defaultValue)
{
- COSDictionary eDic = getCOSDictionary(COSName.getPDFName(embedded));
+ COSDictionary eDic = getCOSDictionary(embedded);
return eDic != null ? eDic.getDate(key, defaultValue) : defaultValue;
}
@@ -1002,20 +913,7 @@ public class COSDictionary extends COSBa
*
* @return The value of the embedded integer.
*/
- public int getEmbeddedInt(String embeddedDictionary, String key)
- {
- return getEmbeddedInt(embeddedDictionary, COSName.getPDFName(key));
- }
-
- /**
- * Get an integer from an embedded dictionary. Useful for 1-1 mappings. default:-1
- *
- * @param embeddedDictionary The name of the embedded dictionary.
- * @param key The key in the embedded dictionary.
- *
- * @return The value of the embedded integer.
- */
- public int getEmbeddedInt(String embeddedDictionary, COSName key)
+ public int getEmbeddedInt(COSName embeddedDictionary, COSName key)
{
return getEmbeddedInt(embeddedDictionary, key, -1);
}
@@ -1029,23 +927,9 @@ public class COSDictionary extends COSBa
*
* @return The value of the embedded integer.
*/
- public int getEmbeddedInt(String embeddedDictionary, String key, int defaultValue)
- {
- return getEmbeddedInt(embeddedDictionary, COSName.getPDFName(key), defaultValue);
- }
-
- /**
- * Get an integer from an embedded dictionary. Useful for 1-1 mappings.
- *
- * @param embeddedDictionary The name of the embedded dictionary.
- * @param key The key in the embedded dictionary.
- * @param defaultValue The value if there is no embedded dictionary or it does not contain the key.
- *
- * @return The value of the embedded integer.
- */
- public int getEmbeddedInt(String embeddedDictionary, COSName key, int defaultValue)
+ public int getEmbeddedInt(COSName embeddedDictionary, COSName key, int defaultValue)
{
- COSDictionary embedded = getCOSDictionary(COSName.getPDFName(embeddedDictionary));
+ COSDictionary embedded = getCOSDictionary(embeddedDictionary);
return embedded != null ? embedded.getInt(key, defaultValue) : defaultValue;
}
Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSName.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSName.java?rev=1887756&r1=1887755&r2=1887756&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSName.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSName.java Wed Mar 17 16:43:52 2021
@@ -131,6 +131,7 @@ public final class COSName extends COSBa
public static final COSName CH = new COSName("Ch");
public static final COSName CHAR_PROCS = new COSName("CharProcs");
public static final COSName CHAR_SET = new COSName("CharSet");
+ public static final COSName CHECK_SUM = new COSName("CheckSum");
public static final COSName CICI_SIGNIT = new COSName("CICI.SignIt");
public static final COSName CID_FONT_TYPE0 = new COSName("CIDFontType0");
public static final COSName CID_FONT_TYPE2 = new COSName("CIDFontType2");
@@ -222,6 +223,7 @@ public final class COSName extends COSBa
public static final COSName EARLY_CHANGE = new COSName("EarlyChange");
public static final COSName EF = new COSName("EF");
public static final COSName EMBEDDED_FDFS = new COSName("EmbeddedFDFs");
+ public static final COSName EMBEDDED_FILE = new COSName("EmbeddedFile");
public static final COSName EMBEDDED_FILES = new COSName("EmbeddedFiles");
public static final COSName EMPTY = new COSName("");
public static final COSName ENCODE = new COSName("Encode");
@@ -491,6 +493,7 @@ public final class COSName extends COSBa
public static final COSName REGISTRY = new COSName("Registry");
public static final COSName REGISTRY_NAME = new COSName("RegistryName");
public static final COSName RENAME = new COSName("Rename");
+ public static final COSName RES_FORK = new COSName("ResFork");
public static final COSName RESOURCES = new COSName("Resources");
public static final COSName RGB = new COSName("RGB");
public static final COSName RI = new COSName("RI");
Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/UnmodifiableCOSDictionary.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/UnmodifiableCOSDictionary.java?rev=1887756&r1=1887755&r2=1887756&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/UnmodifiableCOSDictionary.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/UnmodifiableCOSDictionary.java Wed Mar 17 16:43:52 2021
@@ -139,16 +139,7 @@ final class UnmodifiableCOSDictionary ex
* {@inheritDoc}
*/
@Override
- public void setEmbeddedDate(String embedded, String key, Calendar date)
- {
- throw new UnsupportedOperationException();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setEmbeddedDate(String embedded, COSName key, Calendar date)
+ public void setEmbeddedDate(COSName embedded, COSName key, Calendar date)
{
throw new UnsupportedOperationException();
}
@@ -175,16 +166,7 @@ final class UnmodifiableCOSDictionary ex
* {@inheritDoc}
*/
@Override
- public void setEmbeddedString(String embedded, String key, String value)
- {
- throw new UnsupportedOperationException();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setEmbeddedString(String embedded, COSName key, String value)
+ public void setEmbeddedString(COSName embedded, COSName key, String value)
{
throw new UnsupportedOperationException();
}
@@ -229,16 +211,7 @@ final class UnmodifiableCOSDictionary ex
* {@inheritDoc}
*/
@Override
- public void setEmbeddedInt(String embeddedDictionary, String key, int value)
- {
- throw new UnsupportedOperationException();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setEmbeddedInt(String embeddedDictionary, COSName key, int value)
+ public void setEmbeddedInt(COSName embeddedDictionary, COSName key, int value)
{
throw new UnsupportedOperationException();
}
Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/filespecification/PDEmbeddedFile.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/filespecification/PDEmbeddedFile.java?rev=1887756&r1=1887755&r2=1887756&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/filespecification/PDEmbeddedFile.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/filespecification/PDEmbeddedFile.java Wed Mar 17 16:43:52 2021
@@ -40,7 +40,7 @@ public class PDEmbeddedFile extends PDSt
public PDEmbeddedFile( PDDocument document )
{
super( document );
- getCOSObject().setName(COSName.TYPE, "EmbeddedFile" );
+ getCOSObject().setItem(COSName.TYPE, COSName.EMBEDDED_FILE);
}
/**
@@ -57,7 +57,7 @@ public class PDEmbeddedFile extends PDSt
public PDEmbeddedFile( PDDocument doc, InputStream str ) throws IOException
{
super(doc, str);
- getCOSObject().setName(COSName.TYPE, "EmbeddedFile");
+ getCOSObject().setItem(COSName.TYPE, COSName.EMBEDDED_FILE);
}
/**
@@ -69,7 +69,7 @@ public class PDEmbeddedFile extends PDSt
public PDEmbeddedFile(PDDocument doc, InputStream input, COSName filter) throws IOException
{
super(doc, input, filter);
- getCOSObject().setName(COSName.TYPE, "EmbeddedFile");
+ getCOSObject().setItem(COSName.TYPE, COSName.EMBEDDED_FILE);
}
/**
@@ -99,7 +99,7 @@ public class PDEmbeddedFile extends PDSt
*/
public int getSize()
{
- return getCOSObject().getEmbeddedInt( "Params", "Size" );
+ return getCOSObject().getEmbeddedInt(COSName.PARAMS, COSName.SIZE);
}
/**
@@ -109,7 +109,7 @@ public class PDEmbeddedFile extends PDSt
*/
public void setSize( int size )
{
- getCOSObject().setEmbeddedInt( "Params", "Size", size );
+ getCOSObject().setEmbeddedInt(COSName.PARAMS, COSName.SIZE, size);
}
/**
@@ -120,7 +120,7 @@ public class PDEmbeddedFile extends PDSt
*/
public Calendar getCreationDate() throws IOException
{
- return getCOSObject().getEmbeddedDate( "Params", "CreationDate" );
+ return getCOSObject().getEmbeddedDate(COSName.PARAMS, COSName.CREATION_DATE);
}
/**
@@ -130,7 +130,7 @@ public class PDEmbeddedFile extends PDSt
*/
public void setCreationDate( Calendar creation )
{
- getCOSObject().setEmbeddedDate( "Params", "CreationDate", creation );
+ getCOSObject().setEmbeddedDate(COSName.PARAMS, COSName.CREATION_DATE, creation);
}
/**
@@ -141,7 +141,7 @@ public class PDEmbeddedFile extends PDSt
*/
public Calendar getModDate() throws IOException
{
- return getCOSObject().getEmbeddedDate( "Params", "ModDate" );
+ return getCOSObject().getEmbeddedDate(COSName.PARAMS, COSName.MOD_DATE);
}
/**
@@ -151,7 +151,7 @@ public class PDEmbeddedFile extends PDSt
*/
public void setModDate( Calendar mod )
{
- getCOSObject().setEmbeddedDate( "Params", "ModDate", mod );
+ getCOSObject().setEmbeddedDate(COSName.PARAMS, COSName.MOD_DATE, mod);
}
/**
@@ -161,7 +161,7 @@ public class PDEmbeddedFile extends PDSt
*/
public String getCheckSum()
{
- return getCOSObject().getEmbeddedString( "Params", "CheckSum" );
+ return getCOSObject().getEmbeddedString(COSName.PARAMS, COSName.CHECK_SUM);
}
/**
@@ -171,7 +171,7 @@ public class PDEmbeddedFile extends PDSt
*/
public void setCheckSum( String checksum )
{
- getCOSObject().setEmbeddedString( "Params", "CheckSum", checksum );
+ getCOSObject().setEmbeddedString(COSName.PARAMS, COSName.CHECK_SUM, checksum);
}
/**
@@ -181,13 +181,8 @@ public class PDEmbeddedFile extends PDSt
*/
public String getMacSubtype()
{
- String retval = null;
- COSDictionary params = (COSDictionary)getCOSObject().getDictionaryObject( COSName.PARAMS );
- if( params != null )
- {
- retval = params.getEmbeddedString( "Mac", "Subtype" );
- }
- return retval;
+ COSDictionary params = getCOSObject().getCOSDictionary(COSName.PARAMS);
+ return params != null ? params.getEmbeddedString(COSName.MAC, COSName.SUBTYPE) : null;
}
/**
@@ -197,7 +192,7 @@ public class PDEmbeddedFile extends PDSt
*/
public void setMacSubtype( String macSubtype )
{
- COSDictionary params = (COSDictionary)getCOSObject().getDictionaryObject( COSName.PARAMS );
+ COSDictionary params = getCOSObject().getCOSDictionary(COSName.PARAMS);
if( params == null && macSubtype != null )
{
params = new COSDictionary();
@@ -205,7 +200,7 @@ public class PDEmbeddedFile extends PDSt
}
if( params != null )
{
- params.setEmbeddedString( "Mac", "Subtype", macSubtype );
+ params.setEmbeddedString(COSName.MAC, COSName.SUBTYPE, macSubtype);
}
}
@@ -216,13 +211,8 @@ public class PDEmbeddedFile extends PDSt
*/
public String getMacCreator()
{
- String retval = null;
- COSDictionary params = (COSDictionary)getCOSObject().getDictionaryObject( COSName.PARAMS );
- if( params != null )
- {
- retval = params.getEmbeddedString( "Mac", "Creator" );
- }
- return retval;
+ COSDictionary params = getCOSObject().getCOSDictionary(COSName.PARAMS);
+ return params != null ? params.getEmbeddedString(COSName.MAC, COSName.CREATOR) : null;
}
/**
@@ -232,7 +222,7 @@ public class PDEmbeddedFile extends PDSt
*/
public void setMacCreator( String macCreator )
{
- COSDictionary params = (COSDictionary)getCOSObject().getDictionaryObject( COSName.PARAMS );
+ COSDictionary params = getCOSObject().getCOSDictionary(COSName.PARAMS);
if( params == null && macCreator != null )
{
params = new COSDictionary();
@@ -240,7 +230,7 @@ public class PDEmbeddedFile extends PDSt
}
if( params != null )
{
- params.setEmbeddedString( "Mac", "Creator", macCreator );
+ params.setEmbeddedString(COSName.MAC, COSName.CREATOR, macCreator);
}
}
@@ -251,13 +241,8 @@ public class PDEmbeddedFile extends PDSt
*/
public String getMacResFork()
{
- String retval = null;
- COSDictionary params = (COSDictionary)getCOSObject().getDictionaryObject( COSName.PARAMS );
- if( params != null )
- {
- retval = params.getEmbeddedString( "Mac", "ResFork" );
- }
- return retval;
+ COSDictionary params = getCOSObject().getCOSDictionary(COSName.PARAMS);
+ return params != null ? params.getEmbeddedString(COSName.MAC, COSName.RES_FORK) : null;
}
/**
@@ -267,7 +252,7 @@ public class PDEmbeddedFile extends PDSt
*/
public void setMacResFork( String macResFork )
{
- COSDictionary params = (COSDictionary)getCOSObject().getDictionaryObject( COSName.PARAMS );
+ COSDictionary params = getCOSObject().getCOSDictionary(COSName.PARAMS);
if( params == null && macResFork != null )
{
params = new COSDictionary();
@@ -275,7 +260,7 @@ public class PDEmbeddedFile extends PDSt
}
if( params != null )
{
- params.setEmbeddedString( "Mac", "ResFork", macResFork);
+ params.setEmbeddedString(COSName.MAC, COSName.RES_FORK, macResFork);
}
}
Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/function/PDFunction.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/function/PDFunction.java?rev=1887756&r1=1887755&r2=1887756&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/function/PDFunction.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/function/PDFunction.java Wed Mar 17 16:43:52 2021
@@ -257,7 +257,7 @@ public abstract class PDFunction impleme
{
if (range == null)
{
- range = (COSArray) getCOSObject().getDictionaryObject(COSName.RANGE);
+ range = getCOSObject().getCOSArray(COSName.RANGE);
}
return range;
}
@@ -271,7 +271,7 @@ public abstract class PDFunction impleme
{
if (domain == null)
{
- domain = (COSArray) getCOSObject().getDictionaryObject(COSName.DOMAIN);
+ domain = getCOSObject().getCOSArray(COSName.DOMAIN);
}
return domain;
}
Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/function/PDFunctionType0.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/function/PDFunctionType0.java?rev=1887756&r1=1887755&r2=1887756&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/function/PDFunctionType0.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/function/PDFunctionType0.java Wed Mar 17 16:43:52 2021
@@ -96,7 +96,7 @@ public class PDFunctionType0 extends PDF
{
if (size == null)
{
- size = (COSArray) getCOSObject().getDictionaryObject(COSName.SIZE);
+ size = getCOSObject().getCOSArray(COSName.SIZE);
}
return size;
}
@@ -145,7 +145,7 @@ public class PDFunctionType0 extends PDF
{
if (encode == null)
{
- encode = (COSArray) getCOSObject().getDictionaryObject(COSName.ENCODE);
+ encode = getCOSObject().getCOSArray(COSName.ENCODE);
// the default value is [0 (size[0]-1) 0 (size[1]-1) ...]
if (encode == null)
{
@@ -171,7 +171,7 @@ public class PDFunctionType0 extends PDF
{
if (decode == null)
{
- decode = (COSArray) getCOSObject().getDictionaryObject(COSName.DECODE);
+ decode = getCOSObject().getCOSArray(COSName.DECODE);
// if decode is null, the default values are the range values
if (decode == null)
{
Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/function/PDFunctionType2.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/function/PDFunctionType2.java?rev=1887756&r1=1887755&r2=1887756&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/function/PDFunctionType2.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/function/PDFunctionType2.java Wed Mar 17 16:43:52 2021
@@ -56,7 +56,7 @@ public class PDFunctionType2 extends PDF
if (getCOSObject().getDictionaryObject(COSName.C0) instanceof COSArray)
{
- c0 = (COSArray) getCOSObject().getDictionaryObject(COSName.C0);
+ c0 = (COSArray) getCOSObject().getCOSArray(COSName.C0);
}
else
{
Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/function/PDFunctionType3.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/function/PDFunctionType3.java?rev=1887756&r1=1887755&r2=1887756&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/function/PDFunctionType3.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/function/PDFunctionType3.java Wed Mar 17 16:43:52 2021
@@ -134,7 +134,7 @@ public class PDFunctionType3 extends PDF
{
if (functions == null)
{
- functions = (COSArray)(getCOSObject().getDictionaryObject( COSName.FUNCTIONS ));
+ functions = getCOSObject().getCOSArray(COSName.FUNCTIONS);
}
return functions;
}
@@ -148,7 +148,7 @@ public class PDFunctionType3 extends PDF
{
if (bounds == null)
{
- bounds = (COSArray)(getCOSObject().getDictionaryObject( COSName.BOUNDS ));
+ bounds = getCOSObject().getCOSArray(COSName.BOUNDS);
}
return bounds;
}
@@ -162,7 +162,7 @@ public class PDFunctionType3 extends PDF
{
if (encode == null)
{
- encode = (COSArray)(getCOSObject().getDictionaryObject( COSName.ENCODE ));
+ encode = getCOSObject().getCOSArray(COSName.ENCODE);
}
return encode;
}
Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/cos/UnmodifiableCOSDictionaryTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/cos/UnmodifiableCOSDictionaryTest.java?rev=1887756&r1=1887755&r2=1887756&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/cos/UnmodifiableCOSDictionaryTest.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/cos/UnmodifiableCOSDictionaryTest.java Wed Mar 17 16:43:52 2021
@@ -210,7 +210,7 @@ class UnmodifiableCOSDictionaryTest
Calendar calendar = Calendar.getInstance();
try
{
- unmodifiableCOSDictionary.setEmbeddedDate("Embedded", COSName.A, calendar);
+ unmodifiableCOSDictionary.setEmbeddedDate(COSName.PARAMS, COSName.A, calendar);
fail("An UnsupportedOperationException should have been thrown");
}
catch (UnsupportedOperationException exception)
@@ -218,15 +218,6 @@ class UnmodifiableCOSDictionaryTest
// nothing to do
}
- try
- {
- unmodifiableCOSDictionary.setEmbeddedDate("Embedded", "A", calendar);
- fail("An UnsupportedOperationException should have been thrown");
- }
- catch (UnsupportedOperationException exception)
- {
- // nothing to do
- }
}
@Test
@@ -260,17 +251,7 @@ class UnmodifiableCOSDictionaryTest
COSDictionary unmodifiableCOSDictionary = new COSDictionary().asUnmodifiableDictionary();
try
{
- unmodifiableCOSDictionary.setEmbeddedString("Embedded", COSName.A, "A");
- fail("An UnsupportedOperationException should have been thrown");
- }
- catch (UnsupportedOperationException exception)
- {
- // nothing to do
- }
-
- try
- {
- unmodifiableCOSDictionary.setEmbeddedString("Embedded", "A", "A");
+ unmodifiableCOSDictionary.setEmbeddedString(COSName.PARAMS, COSName.A, "A");
fail("An UnsupportedOperationException should have been thrown");
}
catch (UnsupportedOperationException exception)
@@ -310,17 +291,7 @@ class UnmodifiableCOSDictionaryTest
COSDictionary unmodifiableCOSDictionary = new COSDictionary().asUnmodifiableDictionary();
try
{
- unmodifiableCOSDictionary.setEmbeddedInt("Embedded", COSName.A, 0);
- fail("An UnsupportedOperationException should have been thrown");
- }
- catch (UnsupportedOperationException exception)
- {
- // nothing to do
- }
-
- try
- {
- unmodifiableCOSDictionary.setEmbeddedInt("Embedded", "A", 0);
+ unmodifiableCOSDictionary.setEmbeddedInt(COSName.PARAMS, COSName.A, 0);
fail("An UnsupportedOperationException should have been thrown");
}
catch (UnsupportedOperationException exception)