pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1646551 - in /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser: BaseParser.java VisualSignatureParser.java
Date Thu, 18 Dec 2014 22:17:22 GMT
Author: tilman
Date: Thu Dec 18 22:17:22 2014
New Revision: 1646551

URL: http://svn.apache.org/r1646551
Log:
PDFBOX-2576: move method to the only class where it is used and rename it

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/BaseParser.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/VisualSignatureParser.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=1646551&r1=1646550&r2=1646551&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 Thu Dec
18 22:17:22 2014
@@ -1349,51 +1349,6 @@ public abstract class BaseParser
     }
 
     /**
-     * This will read bytes until the end of line marker occurs.
-     *
-     * @param theString The next expected string in the stream.
-     *
-     * @return The characters between the current position and the end of the line.
-     *
-     * @throws IOException If there is an error reading from the stream or theString does
not match what was read.
-     */
-    protected String readExpectedString( String theString ) throws IOException
-    {
-        int c = pdfSource.read();
-        while( isWhitespace(c) && c != -1)
-        {
-            c = pdfSource.read();
-        }
-        StringBuilder buffer = new StringBuilder( theString.length() );
-        int charsRead = 0;
-        while( !isEOL(c) && c != -1 && charsRead < theString.length()
)
-        {
-            char next = (char)c;
-            buffer.append( next );
-            if( theString.charAt( charsRead ) == next )
-            {
-                charsRead++;
-            }
-            else
-            {
-                pdfSource.unread(buffer.toString().getBytes("ISO-8859-1"));
-                throw new IOException( "Error: Expected to read '" + theString +
-                        "' instead started reading '" +buffer.toString() + "'" );
-            }
-            c = pdfSource.read();
-        }
-        while( isEOL(c) && c != -1 )
-        {
-            c = pdfSource.read();
-        }
-        if (c != -1)
-        {
-            pdfSource.unread(c);
-        }
-        return buffer.toString();
-    }
-
-    /**
      * Read one char and throw an exception if it is not the expected value.
      *
      * @param ec the char value that is expected.

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/VisualSignatureParser.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/VisualSignatureParser.java?rev=1646551&r1=1646550&r2=1646551&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/VisualSignatureParser.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/VisualSignatureParser.java
Thu Dec 18 22:17:22 2014
@@ -129,6 +129,53 @@ public class VisualSignatureParser exten
             }
         }
     }
+    
+    /**
+     * This will read bytes until the end of line marker occurs.
+     *
+     * @param theString The next expected string in the stream.
+     *
+     * @return The characters between the current position and the end of the
+     * line.
+     *
+     * @throws IOException If there is an error reading from the stream or
+     * theString does not match what was read.
+     */
+    private String readExpectedStringUntilEOL(String theString) throws IOException
+    {
+        int c = pdfSource.read();
+        while (isWhitespace(c) && c != -1)
+        {
+            c = pdfSource.read();
+        }
+        StringBuilder buffer = new StringBuilder(theString.length());
+        int charsRead = 0;
+        while (!isEOL(c) && c != -1 && charsRead < theString.length())
+        {
+            char next = (char) c;
+            buffer.append(next);
+            if (theString.charAt(charsRead) == next)
+            {
+                charsRead++;
+            }
+            else
+            {
+                pdfSource.unread(buffer.toString().getBytes("ISO-8859-1"));
+                throw new IOException("Error: Expected to read '" + theString
+                        + "' instead started reading '" + buffer.toString() + "'");
+            }
+            c = pdfSource.read();
+        }
+        while (isEOL(c) && c != -1)
+        {
+            c = pdfSource.read();
+        }
+        if (c != -1)
+        {
+            pdfSource.unread(c);
+        }
+        return buffer.toString();
+    }
 
     private boolean parseObject() throws IOException 
     {
@@ -166,7 +213,7 @@ public class VisualSignatureParser exten
             {
                 skipToNextObj();
                 //verify that EOF exists
-                String eof = readExpectedString("%%EOF");
+                String eof = readExpectedStringUntilEOL("%%EOF");
                 if (!eof.contains("%%EOF") && !pdfSource.isEOF())
                 {
                     throw new IOException("expected='%%EOF' actual='" + eof + "' next=" +
readString()



Mime
View raw message