PDF Clown
0.0.8

it.stefanochizzolini.clown.tokens
Class Parser

java.lang.Object
  extended by it.stefanochizzolini.clown.tokens.Parser
All Implemented Interfaces:
Closeable

public class Parser
extends Object
implements Closeable

Token parser.

Contract

Version:
0.0.8
Author:
Stefano Chizzolini (http://www.stefanochizzolini.it)

Nested Class Summary
 class Parser.Reference
           
 
Method Summary
 void close()
           
protected  void finalize()
           
 long getLength()
           
 long getPosition()
           
 IInputStream getStream()
           
 Object getToken()
          Gets the currently-parsed token.
 TokenTypeEnum getTokenType()
          Gets the currently-parsed token type.
 int hashCode()
           
protected static boolean isDelimiter(int c)
          Evaluates whether a character is a delimiter [PDF:1.6:3.1.1].
protected static boolean isEOL(int c)
          Evaluates whether a character is an EOL marker [PDF:1.6:3.1.1].
protected static boolean isWhitespace(int c)
          Evaluates whether a character is a white-space [PDF:1.6:3.1.1].
 boolean moveNext()
          Parse the next token [PDF:1.6:3.1].
 boolean moveNext(int offset)
           
 PdfDataObject parsePdfObject()
          Parse the current PDF object [PDF:1.6:3.2].
 String retrieveVersion()
          Retrieves the PDF version of the file [PDF:1.6:3.4.1].
 long retrieveXRefOffset()
          Retrieves the starting position of the last xref-table section.
 long retrieveXRefOffset(long offset)
          Retrieves the starting position of an xref-table section [PDF:1.6:3.4.4].
 void seek(long position)
           
 void skip(long offset)
           
 boolean skipWhitespace()
          Moves to the last whitespace after the current position in order to let read the first non-whitespace.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isDelimiter

protected static boolean isDelimiter(int c)
Evaluates whether a character is a delimiter [PDF:1.6:3.1.1].


isEOL

protected static boolean isEOL(int c)
Evaluates whether a character is an EOL marker [PDF:1.6:3.1.1].


isWhitespace

protected static boolean isWhitespace(int c)
Evaluates whether a character is a white-space [PDF:1.6:3.1.1].


getLength

public long getLength()

getPosition

public long getPosition()

getStream

public IInputStream getStream()

getToken

public Object getToken()
Gets the currently-parsed token.

Returns:
The current token.

getTokenType

public TokenTypeEnum getTokenType()
Gets the currently-parsed token type.

Returns:
The current token type.

hashCode

public int hashCode()
Overrides:
hashCode in class Object

moveNext

public boolean moveNext(int offset)
                 throws FileFormatException
Parameters:
offset - Number of tokens to be skipped before reaching the intended one.
Throws:
FileFormatException

moveNext

public boolean moveNext()
                 throws FileFormatException
Parse the next token [PDF:1.6:3.1].

Contract

Returns:
Whether a new token was found.
Throws:
FileFormatException

parsePdfObject

public PdfDataObject parsePdfObject()
                             throws FileFormatException
Parse the current PDF object [PDF:1.6:3.2].

Contract

Throws:
FileFormatException

retrieveVersion

public String retrieveVersion()
                       throws FileFormatException
Retrieves the PDF version of the file [PDF:1.6:3.4.1].

Contract

Throws:
FileFormatException

retrieveXRefOffset

public long retrieveXRefOffset()
                        throws FileFormatException
Retrieves the starting position of the last xref-table section.

Throws:
FileFormatException
See Also:
retrieveXRefOffset(long)

retrieveXRefOffset

public long retrieveXRefOffset(long offset)
                        throws FileFormatException
Retrieves the starting position of an xref-table section [PDF:1.6:3.4.4].

Contract

Parameters:
offset - Position of the EOF marker related to the section intended to be parsed.
Throws:
FileFormatException

seek

public void seek(long position)

skip

public void skip(long offset)

skipWhitespace

public boolean skipWhitespace()
Moves to the last whitespace after the current position in order to let read the first non-whitespace.


close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Throws:
IOException

finalize

protected void finalize()
                 throws Throwable
Overrides:
finalize in class Object
Throws:
Throwable

PDF Clown
0.0.8

Project home page

Copyright © 2006-2010 Stefano Chizzolini. Some Rights Reserved.
This documentation is available under the terms of the GNU Free Documentation License.