com.lowagie.text.pdf

Class PdfContentParser

public class PdfContentParser extends Object

Parses the page or template content.

Author: Paulo Soares (psoares@consiste.pt)

Field Summary
static intCOMMAND_TYPE
Commands have this type.
PRTokenisertokeniser
Holds value of property tokeniser.
Constructor Summary
PdfContentParser(PRTokeniser tokeniser)
Creates a new instance of PdfContentParser
Method Summary
PRTokenisergetTokeniser()
Gets the tokeniser.
booleannextValidToken()
Reads the next token skipping over the comments.
ArrayListparse(ArrayList ls)
Parses a single command from the content.
PdfArrayreadArray()
Reads an array.
PdfDictionaryreadDictionary()
Reads a dictionary.
PdfObjectreadPRObject()
Reads a pdf object.
voidsetTokeniser(PRTokeniser tokeniser)
Sets the tokeniser.

Field Detail

COMMAND_TYPE

public static final int COMMAND_TYPE
Commands have this type.

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

getTokeniser

public PRTokeniser getTokeniser()
Gets the tokeniser.

Returns: the tokeniser.

nextValidToken

public boolean nextValidToken()
Reads the next token skipping over the comments.

Returns: true if a token was read, false if the end of content was reached

Throws: IOException on error

parse

public ArrayList parse(ArrayList ls)
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 an ArrayList to use. It will be cleared before using. If it's null will create a new ArrayList

Returns: the same ArrayList given as argument or a new one

Throws: IOException on error

readArray

public PdfArray readArray()
Reads an array. The tokeniser must be positioned past the "[" token.

Returns: an array

Throws: IOException on error

readDictionary

public PdfDictionary readDictionary()
Reads a dictionary. The tokeniser must be positioned past the "<<" token.

Returns: the dictionary

Throws: IOException on error

readPRObject

public PdfObject readPRObject()
Reads a pdf object.

Returns: the pdf object

Throws: IOException on error

setTokeniser

public void setTokeniser(PRTokeniser tokeniser)
Sets the tokeniser.

Parameters: tokeniser the tokeniser