pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1671510 - in /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser: BaseParser.java COSParser.java
Date Mon, 06 Apr 2015 11:06:04 GMT
Author: tilman
Date: Mon Apr  6 11:06:04 2015
New Revision: 1671510

URL: http://svn.apache.org/r1671510
Log:
PDFBOX-2576: move isString methods to the only class where they are being used and make them
private

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/BaseParser.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.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=1671510&r1=1671509&r2=1671510&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 Mon Apr
 6 11:06:04 2015
@@ -17,13 +17,11 @@
 package org.apache.pdfbox.pdfparser;
 
 import java.io.BufferedInputStream;
-import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.Closeable;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
-import java.util.Arrays;
 import java.util.regex.Pattern;
 
 import org.apache.commons.logging.Log;
@@ -1549,61 +1547,8 @@ public abstract class BaseParser impleme
     {
         return c >= ASCII_ZERO && c <= ASCII_NINE;
     }
-    /**
-     * Checks if the given string can be found at the current offset.
-     * 
-     * @param string the bytes of the string to look for
-     * @return true if the bytes are in place, false if not
-     * @throws IOException if something went wrong
-     */
-    protected boolean isString(byte[] string) throws IOException
-    {
-        boolean bytesMatching = false;
-        if (pdfSource.peek() == string[0])
-        {
-            int length = string.length;
-            byte[] bytesRead = new byte[length];
-            int numberOfBytes = pdfSource.read(bytesRead, 0, length);
-            while (numberOfBytes < length)
-            {
-                int readMore = pdfSource.read(bytesRead, numberOfBytes, length - numberOfBytes);
-                if (readMore < 0)
-                {
-                    break;
-                }
-                numberOfBytes += readMore;
-            }
-            if (Arrays.equals(string, bytesRead))
-            {
-                bytesMatching = true;
-            }
-            pdfSource.unread(bytesRead, 0, numberOfBytes);
-        }
-        return bytesMatching;
-    }
 
     /**
-     * Checks if the given string can be found at the current offset.
-     * 
-     * @param string the bytes of the string to look for
-     * @return true if the bytes are in place, false if not
-     * @throws IOException if something went wrong
-     */
-    protected boolean isString(char[] string) throws IOException
-    {
-        boolean bytesMatching = true;
-        long originOffset = pdfSource.getOffset();
-        for (char c : string)
-        {
-            if (pdfSource.read() != c)
-            {
-                bytesMatching = false;
-            }
-        }
-        pdfSource.seek(originOffset);
-        return bytesMatching;
-    }
-    /**
      * This will skip all spaces and comments that are present.
      *
      * @throws IOException If there is an error reading from the stream.

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java?rev=1671510&r1=1671509&r2=1671510&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java Mon Apr 
6 11:06:04 2015
@@ -22,6 +22,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
@@ -1553,6 +1554,61 @@ public class COSParser extends BaseParse
         }
         return startXref;
     }
+    
+    /**
+     * Checks if the given string can be found at the current offset.
+     * 
+     * @param string the bytes of the string to look for
+     * @return true if the bytes are in place, false if not
+     * @throws IOException if something went wrong
+     */
+    private boolean isString(byte[] string) throws IOException
+    {
+        boolean bytesMatching = false;
+        if (pdfSource.peek() == string[0])
+        {
+            int length = string.length;
+            byte[] bytesRead = new byte[length];
+            int numberOfBytes = pdfSource.read(bytesRead, 0, length);
+            while (numberOfBytes < length)
+            {
+                int readMore = pdfSource.read(bytesRead, numberOfBytes, length - numberOfBytes);
+                if (readMore < 0)
+                {
+                    break;
+                }
+                numberOfBytes += readMore;
+            }
+            if (Arrays.equals(string, bytesRead))
+            {
+                bytesMatching = true;
+            }
+            pdfSource.unread(bytesRead, 0, numberOfBytes);
+        }
+        return bytesMatching;
+    }
+
+    /**
+     * Checks if the given string can be found at the current offset.
+     * 
+     * @param string the bytes of the string to look for
+     * @return true if the bytes are in place, false if not
+     * @throws IOException if something went wrong
+     */
+    private boolean isString(char[] string) throws IOException
+    {
+        boolean bytesMatching = true;
+        long originOffset = pdfSource.getOffset();
+        for (char c : string)
+        {
+            if (pdfSource.read() != c)
+            {
+                bytesMatching = false;
+            }
+        }
+        pdfSource.seek(originOffset);
+        return bytesMatching;
+    }
 
     /**
      * This will parse the trailer from the stream and add it to the state.



Mime
View raw message