|
jET |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--prv.doman.util.Tokenizer
The stream tokenizer gets a stream and parses it into tokens.
There are some predefined tokens:
and regular words.
Tokenizer may ignore slash slash comments (like in C++).
This is an example of using this class.
Tokenizer t = new Tokenizer(new FileReader("note.txt")); while (t.hasMoreTokens()) { Token token = t.nextToken(); ... }
This class is not optimized.
Token
Constructor Summary | |
Tokenizer(java.io.Reader in)
Creates tokenizer to tokenize reader input. |
|
Tokenizer(java.lang.String source)
Creates tokenizer to tokenize string. |
Method Summary | |
boolean |
getIgnoreSlashSlash()
Gets slash slash comments ingoration flag. |
int |
getLine()
Returns current line number. |
boolean |
hasMoreTokens()
Returns true , if in the input is at least one
token to read. |
Token |
nextToken()
Gets next token from input and returns it. |
void |
setIgnoreSlashSlash(boolean b)
Sets slash slash comments ignoration. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Tokenizer(java.io.Reader in)
It's much better to wrap input reader with buffering.
in
- Input to tokenize.public Tokenizer(java.lang.String source)
source
- String to tokenize.Method Detail |
public boolean hasMoreTokens() throws java.io.IOException
true
, if in the input is at least one
token to read.
True
, if in the input is at least one
token to read.
java.io.IOException
- When some error occured.public Token nextToken() throws java.io.IOException
java.io.IOException
- When an error occured.public int getLine()
public void setIgnoreSlashSlash(boolean b)
//
and
end at the end of line.
b
- If true
, slash slash comments will be ignored.public boolean getIgnoreSlashSlash()
True
means that tokenizer ignores
slash slash comments.
|
jET |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |