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 2018/01/23 19:35:28 UTC
svn commit: r1822041 -
/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDictionary.java
Author: tilman
Date: Tue Jan 23 19:35:27 2018
New Revision: 1822041
URL: http://svn.apache.org/viewvc?rev=1822041&view=rev
Log:
PDFBOX-4071: avoid potential ClassCastException; improve javadoc
Modified:
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDictionary.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=1822041&r1=1822040&r2=1822041&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 Tue Jan 23 19:35:27 2018
@@ -705,8 +705,8 @@ public class COSDictionary extends COSBa
}
/**
- * 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.
+ * This is a convenience method that will get the dictionary object that is expected to be a
+ * string. Null is returned if the entry does not exist in the dictionary.
*
* @param key The key to the item in the dictionary.
* @return The name converted to a string.
@@ -717,8 +717,8 @@ public class COSDictionary extends COSBa
}
/**
- * 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.
+ * This is a convenience method that will get the dictionary object that is expected to be a
+ * string. Null is returned if the entry does not exist in the dictionary.
*
* @param key The key to the item in the dictionary.
* @return The name converted to a string.
@@ -735,8 +735,8 @@ public class COSDictionary extends COSBa
}
/**
- * 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.
+ * This is a convenience method that will get the dictionary object that is expected to be a
+ * string. Null is returned if the entry does not exist in the dictionary.
*
* @param key The key to the item in the dictionary.
* @param defaultValue The default value to return.
@@ -748,8 +748,8 @@ public class COSDictionary extends COSBa
}
/**
- * 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.
+ * This is a convenience method that will get the dictionary object that is expected to be a
+ * string. Null is returned if the entry does not exist in the dictionary.
*
* @param key The key to the item in the dictionary.
* @param defaultValue The default value to return.
@@ -817,10 +817,10 @@ public class COSDictionary extends COSBa
public String getEmbeddedString(String embedded, COSName key, String defaultValue)
{
String retval = defaultValue;
- COSDictionary dic = (COSDictionary) getDictionaryObject(embedded);
- if (dic != null)
+ COSBase base = getDictionaryObject(embedded);
+ if (base instanceof COSDictionary)
{
- retval = dic.getString(key, defaultValue);
+ retval = ((COSDictionary) base).getString(key, defaultValue);
}
return retval;
}