Return-Path: X-Original-To: apmail-pdfbox-commits-archive@www.apache.org Delivered-To: apmail-pdfbox-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C241A17804 for ; Mon, 6 Apr 2015 11:06:05 +0000 (UTC) Received: (qmail 38893 invoked by uid 500); 6 Apr 2015 11:06:05 -0000 Delivered-To: apmail-pdfbox-commits-archive@pdfbox.apache.org Received: (qmail 38865 invoked by uid 500); 6 Apr 2015 11:06:05 -0000 Mailing-List: contact commits-help@pdfbox.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@pdfbox.apache.org Delivered-To: mailing list commits@pdfbox.apache.org Received: (qmail 38856 invoked by uid 99); 6 Apr 2015 11:06:05 -0000 Received: from eris.apache.org (HELO hades.apache.org) (140.211.11.105) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 06 Apr 2015 11:06:05 +0000 Received: from hades.apache.org (localhost [127.0.0.1]) by hades.apache.org (ASF Mail Server at hades.apache.org) with ESMTP id 11CEAAC0044 for ; Mon, 6 Apr 2015 11:06:05 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@pdfbox.apache.org From: tilman@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20150406110605.11CEAAC0044@hades.apache.org> 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.