Class graph.ScanWord
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class graph.ScanWord

java.lang.Object
   |
   +----java.io.StreamTokenizer
           |
           +----graph.ScanWord

public class ScanWord
extends StreamTokenizer
This class extends the StreamTokenizer class. It allows words to be defined and recognised and returned as a token. The TT_NUMBER token of the StreamTokenizer is also modified so that scientific notation is recognised.
Version:
1.5, 1996/07/24 00:19:41
Author:
Leigh Brookshaw

Variable Index

 o ERROR
Token returned when an error is encountered
 o STRING
Token returned when a string has been found.
 o UNKNOWN
Token returned when an unknown characters match nothing

Constructor Index

 o ScanWord(InputStream)
Instantiate the class with the parsed input stream.

Method Index

 o addKeyWord(String, int)
Add a keyword/token pair.
 o closeStream()
Close the input stream
 o getKeyValue(String)
return the matching token given the keyword
 o getNumber(String)
Check to see if the returned word is a number The native StreamTokenizer number method does not work for scientific notation so we us the Double class doubleValue() method
 o nextWord()
Read the input stream and return the next token found.
 o resetKeyWords()
Clear the internal table containing the keyword/token pairs
 o resetWordSyntax()
Reset the syntax of the parent class
 o setStringChar(char)
Set the character that delimeters a string.

Variables

 o UNKNOWN
  public final static int UNKNOWN
Token returned when an unknown characters match nothing
 o ERROR
  public final static int ERROR
Token returned when an error is encountered
 o STRING
  public final static int STRING
Token returned when a string has been found. A string is defined to be text between matching quotes " ".

Constructors

 o ScanWord
  public ScanWord(InputStream in)
Instantiate the class with the parsed input stream.
Parameters:
in - Input stream to read from

Methods

 o addKeyWord
  public void addKeyWord(String s,
                         int i)
Add a keyword/token pair.
Parameters:
s - String contining the keyword
i - Token to return when the keyword is encountered.
 o getKeyValue
  public int getKeyValue(String s)
return the matching token given the keyword
Parameters:
s - Keyword.
 o resetKeyWords
  public void resetKeyWords()
Clear the internal table containing the keyword/token pairs
 o nextWord
  public int nextWord()
Read the input stream and return the next token found.
 o setStringChar
  public void setStringChar(char c)
Set the character that delimeters a string.
Parameters:
c - character to delimeter strings. Default is ".
 o getNumber
  protected int getNumber(String s)
Check to see if the returned word is a number The native StreamTokenizer number method does not work for scientific notation so we us the Double class doubleValue() method
Parameters:
s - String to find number.
 o resetWordSyntax
  protected void resetWordSyntax()
Reset the syntax of the parent class
 o closeStream
  protected void closeStream()
Close the input stream

All Packages  Class Hierarchy  This Package  Previous  Next  Index