All Packages Class Hierarchy This Package Previous Next Index
Class KQMLLayer.KQMLStreamTokenizer
KQMLLayer.KQMLStreamTokenizer
- public class KQMLStreamTokenizer
KQMLStreamTokenizer is a scanner for KQML-messages. it is
api-compatible with JDK's StreamTokenizer but rewritten to
support multi-line-strings as specified in the KQML-syntax.
-
lastChar
-
-
nval
-
-
pushed
-
-
reader
-
-
sval
-
-
syntax
-
-
TT_EOF
-
-
TT_EOL
-
-
TT_NUMBER
-
-
TT_WORD
-
-
ttype
-
-
KQMLStreamTokenizer(Reader)
- The constructor for KQMLStreamTokenizer requires a java.io.Reader
to supply the incoming character-stream.
-
consume(char)
- A convenience-method that reads the next token, compares it with the
given string using .equals() and throws a ParseException if they
do not match or the token is not a single character.
-
consume(String)
- A convenience-method that reads the next token, compares it with the
given string using .equals() and throws a ParseException if they
do not match.
-
consumeIgnoreCase(String)
- A convenience-method that reads the next token, compares it with the
given string using .equalsIgnoreCase() and throws a ParseException if they
do not match.
-
fixedQuoteChar(char)
- Specifies that the given character to be a fixed-quote character.
-
getNextToken()
- returns the next token from the input-stream.
-
nextToken()
- Reads the next token from the incoming stream and returns the
type-id of that token.
-
ordinaryChar(char)
- Specifies that the given character to be an ordinary character.
-
pushBack()
- pushes back the last token into the incoming-stream.
-
quoteChar(char)
- Specifies that the given character to be a quote character.
-
resetSyntax()
- Clear the internal syntax-table
-
testToken(char)
- A convenience-method that reads the next token and compares it with the
given character.
-
testToken(String)
- A convenience-method that reads the next token and compares it with the
given string using .equals().
-
viewToken()
- Returns the next token from the input-stream without removing it (aka
"lookahead").
-
whitespaceChars(char, char)
- Specifies that all characters between low and high are considered
whitespace-characters.
-
wordChars(char, char)
- Specifies that all characters between low and high are considered
word-characters.
reader
protected Reader reader
syntax
protected int syntax[]
pushed
protected boolean pushed
nval
public int nval
ttype
public int ttype
lastChar
public int lastChar
sval
public String sval
TT_WORD
public static int TT_WORD
TT_NUMBER
public static int TT_NUMBER
TT_EOF
public static int TT_EOF
TT_EOL
public static int TT_EOL
KQMLStreamTokenizer
public KQMLStreamTokenizer(Reader r)
- The constructor for KQMLStreamTokenizer requires a java.io.Reader
to supply the incoming character-stream.
- Parameters:
- r - incoming character-stream
resetSyntax
protected void resetSyntax()
- Clear the internal syntax-table
wordChars
public void wordChars(char low,
char high)
- Specifies that all characters between low and high are considered
word-characters. The specified interval of characters are added to the
set of word-characters, old word-characters remain in place.
- Parameters:
- low - lower bound of the character-interval
- high - upper bound of the character-interval
whitespaceChars
public void whitespaceChars(char low,
char high)
- Specifies that all characters between low and high are considered
whitespace-characters. The specified interval of characters are added to the
set of whitespace-characters, old whitespace-characters remain in place.
Whitespace delimits words, but is not returned as tokens.
- Parameters:
- low - lower bound of the character-interval
- high - upper bound of the character-interval
ordinaryChar
public void ordinaryChar(char c)
- Specifies that the given character to be an ordinary character.
Ordinary characters delimit words and are returned as separate tokens
- Parameters:
- c - new ordinary character
quoteChar
public void quoteChar(char c)
- Specifies that the given character to be a quote character.
Quote characters mark the beginning and end of a string.
Inside a string quote-characters must be escaped by a \
- Parameters:
- c - new quote character
fixedQuoteChar
public void fixedQuoteChar(char c)
- Specifies that the given character to be a fixed-quote character.
Fixed-Quote characters mark the beginning of a fixed string.
After the fixed-quote-character, a number must state the fixed
length of the string. String-delimiters are ignored in fixed strings.
- Parameters:
- c - new fixed-quote character
pushBack
public void pushBack()
- pushes back the last token into the incoming-stream. The next read-
activity will return the same token again.
nextToken
public int nextToken() throws ParseException, IOException
- Reads the next token from the incoming stream and returns the
type-id of that token. Usually getNextToken() is used to directly return
the token instead of only the type. nextToken is a more efficient way
to skip tokens if one is not interested in the token.
consumeIgnoreCase
public void consumeIgnoreCase(String expected) throws IOException, ParseException
- A convenience-method that reads the next token, compares it with the
given string using .equalsIgnoreCase() and throws a ParseException if they
do not match.
- Parameters:
- expected - expected token
consume
public void consume(String expected) throws IOException, ParseException
- A convenience-method that reads the next token, compares it with the
given string using .equals() and throws a ParseException if they
do not match.
- Parameters:
- expected - expected token
consume
public void consume(char expected) throws IOException, ParseException
- A convenience-method that reads the next token, compares it with the
given string using .equals() and throws a ParseException if they
do not match or the token is not a single character.
- Parameters:
- expected - expected token
viewToken
public String viewToken() throws IOException, ParseException
- Returns the next token from the input-stream without removing it (aka
"lookahead"). Thus
multiple calls to viewToken() will always return the same token.
testToken
public boolean testToken(char expected) throws IOException, ParseException
- A convenience-method that reads the next token and compares it with the
given character. It returns true if they match,
false if they don't or if the next token is not a single
character.
- Parameters:
- expected - token to compare to the input
testToken
public boolean testToken(String expected) throws IOException, ParseException
- A convenience-method that reads the next token and compares it with the
given string using .equals(). It returns true if they match,
false otherise.
- Parameters:
- expected - token to compare to the input
getNextToken
public String getNextToken() throws IOException, ParseException
- returns the next token from the input-stream. The token is always
returned as a string.
All Packages Class Hierarchy This Package Previous Next Index