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 2018/10/21 20:06:14 UTC
svn commit: r1844514 -
/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDictionary.java
Author: lehmi
Date: Sun Oct 21 20:06:14 2018
New Revision: 1844514
URL: http://svn.apache.org/viewvc?rev=1844514&view=rev
Log:
PDFBOX-4349: added 3 new convenience methods and deprecated 3 other methods
Modified:
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDictionary.java
Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDictionary.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDictionary.java?rev=1844514&r1=1844513&r2=1844514&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDictionary.java (original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDictionary.java Sun Oct 21 20:06:14 2018
@@ -164,6 +164,9 @@ public class COSDictionary extends COSBa
* @param keyList The list of keys to find a value.
*
* @return The object that matches the key.
+ *
+ * @deprecated Will be removed in 3.0. A value may have to keys, the regular one and sometimes an additional
+ * abbreviation. More than 2 values doesn't make sense.
*/
public COSBase getDictionaryObject(String[] keyList)
{
@@ -560,6 +563,57 @@ public class COSDictionary extends COSBa
}
/**
+ * This is a convenience method that will get the dictionary object that is expected to be a COSObject. Null is
+ * returned if the entry does not exist in the dictionary.
+ *
+ * @param key The key to the item in the dictionary.
+ * @return The COSObject.
+ */
+ public COSObject getCOSObject(COSName key)
+ {
+ COSBase object = getItem(key);
+ if (object instanceof COSObject)
+ {
+ return (COSObject) object;
+ }
+ return null;
+ }
+
+ /**
+ * This is a convenience method that will get the dictionary object that is expected to be a COSDictionary. Null is
+ * returned if the entry does not exist in the dictionary.
+ *
+ * @param key The key to the item in the dictionary.
+ * @return The COSDictionary.
+ */
+ public COSDictionary getCOSDictionary(COSName key)
+ {
+ COSBase dictionary = getDictionaryObject(key);
+ if (dictionary instanceof COSDictionary)
+ {
+ return (COSDictionary) dictionary;
+ }
+ return null;
+ }
+
+ /**
+ * This is a convenience method that will get the dictionary object that is expected to be a COSArray. Null is
+ * returned if the entry does not exist in the dictionary.
+ *
+ * @param key The key to the item in the dictionary.
+ * @return The COSArray.
+ */
+ public COSArray getCOSArray(COSName key)
+ {
+ COSBase array = getDictionaryObject(key);
+ if (array instanceof COSArray)
+ {
+ return (COSArray) array;
+ }
+ return null;
+ }
+
+ /**
* This is a convenience method that will get the dictionary object that is expected to be a name. Default is
* returned if the entry does not exist in the dictionary.
*
@@ -1026,6 +1080,9 @@ public class COSDictionary extends COSBa
* @param keyList The key to the item in the dictionary.
* @param defaultValue The value to return if the dictionary item is null.
* @return The integer value.
+ *
+ * @deprecated Will be removed in 3.0. A value may have to keys, the regular one and sometimes an additional
+ * abbreviation. More than 2 values doesn't make sense.
*/
public int getInt(String[] keyList, int defaultValue)
{
@@ -1129,6 +1186,9 @@ public class COSDictionary extends COSBa
* @param keyList The key to the item in the dictionary.
* @param defaultValue The value to return if the dictionary item is null.
* @return The long value.
+ *
+ * @deprecated Will be removed in 3.0. A value may have to keys, the regular one and sometimes an additional
+ * abbreviation. More than 2 values doesn't make sense.
*/
public long getLong(String[] keyList, long defaultValue)
{