Package com.aowagie.text.pdf
Class PdfContentParser
- java.lang.Object
-
- com.aowagie.text.pdf.PdfContentParser
-
public class PdfContentParser extends java.lang.Object
Parses the page or template content.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static int
COMMAND_TYPE
Commands have this type.private PRTokeniser
tokeniser
Holds value of property tokeniser.
-
Constructor Summary
Constructors Constructor Description PdfContentParser(PRTokeniser tokeniser)
Creates a new instance of PdfContentParser
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PRTokeniser
getTokeniser()
Gets the tokeniser.private boolean
nextValidToken()
Reads the next token skipping over the comments.java.util.ArrayList
parse(java.util.ArrayList ls)
Parses a single command from the content.private PdfArray
readArray()
Reads an array.private PdfDictionary
readDictionary()
Reads a dictionary.(package private) PdfObject
readPRObject()
Reads a pdf object.void
setTokeniser(PRTokeniser tokeniser)
Sets the tokeniser.
-
-
-
Field Detail
-
COMMAND_TYPE
static final int COMMAND_TYPE
Commands have this type.- See Also:
- Constant Field Values
-
tokeniser
private PRTokeniser tokeniser
Holds value of property tokeniser.
-
-
Constructor Detail
-
PdfContentParser
public PdfContentParser(PRTokeniser tokeniser)
Creates a new instance of PdfContentParser- Parameters:
tokeniser
- the tokeniser with the content
-
-
Method Detail
-
parse
public java.util.ArrayList parse(java.util.ArrayList ls) throws java.io.IOException
Parses a single command from the content. Each command is output as an array of arguments having the command itself as the last element. The returned array will be empty if the end of content was reached.- Parameters:
ls
- anArrayList
to use. It will be cleared before using. If it'snull
will create a newArrayList
- Returns:
- the same
ArrayList
given as argument or a new one - Throws:
java.io.IOException
- on error
-
getTokeniser
public PRTokeniser getTokeniser()
Gets the tokeniser.- Returns:
- the tokeniser.
-
setTokeniser
public void setTokeniser(PRTokeniser tokeniser)
Sets the tokeniser.- Parameters:
tokeniser
- the tokeniser
-
readDictionary
private PdfDictionary readDictionary() throws java.io.IOException
Reads a dictionary. The tokeniser must be positioned past the "<<" token.- Returns:
- the dictionary
- Throws:
java.io.IOException
- on error
-
readArray
private PdfArray readArray() throws java.io.IOException
Reads an array. The tokeniser must be positioned past the "[" token.- Returns:
- an array
- Throws:
java.io.IOException
- on error
-
readPRObject
PdfObject readPRObject() throws java.io.IOException
Reads a pdf object.- Returns:
- the pdf object
- Throws:
java.io.IOException
- on error
-
nextValidToken
private boolean nextValidToken() throws java.io.IOException
Reads the next token skipping over the comments.- Returns:
true
if a token was read,false
if the end of content was reached- Throws:
java.io.IOException
- on error
-
-