org.jcoderz.phoenix.report
Class Syntax

java.lang.Object
  extended by org.jcoderz.phoenix.report.Syntax

public class Syntax
extends Object

Splits an input file into several tokens suitable for syntax highlighting. This class encapsulates the access to the jEdit syntax highlighter package. No jEdit related classes should be passed by interfaces of this class.

Author:
Andreas Mandel

Constructor Summary
Syntax(File in, Charset charSet, int tabWidth)
          Initializes an Ascii2Html instance.
 
Method Summary
 int getCurrentLineNumber()
          The line number of the currently parsed token.
 int getCurrentLinePos()
          Returns the cursor position of start of the current token.
 int getCurrentTokenLength()
          Returns the length of the current reported token.
 String getCurrentTokenType()
          Returns the current token type as string.
 int getNumberOfLines()
          Returns the number of lines of the parsed file.
 String nextToken()
          Parses the next token and returns its textual content as string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Syntax

public Syntax(File in,
              Charset charSet,
              int tabWidth)
       throws IOException
Initializes an Ascii2Html instance.

Parameters:
in - the source file to read.
charSet - the char set to use when reading the source file. If null the platform default char set will be used.
tabWidth - the tab width to use when calculating the cursor position.
Throws:
IOException - if a error occurs while reading the source file.
Method Detail

getNumberOfLines

public int getNumberOfLines()
Returns the number of lines of the parsed file. The value is available after creation of the class.

Returns:
the number of lines of the parsed file.

getCurrentLineNumber

public int getCurrentLineNumber()
The line number of the currently parsed token. Counting starts with line 1. Nevertheless prior the first call to nextToken() 0 is returned.

Returns:
the line number of the currently parsed token.

getCurrentLinePos

public int getCurrentLinePos()
Returns the cursor position of start of the current token.

Returns:
the cursor position of start of the current token.

getCurrentTokenType

public String getCurrentTokenType()
Returns the current token type as string. To be used as symbolic identifier of the token. Possible return values can be fount in Token.tokenToString(byte). For the Token.END null is returned.

Returns:
the current token type as string.

getCurrentTokenLength

public int getCurrentTokenLength()
Returns the length of the current reported token.

Returns:
the length of the current reported token.

nextToken

public String nextToken()
Parses the next token and returns its textual content as string.

Returns:
the textual content of the new token.


Copyright 2007 The jCoderZ Project.