Build 1.0_r1(from source)

java.io
Class StreamTokenizer

java.lang.Object
  extended by java.io.StreamTokenizer

public class StreamTokenizer
extends Object

StreamTokenizer takes a stream and a set of tokens and parses them one at a time. The different types of tokens that can be found are numbers, identifiers, quoted strings, and different comment styles.


Field Summary
 double nval
          Contains a number if the current token is a number (ttype is TT_NUMBER)
 String sval
          Contains a string if the current token is a word (ttype is TT_WORD)
static int TT_EOF
          The constant representing end of stream.
static int TT_EOL
          The constant representing end of line.
static int TT_NUMBER
          The constant representing a number token.
static int TT_WORD
          The constant representing a word token.
 int ttype
          The token type
 
Constructor Summary
StreamTokenizer(InputStream is)
          Deprecated. Use StreamTokenizer(Reader)
StreamTokenizer(Reader r)
          Construct a new StreamTokenizer on the Reader r.
 
Method Summary
 void commentChar(int ch)
          Set the character ch to be regarded as a comment character.
 void eolIsSignificant(boolean flag)
          Set a boolean indicating whether or not end of line is significant and should be returned as TT_EOF in ttype.
 int lineno()
          Answer the current line number.
 void lowerCaseMode(boolean flag)
          Set a boolean indicating whether or not tokens should be uppercased when present in sval.
 int nextToken()
          Answer the next token type.
 void ordinaryChar(int ch)
          Set the character ch to be regarded as an ordinary character.
 void ordinaryChars(int low, int hi)
          Set the characters ranging from low to hi to be regarded as ordinary characters.
 void parseNumbers()
          Indicate that numbers should be parsed.
 void pushBack()
          Indicate that the current token should be pushed back and returned the next time nextToken() is called.
 void quoteChar(int ch)
          Set the character ch to be regarded as a quote character.
 void resetSyntax()
          Reset all characters so that they are ordinary.
 void slashSlashComments(boolean flag)
          Set a boolean indicating whether or not slash slash comments should be recognized.
 void slashStarComments(boolean flag)
          Set a boolean indicating whether or not slash star comments should be recognized.
 String toString()
          Answer the state of this tokenizer in a readable format.
 void whitespaceChars(int low, int hi)
          Set the characters ranging from low to hi to be regarded as whitespace characters.
 void wordChars(int low, int hi)
          Set the characters ranging from low to hi to be regarded as word characters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

nval

public double nval
Contains a number if the current token is a number (ttype is TT_NUMBER)


sval

public String sval
Contains a string if the current token is a word (ttype is TT_WORD)


TT_EOF

public static final int TT_EOF
The constant representing end of stream.

See Also:
Constant Field Values

TT_EOL

public static final int TT_EOL
The constant representing end of line.

See Also:
Constant Field Values

TT_NUMBER

public static final int TT_NUMBER
The constant representing a number token.

See Also:
Constant Field Values

TT_WORD

public static final int TT_WORD
The constant representing a word token.

See Also:
Constant Field Values

ttype

public int ttype
The token type

Constructor Detail

StreamTokenizer

@Deprecated
public StreamTokenizer(InputStream is)
Deprecated. Use StreamTokenizer(Reader)

Construct a new StreamTokenizer on the InputStream is. This usage of this method should be replaced with the constructor which takes a Reader.

Parameters:
is - The InputStream to parse tokens on.

StreamTokenizer

public StreamTokenizer(Reader r)
Construct a new StreamTokenizer on the Reader r. Initialize the default state per specification. These are the defaults and are not needed in constructor.

Parameters:
r - The InputStream to parse tokens on.
Method Detail

commentChar

public void commentChar(int ch)
Set the character ch to be regarded as a comment character.

Parameters:
ch - The character to be considered a comment character.

eolIsSignificant

public void eolIsSignificant(boolean flag)
Set a boolean indicating whether or not end of line is significant and should be returned as TT_EOF in ttype.

Parameters:
flag - true if EOL is significant, false otherwise.

lineno

public int lineno()
Answer the current line number.

Returns:
the current line number.

lowerCaseMode

public void lowerCaseMode(boolean flag)
Set a boolean indicating whether or not tokens should be uppercased when present in sval.

Parameters:
flag - true if sval should be forced uppercase, false otherwise.

nextToken

public int nextToken()
              throws IOException
Answer the next token type.

Returns:
The next token to be parsed.
Throws:
IOException - If an IO error occurs while getting the token

ordinaryChar

public void ordinaryChar(int ch)
Set the character ch to be regarded as an ordinary character.

Parameters:
ch - The character to be considered an ordinary comment character.

ordinaryChars

public void ordinaryChars(int low,
                          int hi)
Set the characters ranging from low to hi to be regarded as ordinary characters.

Parameters:
low - The starting range for ordinary characters.
hi - The ending range for ordinary characters.

parseNumbers

public void parseNumbers()
Indicate that numbers should be parsed.


pushBack

public void pushBack()
Indicate that the current token should be pushed back and returned the next time nextToken() is called.


quoteChar

public void quoteChar(int ch)
Set the character ch to be regarded as a quote character.

Parameters:
ch - The character to be considered a quote comment character.

resetSyntax

public void resetSyntax()
Reset all characters so that they are ordinary.


slashSlashComments

public void slashSlashComments(boolean flag)
Set a boolean indicating whether or not slash slash comments should be recognized. The comment ends at a new line.

Parameters:
flag - true if // should be recognized as the start of a comment, false otherwise.

slashStarComments

public void slashStarComments(boolean flag)
Set a boolean indicating whether or not slash star comments should be recognized. Slash-star comments cannot be nested and end when a star-slash combination is found.

Parameters:
flag - true if /* should be recognized as the start of a comment, false otherwise.

toString

public String toString()
Answer the state of this tokenizer in a readable format.

Overrides:
toString in class Object
Returns:
The current state of this tokenizer.

whitespaceChars

public void whitespaceChars(int low,
                            int hi)
Set the characters ranging from low to hi to be regarded as whitespace characters.

Parameters:
low - The starting range for whitespace characters.
hi - The ending range for whitespace characters.

wordChars

public void wordChars(int low,
                      int hi)
Set the characters ranging from low to hi to be regarded as word characters.

Parameters:
low - The starting range for word characters.
hi - The ending range for word characters.

Build 1.0_r1(from source)

Please submit a feedback, bug or feature