public abstract class BaseParser extends Object
Modifier and Type | Field and Description |
---|---|
static String |
DEF
This is a string constant that will be used for comparisons.
|
protected COSDocument |
document
This is the document that will be parsed.
|
static byte[] |
ENDOBJ
This is a byte array that will be used for comparisons.
|
static byte[] |
ENDSTREAM
This is a byte array that will be used for comparisons.
|
protected static boolean |
FORCE_PARSING
Default value of the
forceParsing flag. |
protected boolean |
forceParsing
Flag to skip malformed or otherwise unparseable input where possible.
|
protected PushBackInputStream |
pdfSource
This is the stream that will be read from.
|
static String |
PROP_PUSHBACK_SIZE
system property allowing to define size of push back buffer.
|
Modifier | Constructor and Description |
---|---|
|
BaseParser()
Default constructor.
|
protected |
BaseParser(byte[] input)
Constructor.
|
|
BaseParser(InputStream input)
Constructor.
|
|
BaseParser(InputStream input,
boolean forceParsingValue)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
isClosing()
This will tell if the next character is a closing brace( close of PDF array ).
|
protected boolean |
isClosing(int c)
This will tell if the next character is a closing brace( close of PDF array ).
|
protected boolean |
isEndOfName(char ch)
Determine if a character terminates a PDF name.
|
protected boolean |
isEOL()
This will tell if the next byte to be read is an end of line byte.
|
protected boolean |
isEOL(int c)
This will tell if the next byte to be read is an end of line byte.
|
protected boolean |
isWhitespace()
This will tell if the next byte is whitespace or not.
|
protected boolean |
isWhitespace(int c)
This will tell if the next byte is whitespace or not.
|
protected COSBoolean |
parseBoolean()
This will parse a boolean object from the stream.
|
protected COSArray |
parseCOSArray()
This will parse a PDF array object.
|
protected COSDictionary |
parseCOSDictionary()
This will parse a PDF dictionary.
|
protected COSName |
parseCOSName()
This will parse a PDF name from the stream.
|
protected COSStream |
parseCOSStream(COSDictionary dic,
RandomAccess file)
This will read a COSStream from the input stream.
|
protected COSString |
parseCOSString(boolean isDictionary)
This will parse a PDF string.
|
protected COSBase |
parseDirObject()
This will parse a directory object from the stream.
|
protected String |
readExpectedString(String theString)
This will read bytes until the end of line marker occurs.
|
protected int |
readInt()
This will read an integer from the stream.
|
protected String |
readLine()
This will read bytes until the first end of line marker occurs.
|
protected String |
readString()
This will read the next string from the stream.
|
protected String |
readString(int length)
This will read the next string from the stream up to a certain length.
|
void |
setDocument(COSDocument doc)
Set the document for this stream.
|
protected void |
skipSpaces()
This will skip all spaces and comments that are present.
|
public static final String PROP_PUSHBACK_SIZE
public static final byte[] ENDSTREAM
public static final byte[] ENDOBJ
public static final String DEF
protected static final boolean FORCE_PARSING
forceParsing
flag.protected PushBackInputStream pdfSource
protected COSDocument document
protected final boolean forceParsing
public BaseParser()
public BaseParser(InputStream input, boolean forceParsingValue) throws IOException
input
- The input stream to read the data from.forceParsingValue
- flag to skip malformed or otherwise unparseable
input where possibleIOException
- If there is an error reading the input stream.public BaseParser(InputStream input) throws IOException
input
- The input stream to read the data from.IOException
- If there is an error reading the input stream.protected BaseParser(byte[] input) throws IOException
input
- The array to read the data from.IOException
- If there is an error reading the byte data.public void setDocument(COSDocument doc)
doc
- The current document.protected COSDictionary parseCOSDictionary() throws IOException
IOException
- IF there is an error reading the stream.protected COSStream parseCOSStream(COSDictionary dic, RandomAccess file) throws IOException
file
- The file to write the stream to when reading.dic
- The dictionary that goes with this stream.IOException
- If there is an error reading the stream.protected COSString parseCOSString(boolean isDictionary) throws IOException
isDictionary
- indicates if the stream is a dictionary or notIOException
- If there is an error reading from the stream.protected COSArray parseCOSArray() throws IOException
IOException
- If there is an error parsing the stream.protected boolean isEndOfName(char ch)
ch
- The charactertrue
if the character terminates a PDF name, otherwise false
.protected COSName parseCOSName() throws IOException
IOException
- If there is an error reading from the stream.protected COSBoolean parseBoolean() throws IOException
IOException
- If an IO error occurs during parsing.protected COSBase parseDirObject() throws IOException
IOException
- If there is an error during parsing.protected String readString() throws IOException
IOException
- If there is an error reading from the stream.protected String readExpectedString(String theString) throws IOException
theString
- The next expected string in the stream.IOException
- If there is an error reading from the stream or theString does not match what was read.protected String readString(int length) throws IOException
length
- The length to stop reading at.IOException
- If there is an error reading from the stream.protected boolean isClosing() throws IOException
IOException
- If an IO error occurs.protected boolean isClosing(int c)
c
- The character to check against end of lineprotected String readLine() throws IOException
IOException
- If there is an error reading from the stream.protected boolean isEOL() throws IOException
IOException
- If there is an error reading from the stream.protected boolean isEOL(int c)
c
- The character to check against end of lineprotected boolean isWhitespace() throws IOException
IOException
- If there is an error reading from the stream.protected boolean isWhitespace(int c)
c
- The character to check against whitespaceprotected void skipSpaces() throws IOException
IOException
- If there is an error reading from the stream.protected int readInt() throws IOException
IOException
- If there is an error reading from the stream.Copyright © 2002-2013 The Apache Software Foundation. All Rights Reserved.