Author: lehmi
Date: Sun Oct 21 20:11:34 2018
New Revision: 1844517
URL: http://svn.apache.org/viewvc?rev=1844517&view=rev
Log:
PDFBOX-4349: added 3 new convenience methods and removed 3 deprecated methods
Modified:
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDictionary.java
(contents, props changed)
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=1844517&r1=1844516&r2=1844517&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
Sun Oct 21 20:11:34 2018
@@ -226,26 +226,6 @@ public class COSDictionary extends COSBa
}
/**
- * This is a special case of getDictionaryObject that takes multiple keys,
it will handle the situation where
- * multiple keys could get the same value, ie if either CS or ColorSpace
is used to get the colorspace. This will
- * get an object from this dictionary. If the object is a reference then
it will dereference it and get it from the
- * document. If the object is COSNull then null will be returned.
- *
- * @param keyList The list of keys to find a value.
- *
- * @return The object that matches the key.
- */
- public COSBase getDictionaryObject(String[] keyList)
- {
- COSBase retval = null;
- for (int i = 0; i < keyList.length && retval == null; i++)
- {
- retval = getDictionaryObject(COSName.getPDFName(keyList[i]));
- }
- return retval;
- }
-
- /**
* This will get an object from this dictionary. If the object is a
reference then it will dereference it and get it
* from the document. If the object is COSNull then null will be returned.
*
@@ -630,6 +610,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.
*
@@ -1086,25 +1117,6 @@ public class COSDictionary extends COSBa
* This is a convenience method that will get the dictionary object that
is expected to be an integer. If the
* dictionary value is null then the default value will be returned.
*
- * @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.
- */
- public int getInt(String[] keyList, int defaultValue)
- {
- int retval = defaultValue;
- COSBase obj = getDictionaryObject(keyList);
- if (obj instanceof COSNumber)
- {
- retval = ((COSNumber) obj).intValue();
- }
- return retval;
- }
-
- /**
- * This is a convenience method that will get the dictionary object that
is expected to be an integer. If the
- * dictionary value is null then the default value will be returned.
- *
* @param key The key to the item in the dictionary.
* @param defaultValue The value to return if the dictionary item is null.
* @return The integer value.
@@ -1186,25 +1198,6 @@ public class COSDictionary extends COSBa
}
/**
- * This is a convenience method that will get the dictionary object that
is expected to be an long. If the
- * dictionary value is null then the default value will be returned.
- *
- * @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.
- */
- public long getLong(String[] keyList, long defaultValue)
- {
- long retval = defaultValue;
- COSBase obj = getDictionaryObject(keyList);
- if (obj instanceof COSNumber)
- {
- retval = ((COSNumber) obj).longValue();
- }
- return retval;
- }
-
- /**
* This is a convenience method that will get the dictionary object that
is expected to be an integer. If the
* dictionary value is null then the default value will be returned.
*
Propchange:
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDictionary.java
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Sun Oct 21 20:11:34 2018
@@ -0,0 +1,3 @@
+/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDictionary.java:1760418,1761484,1762133,1762140,1763609,1776107,1778755,1779822,1780783,1780789,1782684,1784450,1792784,1795704,1795712,1799081-1799082,1814046,1814285,1814459,1824914,1825811,1825820,1825912,1844514
+/pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDictionary.java:1618517-1621410
+/pdfbox/no-awt/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDictionary.java:1618514-1618516