|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--uk.org.redfelineninja.util.CommandTokenizer
This class provides a simple means to parse strings in command driven situations. This class is almost equivalent to java.io.StreamTokenizer but can be used in command driven situations. java.io.StreamTokenizer can not detect the end of a line until the next line has been presented to it. This is not approptiate in command driven situations. This class can be used as a drop in replacement in a command driven system or as an advanded version of java.util.StringTokenizer.
WARNING: This has not yet acheived its goal as a drop in replacement for StreamTokenizer. It has no decent comment handling.
Field Summary | |
double |
nval
The numeric value of the current token if applicable. |
java.lang.String |
sval
The string value of the current token if applicable. |
static int |
TT_EOF
ttype takes this value if the end of the file has been reached. |
static int |
TT_EOL
ttype takes this value at the end of a line. |
static int |
TT_NUMBER
ttype takes this value if the current token is numeric. |
static int |
TT_UNDEF
ttype takes this value when pushed back and at any other time when its value is not defined. |
static int |
TT_WORD
ttype takes this value if the current token is a single word. |
int |
ttype
The type of the current token. |
Constructor Summary | |
CommandTokenizer(java.io.InputStream is)
Deprecated. The prefered way to create a CommandTokenizer is by supplying it with a Reader. |
|
CommandTokenizer(java.io.Reader r)
Create a new CommandTokenizer that uses the supplied Reader. |
|
CommandTokenizer(java.lang.String c)
Create a new CommandTokenizer that takes its data from the supplied string. |
Method Summary | |
void |
commentChar(int ch)
|
void |
eolIsSignificant(boolean b)
Sets whether or not EOLs will be treated as tokens. |
java.lang.Character |
getCharacter()
Try to get a character from the tokenizer. |
boolean |
getEOF()
Test whether the tokenizer has reached the end of a file. |
boolean |
getEOL()
Test whether the tokenizer has reached the end of a line. |
java.lang.String |
getLine()
Get the whole of the current line for processing in a different way. |
java.lang.Double |
getNumber()
Try to get a number from the tokenizer. |
java.lang.String |
getString()
Try to get a string from the supplied tokenizer. |
char[] |
getStringDelim()
|
java.lang.String |
getText()
Try to get a text token from the tokenizer. |
java.lang.String |
getWord()
Try to get a word from the tokenizer. |
static boolean |
in(int ch,
char[] chars)
Checks a charecter for membership of the supplied array. |
boolean |
isNumeric()
Test if the Token is numeric. |
boolean |
isString()
Test if the token is a quoted string. |
boolean |
isText()
Test if sval is defined for this token. |
boolean |
isWord()
Test if the token is a single word. |
int |
nextToken()
Move the tokenizer to the next token. |
void |
ordinaryChar(int ch)
|
void |
pushBack()
Pushes the current token back so that nextToken will return it again. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public java.lang.String sval
public double nval
public int ttype
public static final int TT_EOF
public static final int TT_NUMBER
public static final int TT_WORD
public static final int TT_EOL
eolIsSignificant(boolean)
,
Constant Field Valuespublic static final int TT_UNDEF
Constructor Detail |
public CommandTokenizer(java.io.InputStream is)
CommandTokenizer#( Reader )
,
Reader
public CommandTokenizer(java.io.Reader r)
public CommandTokenizer(java.lang.String c)
The CommandTokenizer will behave exactly as though the string was received from a Reader. When all tokens in the string have been exhusted the tokenizer will constantly return TT_EOF.
Method Detail |
public void eolIsSignificant(boolean b)
public char[] getStringDelim()
public void commentChar(int ch)
public void ordinaryChar(int ch)
public void pushBack()
public java.lang.String getLine()
public int nextToken() throws java.io.IOException
The tokens are categorized as follows.
java.io.IOException
public static final boolean in(int ch, char[] chars)
public final boolean isNumeric()
public final boolean isWord()
public final boolean isString()
public final boolean isText()
public final java.lang.Double getNumber() throws java.io.IOException
java.io.IOException
public final java.lang.String getText() throws java.io.IOException
java.io.IOException
public final java.lang.String getString() throws java.io.IOException
java.io.IOException
public final java.lang.String getWord() throws java.io.IOException
java.io.IOException
public final java.lang.Character getCharacter() throws java.io.IOException
java.io.IOException
public final boolean getEOL() throws java.io.IOException
java.io.IOException
StreamTokenizer.eolIsSignificant(boolean)
public final boolean getEOF() throws java.io.IOException
java.io.IOException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |