public class StreamTokenizer extends Object
Modifier and Type | Field and Description |
---|---|
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 and Description |
---|
StreamTokenizer(InputStream is)
Deprecated.
Use StreamTokenizer(Reader)
|
StreamTokenizer(Reader r)
Construct a new StreamTokenizer on the Reader
r . |
Modifier and Type | Method and Description |
---|---|
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. |
public double nval
ttype
is TT_NUMBER
)public String sval
ttype
is TT_WORD
)public static final int TT_EOF
public static final int TT_EOL
public static final int TT_NUMBER
public static final int TT_WORD
public int ttype
public StreamTokenizer(InputStream is)
is
- The InputStream to parse tokens on.public StreamTokenizer(Reader r)
r
.
Initialize the default state per specification.
r
- The InputStream to parse tokens on.public void commentChar(int ch)
ch
to be regarded as a comment
character.ch
- The character to be considered a comment character.public void eolIsSignificant(boolean flag)
TT_EOF
in ttype
.flag
- true
if EOL is significant, false
otherwise.public int lineno()
public void lowerCaseMode(boolean flag)
sval
.flag
- true
if sval
should be forced
uppercase, false
otherwise.public int nextToken() throws IOException
IOException
- If an IO error occurs while getting the tokenpublic void ordinaryChar(int ch)
ch
to be regarded as an ordinary
character.ch
- The character to be considered an ordinary comment character.public void ordinaryChars(int low, int hi)
low
to hi
to be regarded as ordinary characters.low
- The starting range for ordinary characters.hi
- The ending range for ordinary characters.public void parseNumbers()
public void pushBack()
nextToken()
is called.public void quoteChar(int ch)
ch
to be regarded as a quote character.ch
- The character to be considered a quote comment character.public void resetSyntax()
public void slashSlashComments(boolean flag)
flag
- true
if //
should be recognized
as the start of a comment, false
otherwise.public void slashStarComments(boolean flag)
flag
- true
if /*
should be recognized
as the start of a comment, false
otherwise.public String toString()
public void whitespaceChars(int low, int hi)
low
to hi
to be regarded as whitespace characters.low
- The starting range for whitespace characters.hi
- The ending range for whitespace characters.public void wordChars(int low, int hi)
low
to hi
to be regarded as word characters.low
- The starting range for word characters.hi
- The ending range for word characters.