org.metasyntactic.tool.codecounter
Class JavaSourceTokenStream

java.lang.Object
  |
  +--org.metasyntactic.tool.codecounter.JavaSourceTokenStream

public class JavaSourceTokenStream
extends java.lang.Object

JavaSourceTokenStream --- A Stream specialized to Java Source. A helper class for the JavaSource class.


Constructor Summary
JavaSourceTokenStream(java.io.InputStream FileInputStream)
          Creates a JavaSourceTokenStream object, which supports parsing of Java Source.
 
Method Summary
 boolean atEof()
          Returns true if you are currently at EOF in the token stream.
 boolean atEol()
          Returns true if you are currently at EOL in the token stream.
 JavaSourceToken currentToken()
          Returns the current JavaSourceToken.
 void nextToken()
          Moves forward one token in the token stream.
 int position()
          Returns an int representing the current position of the stream.
 void previousToken()
          Moves back one token in the token stream.
 int setPosition(int newPosition)
          Sets the position of the stream, unless the passed int is not a legal position within the stream.
 java.lang.String tokenString()
          Returns the string representation of the current token, or a blank if it's a non-printing character like EOF or EOL.
 java.lang.String tokenStringAt(int position)
          Returns the string representation of the token at position, or a blank if it's a non-printing character like EOF or EOL.
 java.lang.String toString()
          A debugging function.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JavaSourceTokenStream

public JavaSourceTokenStream(java.io.InputStream FileInputStream)
                      throws java.io.IOException
Creates a JavaSourceTokenStream object, which supports parsing of Java Source. The token stream records each token as a string, as well as EOF and EOL. Each EOL token indicates if code occurred on its line through the hasCode boolean.

Parameters:
FileInputStream - The file containing Java source code to be tokenized.
Throws:
java.io.IOException - Thrown if something goes sour with the file.
Method Detail

previousToken

public void previousToken()
Moves back one token in the token stream. Stops moving at the beginning of the token stream.


nextToken

public void nextToken()
Moves forward one token in the token stream. Stops moving at the end of the token stream.


atEof

public boolean atEof()
Returns true if you are currently at EOF in the token stream.


atEol

public boolean atEol()
Returns true if you are currently at EOL in the token stream.


tokenString

public java.lang.String tokenString()
Returns the string representation of the current token, or a blank if it's a non-printing character like EOF or EOL.


tokenStringAt

public java.lang.String tokenStringAt(int position)
Returns the string representation of the token at position, or a blank if it's a non-printing character like EOF or EOL.


position

public int position()
Returns an int representing the current position of the stream.


currentToken

public JavaSourceToken currentToken()
Returns the current JavaSourceToken.


setPosition

public int setPosition(int newPosition)
Sets the position of the stream, unless the passed int is not a legal position within the stream. In that case, this function does nothing.

Parameters:
newPosition - The new position.
Returns:
The new position, which may or may not equal newPosition.

toString

public java.lang.String toString()
A debugging function. Returns the entire tokenStream in a string.

Overrides:
toString in class java.lang.Object