You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ja...@apache.org on 2014/09/26 20:34:36 UTC

svn commit: r1627857 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFStreamParser.java

Author: jahewson
Date: Fri Sep 26 18:34:36 2014
New Revision: 1627857

URL: http://svn.apache.org/r1627857
Log:
PDFBOX-2385: Clean Up

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

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFStreamParser.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFStreamParser.java?rev=1627857&r1=1627856&r2=1627857&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFStreamParser.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFStreamParser.java Fri Sep 26 18:34:36 2014
@@ -41,8 +41,7 @@ import org.apache.pdfbox.contentstream.o
 /**
  * This will parse a PDF byte stream and extract operands and such.
  *
- * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
- * @version $Revision$
+ * @author Ben Litchfield
  */
 public class PDFStreamParser extends BaseParser
 {
@@ -52,8 +51,8 @@ public class PDFStreamParser extends Bas
     private static final Log LOG = LogFactory.getLog(PDFStreamParser.class);
 
     private List<Object> streamObjects = new ArrayList<Object>( 100 );
-    private final int    MAXBINCHARTESTLENGTH = 10;
-    private final byte[] binCharTestArr = new byte[MAXBINCHARTESTLENGTH];
+    private final int MAX_BIN_CHAR_TEST_LENGTH = 10;
+    private final byte[] binCharTestArr = new byte[MAX_BIN_CHAR_TEST_LENGTH];
 
     /**
      * Constructor that takes a stream to parse.
@@ -342,13 +341,13 @@ public class PDFStreamParser extends Bas
                 buf.append( c );
                 pdfSource.read();
 
-                boolean dotNotRead = (c != '.');
-                while( Character.isDigit(( c = (char)pdfSource.peek()) ) || (dotNotRead && (c == '.')) )
+                boolean dotNotRead = c != '.';
+                while( Character.isDigit(c = (char)pdfSource.peek()) || dotNotRead && c == '.')
                 {
                     buf.append( c );
                     pdfSource.read();
 
-                    if (dotNotRead && (c == '.'))
+                    if (dotNotRead && c == '.')
                     {
                         dotNotRead = false;
                     }
@@ -451,7 +450,7 @@ public class PDFStreamParser extends Bas
             throws IOException
     {
         // as suggested in PDFBOX-1164
-        final int readBytes = pdfSource.read(binCharTestArr, 0, MAXBINCHARTESTLENGTH);
+        final int readBytes = pdfSource.read(binCharTestArr, 0, MAX_BIN_CHAR_TEST_LENGTH);
         boolean noBinData = true;
         int startOpIdx = -1;
         int endOpIdx = -1;
@@ -461,7 +460,7 @@ public class PDFStreamParser extends Bas
             for (int bIdx = 0; bIdx < readBytes; bIdx++)
             {
                 final byte b = binCharTestArr[bIdx];
-                if ((b < 0x09) || ((b > 0x0a) && (b < 0x20) && (b != 0x0d)))
+                if (b < 0x09 || b > 0x0a && b < 0x20 && b != 0x0d)
                 {
                     // control character or > 0x7f -> we have binary data
                     noBinData = false;
@@ -472,7 +471,8 @@ public class PDFStreamParser extends Bas
                 {
                     startOpIdx = bIdx;
                 }
-                else if (startOpIdx != -1 && endOpIdx == -1 && (b == 9 || b == 0x20 || b == 0x0a || b == 0x0d))
+                else if (startOpIdx != -1 && endOpIdx == -1 &&
+                         (b == 9 || b == 0x20 || b == 0x0a || b == 0x0d))
                 {
                     if (bIdx == startOpIdx + 1)
                     {
@@ -485,7 +485,7 @@ public class PDFStreamParser extends Bas
                     }
                 }
             }
-            if (readBytes == MAXBINCHARTESTLENGTH) // only if not close to eof
+            if (readBytes == MAX_BIN_CHAR_TEST_LENGTH) // only if not close to eof
             {
                 // a PDF operator is 1-3 bytes long
                 if (endOpIdx == -1 || startOpIdx == -1 || endOpIdx - startOpIdx > 3)