pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1678441 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/BaseParser.java
Date Fri, 08 May 2015 19:32:47 GMT
Author: tilman
Date: Fri May  8 19:32:46 2015
New Revision: 1678441

URL: http://svn.apache.org/r1678441
Log:
PDFBOX-2576: slight simplify; make method static that is called by static method

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/BaseParser.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/BaseParser.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/BaseParser.java?rev=1678441&r1=1678440&r2=1678441&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/BaseParser.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/BaseParser.java Fri May
 8 19:32:46 2015
@@ -176,7 +176,7 @@ public abstract class BaseParser impleme
 
     private static boolean isHexDigit(char ch)
     {
-        return (ch >= ASCII_ZERO && ch <= ASCII_NINE) ||
+        return isDigit(ch) ||
         (ch >= 'a' && ch <= 'f') ||
         (ch >= 'A' && ch <= 'F');
     }
@@ -190,34 +190,28 @@ public abstract class BaseParser impleme
      */
     private COSBase parseCOSDictionaryValue() throws IOException
     {
-        COSBase retval = null;
         long numOffset = pdfSource.getOffset();
         COSBase number = parseDirObject();
         skipSpaces();
-        char next = (char)pdfSource.peek();
-        if( next >= ASCII_ZERO && next <= ASCII_NINE )
+        if (!isDigit())
         {
-            long genOffset = pdfSource.getOffset();
-            COSBase generationNumber = parseDirObject();
-            skipSpaces();
-            readExpectedChar('R');
-            if (!(number instanceof COSInteger))
-            {
-                throw new IOException("expected number, actual=" + number + " at offset "
+ numOffset);
-            }
-            if (!(generationNumber instanceof COSInteger))
-            {
-                throw new IOException("expected number, actual=" + number + " at offset "
+ genOffset);
-            }
-            COSObjectKey key = new COSObjectKey(((COSInteger) number).longValue(),
-                    ((COSInteger) generationNumber).intValue());
-            retval = getObjectFromPool(key);
+            return number;
         }
-        else
+        long genOffset = pdfSource.getOffset();
+        COSBase generationNumber = parseDirObject();
+        skipSpaces();
+        readExpectedChar('R');
+        if (!(number instanceof COSInteger))
         {
-            retval = number;
+            throw new IOException("expected number, actual=" + number + " at offset " + numOffset);
         }
-        return retval;
+        if (!(generationNumber instanceof COSInteger))
+        {
+            throw new IOException("expected number, actual=" + number + " at offset " + genOffset);
+        }
+        COSObjectKey key = new COSObjectKey(((COSInteger) number).longValue(),
+                ((COSInteger) generationNumber).intValue());
+        return getObjectFromPool(key);
     }
 
     private COSBase getObjectFromPool(COSObjectKey key) throws IOException
@@ -1364,7 +1358,7 @@ public abstract class BaseParser impleme
      * @param c The character to be checked
      * @return true if the next byte in the stream is a digit.
      */
-    protected boolean isDigit(int c)
+    protected static boolean isDigit(int c)
     {
         return c >= ASCII_ZERO && c <= ASCII_NINE;
     }



Mime
View raw message