PDF Clown
0.1.2

org.pdfclown.util.parsers
Class PostScriptParser

java.lang.Object
  extended by org.pdfclown.util.parsers.PostScriptParser
All Implemented Interfaces:
Closeable
Direct Known Subclasses:
BaseParser

public class PostScriptParser
extends Object
implements Closeable

PostScript (non-procedural subset) parser [PS].

Since:
0.1.1
Version:
0.1.2, 12/02/12
Author:
Stefano Chizzolini (http://www.stefanochizzolini.it)

Nested Class Summary
static class PostScriptParser.TokenTypeEnum
           
 
Constructor Summary
PostScriptParser(byte[] data)
           
PostScriptParser(IInputStream stream)
           
 
Method Summary
 void close()
           
protected  void finalize()
           
protected static int getHex(int c)
           
 long getLength()
           
 long getPosition()
           
 IInputStream getStream()
           
 Object getToken()
          Gets the currently-parsed token.
 Object getToken(int offset)
          Gets a token after moving to the given offset.
 PostScriptParser.TokenTypeEnum getTokenType()
          Gets the currently-parsed token type.
 int hashCode()
           
protected static boolean isDelimiter(int c)
          Evaluates whether a character is a delimiter.
protected static boolean isEOL(int c)
          Evaluates whether a character is an EOL marker.
protected static boolean isWhitespace(int c)
          Evaluates whether a character is a white-space.
 boolean moveNext()
          Moves the pointer to the next token.
 boolean moveNext(int offset)
          Moves the pointer to the token at the given offset.
 void seek(long position)
          Moves the pointer to the given absolute byte position.
protected  void setToken(Object value)
           
protected  void setTokenType(PostScriptParser.TokenTypeEnum value)
           
 void skip(long offset)
          Moves the pointer to the given relative byte position.
 boolean skipEOL()
          Moves the pointer before the next non-EOL character after the current position.
 boolean skipWhitespace()
          Moves the pointer before the next non-whitespace character after the current position.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PostScriptParser

public PostScriptParser(IInputStream stream)

PostScriptParser

public PostScriptParser(byte[] data)
Method Detail

getHex

protected static int getHex(int c)

isDelimiter

protected static boolean isDelimiter(int c)
Evaluates whether a character is a delimiter.


isEOL

protected static boolean isEOL(int c)
Evaluates whether a character is an EOL marker.


isWhitespace

protected static boolean isWhitespace(int c)
Evaluates whether a character is a white-space.


getLength

public long getLength()

getPosition

public long getPosition()

getStream

public IInputStream getStream()

getToken

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


getToken

public Object getToken(int offset)
Gets a token after moving to the given offset.

Parameters:
offset - Number of tokens to skip before reaching the intended one.
See Also:
getToken()

getTokenType

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


hashCode

public int hashCode()
Overrides:
hashCode in class Object

moveNext

public boolean moveNext(int offset)
Moves the pointer to the token at the given offset.

Parameters:
offset - Number of tokens to skip before reaching the intended one.
Returns:
Whether a new token was found.

moveNext

public boolean moveNext()
Moves the pointer to the next token.

To properly parse the current token, the pointer MUST be just before its starting (leading whitespaces are ignored). When this method terminates, the pointer IS at the last byte of the current token.

Returns:
Whether a new token was found.

seek

public void seek(long position)
Moves the pointer to the given absolute byte position.


skip

public void skip(long offset)
Moves the pointer to the given relative byte position.


skipEOL

public boolean skipEOL()
Moves the pointer before the next non-EOL character after the current position.

Returns:
Whether the stream can be further read.

skipWhitespace

public boolean skipWhitespace()
Moves the pointer before the next non-whitespace character after the current position.

Returns:
Whether the stream can be further read.

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

setToken

protected void setToken(Object value)

setTokenType

protected void setTokenType(PostScriptParser.TokenTypeEnum value)

PDF Clown
0.1.2

Project home page

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