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.


Variable Index

 o lastChar
 o nval
 o pushed
 o reader
 o sval
 o syntax
 o TT_EOF
 o TT_EOL
 o TT_NUMBER
 o TT_WORD
 o ttype

Constructor Index

 o KQMLStreamTokenizer(Reader)
The constructor for KQMLStreamTokenizer requires a java.io.Reader to supply the incoming character-stream.

Method Index

 o 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.
 o 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.
 o 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.
 o fixedQuoteChar(char)
Specifies that the given character to be a fixed-quote character.
 o getNextToken()
returns the next token from the input-stream.
 o nextToken()
Reads the next token from the incoming stream and returns the type-id of that token.
 o ordinaryChar(char)
Specifies that the given character to be an ordinary character.
 o pushBack()
pushes back the last token into the incoming-stream.
 o quoteChar(char)
Specifies that the given character to be a quote character.
 o resetSyntax()
Clear the internal syntax-table
 o testToken(char)
A convenience-method that reads the next token and compares it with the given character.
 o testToken(String)
A convenience-method that reads the next token and compares it with the given string using .equals().
 o viewToken()
Returns the next token from the input-stream without removing it (aka "lookahead").
 o whitespaceChars(char, char)
Specifies that all characters between low and high are considered whitespace-characters.
 o wordChars(char, char)
Specifies that all characters between low and high are considered word-characters.

Variables

 o reader
 protected Reader reader
 o syntax
 protected int syntax[]
 o pushed
 protected boolean pushed
 o nval
 public int nval
 o ttype
 public int ttype
 o lastChar
 public int lastChar
 o sval
 public String sval
 o TT_WORD
 public static int TT_WORD
 o TT_NUMBER
 public static int TT_NUMBER
 o TT_EOF
 public static int TT_EOF
 o TT_EOL
 public static int TT_EOL

Constructors

 o 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

Methods

 o resetSyntax
 protected void resetSyntax()
Clear the internal syntax-table

 o 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
 o 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
 o 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
 o 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
 o 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
 o pushBack
 public void pushBack()
pushes back the last token into the incoming-stream. The next read- activity will return the same token again.

 o 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.

 o 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
 o 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
 o 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
 o 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.

 o 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
 o 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
 o 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