ConformingPDFParser, PDFObjectStreamParser, PDFParser, PDFStreamParser, PDFXrefStreamParser, VisualSignatureParserpublic abstract class BaseParser
extends java.lang.Object
| Modifier and Type | Field | Description |
|---|---|---|
static java.lang.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 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 java.lang.String |
PROP_PUSHBACK_SIZE |
system property allowing to define size of push back buffer.
|
| Modifier | Constructor | Description |
|---|---|---|
|
BaseParser() |
Default constructor.
|
protected |
BaseParser(byte[] input) |
Constructor.
|
|
BaseParser(java.io.InputStream input) |
Constructor.
|
|
BaseParser(java.io.InputStream input,
boolean forceParsingValue) |
Constructor.
|
| Modifier and Type | Method | Description |
|---|---|---|
void |
clearResources() |
Release all used resources.
|
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() |
This will parse a PDF string.
|
protected COSString |
parseCOSString(boolean isDictionary) |
Deprecated.
Not needed anymore.
|
protected COSBase |
parseDirObject() |
This will parse a directory object from the stream.
|
protected java.lang.String |
readExpectedString(java.lang.String theString) |
This will read bytes until the end of line marker occurs.
|
protected int |
readGenerationNumber() |
This will read a integer from the Stream and throw an
IllegalArgumentException if the integer value
has more than the maximum object revision (i.e. : bigger than GENERATION_NUMBER_THRESHOLD) |
protected int |
readInt() |
This will read an integer from the stream.
|
protected java.lang.String |
readLine() |
This will read bytes until the first end of line marker occurs.
|
protected long |
readLong() |
This will read an long from the stream.
|
protected long |
readObjectNumber() |
This will read a long from the Stream and throw an
IllegalArgumentException if the long value
has more than 10 digits (i.e. : bigger than OBJECT_NUMBER_THRESHOLD) |
protected java.lang.String |
readString() |
This will read the next string from the stream.
|
protected java.lang.String |
readString(int length) |
This will read the next string from the stream up to a certain length.
|
protected java.lang.StringBuilder |
readStringNumber() |
This method is used to read a token by the readInt() method
and the readLong() method.
|
protected void |
readUntilEndStream(java.io.OutputStream out) |
This method will read through the current stream object until
we find the keyword "endstream" meaning we're at the end of this
object.
|
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 java.lang.String PROP_PUSHBACK_SIZE
public static final byte[] ENDSTREAM
public static final byte[] ENDOBJ
public static final java.lang.String DEF
protected PushBackInputStream pdfSource
protected COSDocument document
protected final boolean forceParsing
public BaseParser()
public BaseParser(java.io.InputStream input,
boolean forceParsingValue)
throws java.io.IOException
input - The input stream to read the data from.forceParsingValue - flag to skip malformed or otherwise unparseable
input where possiblejava.io.IOException - If there is an error reading the input stream.public BaseParser(java.io.InputStream input)
throws java.io.IOException
input - The input stream to read the data from.java.io.IOException - If there is an error reading the input stream.protected BaseParser(byte[] input)
throws java.io.IOException
input - The array to read the data from.java.io.IOException - If there is an error reading the byte data.public void setDocument(COSDocument doc)
doc - The current document.protected COSDictionary parseCOSDictionary() throws java.io.IOException
java.io.IOException - IF there is an error reading the stream.protected COSStream parseCOSStream(COSDictionary dic, RandomAccess file) throws java.io.IOException
file - The file to write the stream to when reading.dic - The dictionary that goes with this stream.java.io.IOException - If there is an error reading the stream.protected void readUntilEndStream(java.io.OutputStream out)
throws java.io.IOException
out - stream we write out to.java.io.IOException@Deprecated protected COSString parseCOSString(boolean isDictionary) throws java.io.IOException
parseCOSString() instead. PDFBOX-1437isDictionary - indicates if the stream is a dictionary or notjava.io.IOException - If there is an error reading from the stream.protected COSString parseCOSString() throws java.io.IOException
java.io.IOException - If there is an error reading from the stream.protected COSArray parseCOSArray() throws java.io.IOException
java.io.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 java.io.IOException
java.io.IOException - If there is an error reading from the stream.protected COSBoolean parseBoolean() throws java.io.IOException
java.io.IOException - If an IO error occurs during parsing.protected COSBase parseDirObject() throws java.io.IOException
java.io.IOException - If there is an error during parsing.protected java.lang.String readString()
throws java.io.IOException
java.io.IOException - If there is an error reading from the stream.protected java.lang.String readExpectedString(java.lang.String theString)
throws java.io.IOException
theString - The next expected string in the stream.java.io.IOException - If there is an error reading from the stream or theString does not match what was read.protected java.lang.String readString(int length)
throws java.io.IOException
length - The length to stop reading at.java.io.IOException - If there is an error reading from the stream.protected boolean isClosing()
throws java.io.IOException
java.io.IOException - If an IO error occurs.protected boolean isClosing(int c)
c - The character to check against end of lineprotected java.lang.String readLine()
throws java.io.IOException
java.io.IOException - If there is an error reading from the stream.protected boolean isEOL()
throws java.io.IOException
java.io.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 java.io.IOException
java.io.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 java.io.IOException
java.io.IOException - If there is an error reading from the stream.protected long readObjectNumber()
throws java.io.IOException
IllegalArgumentException if the long value
has more than 10 digits (i.e. : bigger than OBJECT_NUMBER_THRESHOLD)java.io.IOException - if an I/O error occursprotected int readGenerationNumber()
throws java.io.IOException
IllegalArgumentException if the integer value
has more than the maximum object revision (i.e. : bigger than GENERATION_NUMBER_THRESHOLD)java.io.IOException - if an I/O error occursprotected int readInt()
throws java.io.IOException
java.io.IOException - If there is an error reading from the stream.protected long readLong()
throws java.io.IOException
java.io.IOException - If there is an error reading from the stream.protected final java.lang.StringBuilder readStringNumber()
throws java.io.IOException
java.io.IOException - throws by the pdfSource methods.public void clearResources()