public abstract class AbstractStreamTokenizer
extends java.lang.Object
public final String lookahead (int n) throws IOExceptionwhich returns the string of n characters in the input stream including and starting with the current character.
The syntax configuration used as the default setting of the tokenizer is such that:
StreamTokenizer,
LAStreamTokenizer| Modifier and Type | Field and Description |
|---|---|
static byte |
COMMENT |
boolean |
isInteger
This is set to true whenever an integer number has been read.
|
static byte |
NUMERIC |
double |
nval
This contains the token value whenever a number has been read.
|
static byte |
ORDINARY
The following are public constants denoting recognized token
types.
|
static byte |
QUOTE |
static byte |
SPECIAL |
java.lang.String |
sval
This contains the token string when a word, or a quoted word, has been read.
|
static int |
TT_EOF
This value indicates that the end of file has been read.
|
static int |
TT_EOL
This value indicates that an end of line has been read.
|
static int |
TT_NOTHING
This value indicates that no token has been read yet.
|
static int |
TT_NUMBER
This value indicates that a number has been read.
|
static int |
TT_SPECIAL
This value indicates that a special token has been returned.
|
static int |
TT_WORD
This value indicates that a word has been read.
|
int |
ttype
This always contains the type of token just read.
|
static byte |
WHITESPACE |
static byte |
WORD |
| Constructor and Description |
|---|
AbstractStreamTokenizer() |
| Modifier and Type | Method and Description |
|---|---|
abstract void |
commentChar(int c)
Makes the specified character a comment start character exclusively.
|
int |
currentChar()
returns the current character.
|
abstract void |
disableComments() |
abstract void |
enableComments() |
void |
eolIsSignificant(boolean flag)
The end-of-line is recognized as a token iff the argument is true.
|
java.lang.String |
getFile()
Returns the current file if any, or null.
|
int |
getLineNumber()
Returns the current line number.
|
void |
ignoreNonDecimals()
Specifies that octal and hexadecimal numbers should not be parsed.
|
boolean |
isNumericChar(int c)
Checks whether this character's type is numeric, among other types.
|
boolean |
isOrdinaryChar(int c)
Checks whether this character's type is ordinary, among other types.
|
boolean |
isQuoteChar(int c)
Checks whether this character's type is quote, among other types.
|
boolean |
isWhitespaceChar(int c)
Checks whether this character's type is whitespace, among other types.
|
boolean |
isWordChar(int c)
Checks whether this character's type is word, among other types.
|
int |
lineno()
Returns the current line number.
|
java.lang.String |
location() |
abstract int |
nextToken()
Reads a token and returns its type, which is also the value of
ttype.
|
void |
ordinaryChar(int c)
Makes the specified character ordinary exclusively.
|
void |
ordinaryChars(int from,
int to)
Makes all characters between the first and second arguments inclusive
ordinary exclusively.
|
void |
ordinaryChars(java.lang.String chars)
Sets all characters in this string to be ordinary characters, exclusively.
|
void |
parseDigitsOnly()
Sets this tokenizer to parse numbers, but only whole numbers made
out of maximal sequences of numerical digits, considering as
non-numeric characters the '.', '+',
'-', as well as letters (i.e., 'e',
'E', 'f', 'F', 'l',
'L', 'd', or 'D'))
|
void |
parseNonDecimals()
Specifies that octal and hexadecimal numbers should be parsed.
|
void |
parseNonDecimals(boolean flag) |
void |
parseNumbers()
Specifies that numbers should be parsed.
|
void |
parseNumbers(boolean flag) |
boolean |
parsingDigitsOnly() |
int |
peek()
Returns the next character to be read.
|
int |
peekBack()
Returns the previous character that was read.
|
void |
pushBack()
If called, the next call to NextToken() will return the same
token again.
|
void |
quoteChar(int c)
Makes the specified character a quote character exclusively.
|
void |
quoteChar(int c,
int e)
Makes the specified character a quote character exclusively,
and specifies its escape character.
|
void |
quotePair(int left,
int right)
Same as above with implicit default escape character.
|
void |
quotePair(int left,
int right,
int escape)
Defines a pair of characters as a pair of left and right quotes.
|
void |
resetSyntax()
Make all characters ordinary, do not parse numbers, and do not recognize
comments.
|
void |
setDefaultSyntax()
Resets the syntax configuration of the tokenizer to the default setting.
|
void |
setOrdinaryChar(int c)
Sets this character to be an ordinary character, non-exclusively.
|
void |
setOrdinaryChars(java.lang.String chars)
Sets all characters in this string to be ordinary characters, non-exclusively.
|
void |
setQuoteChar(int c)
Same as above with implicit default escape character.
|
void |
setQuoteChar(int c,
int e)
Sets this character to be a quote character, non-exclusively,
and specifies its escape character.
|
void |
setQuotePair(int left,
int right,
int escape)
Same as quotePair but left's QUOTE_TYPE is
non-exclusive.
|
void |
setType(int c,
int type)
Set the type of this character to be the one specified, non-exclusively.
|
void |
setType(int low,
int high,
int type)
Set the type of all characters in this range to be the one specified,
non-exclusively.
|
void |
setType(java.lang.String chars,
int type)
Set the type of all characters in this string to be the one specified,
non-exclusively.
|
void |
setWhitespaceChar(int c)
Sets this character to be a whitespace character, non-exclusively.
|
void |
setWhitespaceChars(java.lang.String chars)
Sets all characters in this string to be whitespace characters, non-exclusively.
|
void |
setWordChar(int c)
Sets this character to be a word character, non-exclusively.
|
void |
setWordChars(java.lang.String chars)
Sets all characters in this string to be word characters, non-exclusively.
|
void |
skipChar()
A public method for skipping the current character
in the input.
|
void |
skipChar(boolean flag)
Same as skipChar(), but if the specified flag is false
(resp., true) resets the start (resp., end) location of the current
token.
|
abstract void |
slashSlashComments(boolean flag)
C++-style comments will be skipped iff the argument is true.
|
abstract void |
slashStarComments(boolean flag)
C-style comments will be skipped iff the argument is true.
|
void |
spaceIsSignificant(boolean flag)
White spaces are recognized as tokens iff the argument is true.
|
Location |
tokenEnd()
Returns the location of the end of the token at hand.
|
Location |
tokenStart()
Returns the location of the start of the token at hand.
|
java.lang.String |
toString()
Returns a printable value of the current state of this
StreamTokenizer.
|
void |
unsetType(int c,
int type)
Unset the specified type, but no other one, for this character.
|
void |
unsetType(int low,
int high,
int type)
Unset the specified type, but no other one, for all characters in this range.
|
void |
unsetType(java.lang.String chars,
int type)
Unset the specified type, but no other one, for all characters in this string.
|
void |
whitespaceChar(int c)
Sets this character to be a whitespace character, exclusively.
|
void |
whitespaceChars(int from,
int to)
Makes all characters between the first and second arguments inclusive
white space characters exclusively.
|
void |
whitespaceChars(java.lang.String chars)
Sets all characters in this string to be whitespace characters, exclusively.
|
void |
wordChar(int c)
Sets this character to be a word character, exclusively.
|
void |
wordChars(int from,
int to)
Makes all characters between the first and second arguments inclusive
word characters exclusively.
|
void |
wordChars(java.lang.String chars)
Sets all characters in this string to be word characters, exclusively.
|
public static final byte ORDINARY
public static final byte WHITESPACE
public static final byte QUOTE
public static final byte WORD
public static final byte NUMERIC
public static final byte COMMENT
public static final byte SPECIAL
public static final int TT_EOF
public static final int TT_EOL
public static final int TT_WORD
public static final int TT_NUMBER
This happens whenever parseNumbers() (or parseNumbers(true)) has been called (default) and parseNumbers(false) has not yet been called. Note that the characters '0' to '9' and the characters '-', '+', and '.' are always considered numeric when parsing numbers is on.
The format of numbers recognized is that of Java, including octal (0...) and hexadecimal (0x... or 0X...) integers, and complete floating point format. Type letter suffixes (i.e., 'l' or 'L' for integers, and 'f', 'F', 'd', 'D' for floating point numbers, are also recognized, but they are ignored since the value returned is always a double.
public static final int TT_NOTHING
public static final int TT_SPECIAL
public int ttype
public java.lang.String sval
public double nval
public boolean isInteger
public abstract void commentChar(int c)
public abstract void slashSlashComments(boolean flag)
public abstract void slashStarComments(boolean flag)
public abstract int nextToken()
throws java.io.IOException
java.io.IOExceptionpublic abstract void enableComments()
public abstract void disableComments()
public Location tokenStart()
public Location tokenEnd()
public final int getLineNumber()
public final int lineno()
public final java.lang.String getFile()
public java.lang.String location()
public final void ordinaryChars(int from,
int to)
public final void wordChars(int from,
int to)
public final void whitespaceChars(int from,
int to)
public final void quoteChar(int c)
public final void quoteChar(int c,
int e)
public final void ordinaryChar(int c)
public final void eolIsSignificant(boolean flag)
public final void spaceIsSignificant(boolean flag)
public final void parseNumbers()
public final void parseNonDecimals()
public final void ignoreNonDecimals()
public final void parseDigitsOnly()
public final boolean parsingDigitsOnly()
public final void parseNumbers(boolean flag)
public final void parseNonDecimals(boolean flag)
public final void pushBack()
public java.lang.String toString()
toString in class java.lang.Objectpublic final void quotePair(int left,
int right,
int escape)
public final void quotePair(int left,
int right)
public final void setQuotePair(int left,
int right,
int escape)
public final void setQuoteChar(int c)
public final void setQuoteChar(int c,
int e)
public final void setOrdinaryChar(int c)
public final void wordChar(int c)
public final void setWordChar(int c)
public final void wordChars(java.lang.String chars)
public final void setWordChars(java.lang.String chars)
public final void whitespaceChar(int c)
public final void setWhitespaceChar(int c)
public final void whitespaceChars(java.lang.String chars)
public final void setWhitespaceChars(java.lang.String chars)
public final void ordinaryChars(java.lang.String chars)
public final void setOrdinaryChars(java.lang.String chars)
public final boolean isOrdinaryChar(int c)
public final boolean isNumericChar(int c)
public final boolean isWordChar(int c)
public final boolean isWhitespaceChar(int c)
public final boolean isQuoteChar(int c)
public final int peek()
public final int peekBack()
public final void skipChar()
throws java.io.IOException
java.io.IOExceptionpublic final void skipChar(boolean flag)
throws java.io.IOException
java.io.IOExceptionpublic final void setType(int c,
int type)
public final void setType(int low,
int high,
int type)
public final void setType(java.lang.String chars,
int type)
public final void unsetType(int c,
int type)
public final void unsetType(int low,
int high,
int type)
public final void unsetType(java.lang.String chars,
int type)
public final int currentChar()
public final void resetSyntax()
public final void setDefaultSyntax()