Author: lehmi
Date: Sun Mar  7 16:00:51 2010
New Revision: 920021

URL: http://svn.apache.org/viewvc?rev=920021&view=rev
Log:
PDFBOX-628: removed redundant calls in some convenience methods of 
COSDictionary. Based on a patch by Johannes Koch (johannes dot koch at fit dot 
fraunhofer dot de)

Modified:
    pdfbox/trunk/src/main/java/org/apache/pdfbox/cos/COSDictionary.java

Modified: pdfbox/trunk/src/main/java/org/apache/pdfbox/cos/COSDictionary.java
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/src/main/java/org/apache/pdfbox/cos/COSDictionary.java?rev=920021&r1=920020&r2=920021&view=diff
==============================================================================
--- pdfbox/trunk/src/main/java/org/apache/pdfbox/cos/COSDictionary.java 
(original)
+++ pdfbox/trunk/src/main/java/org/apache/pdfbox/cos/COSDictionary.java Sun Mar 
 7 16:00:51 2010
@@ -982,7 +982,7 @@
      */
     public int getInt( String key )
     {
-        return getInt( COSName.getPDFName( key ) );
+        return getInt( COSName.getPDFName( key ), -1 );
     }
 
     /**
@@ -1028,7 +1028,7 @@
      */
     public int getInt( String key, int defaultValue )
     {
-        return getInt( new String []{ key }, defaultValue );
+        return getInt( COSName.getPDFName( key ), defaultValue );
     }
 
     /**
@@ -1042,7 +1042,13 @@
      */
     public int getInt( COSName key, int defaultValue )
     {
-        return getInt(key.getName(), defaultValue );
+        int retval = defaultValue;
+        COSBase obj = getDictionaryObject( key );
+        if( obj != null && obj instanceof COSNumber)
+        {
+            retval = ((COSNumber)obj).intValue();
+        }
+        return retval;
     }
 
     /**
@@ -1055,7 +1061,7 @@
      */
     public long getLong( String key )
     {
-        return getLong( COSName.getPDFName( key ) );
+        return getLong( COSName.getPDFName( key ), -1L );
     }
 
     /**
@@ -1101,7 +1107,7 @@
      */
     public long getLong( String key, long defaultValue )
     {
-        return getLong( new String []{ key }, defaultValue );
+        return getLong( COSName.getPDFName( key ), defaultValue );
     }
 
     /**
@@ -1115,19 +1121,25 @@
      */
     public long getLong( COSName key, long defaultValue )
     {
-        return getLong(key.getName(), defaultValue );
+        long retval = defaultValue;
+        COSBase obj = getDictionaryObject( key );
+        if( obj != null && 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 int.  -1 is returned if there is no value.
+     * is expected to be an float.  -1 is returned if there is no value.
      *
      * @param key The key to the item in the dictionary.
      * @return The float value.
      */
     public float getFloat( String key )
     {
-        return getFloat( COSName.getPDFName( key ) );
+        return getFloat( COSName.getPDFName( key ), -1 );
     }
 
     /**


Reply via email to