org.mbari.siam.moos.utils.chart.graph
Class ScanWord

java.lang.Object
  extended by java.io.StreamTokenizer
      extended by org.mbari.siam.moos.utils.chart.graph.ScanWord
Direct Known Subclasses:
BuildGraph

public class ScanWord
extends java.io.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:
$Revision: 1.1 $, $Date: 2008/11/04 22:17:55 $
Author:
Leigh Brookshaw

Field Summary
static int ERROR
          Token returned when an error is encountered
static int STRING
          Token returned when a string has been found.
static int UNKNOWN
          Token returned when an unknown characters match nothing
 
Fields inherited from class java.io.StreamTokenizer
nval, sval, TT_EOF, TT_EOL, TT_NUMBER, TT_WORD, ttype
 
Constructor Summary
ScanWord(java.io.InputStream in)
          Instantiate the class with the parsed input stream.
 
Method Summary
 void addKeyWord(java.lang.String s, int i)
          Add a keyword/token pair.
protected  void closeStream()
          Close the input stream
 int getKeyValue(java.lang.String s)
          return the matching token given the keyword
protected  int getNumber(java.lang.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
 int nextWord()
          Read the input stream and return the next token found.
 void resetKeyWords()
          Clear the internal table containing the keyword/token pairs
protected  void resetWordSyntax()
          Reset the syntax of the parent class
 void setStringChar(char c)
          Set the character that delimeters a string.
 
Methods inherited from class java.io.StreamTokenizer
commentChar, eolIsSignificant, lineno, lowerCaseMode, nextToken, ordinaryChar, ordinaryChars, parseNumbers, pushBack, quoteChar, resetSyntax, slashSlashComments, slashStarComments, toString, whitespaceChars, wordChars
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

UNKNOWN

public static final int UNKNOWN
Token returned when an unknown characters match nothing

See Also:
Constant Field Values

ERROR

public static final int ERROR
Token returned when an error is encountered

See Also:
Constant Field Values

STRING

public static final int STRING
Token returned when a string has been found. A string is defined to be text between matching quotes " ".

See Also:
Constant Field Values
Constructor Detail

ScanWord

public ScanWord(java.io.InputStream in)
Instantiate the class with the parsed input stream.

Parameters:
in - Input stream to read from
Method Detail

addKeyWord

public void addKeyWord(java.lang.String s,
                       int i)
Add a keyword/token pair.

Parameters:
s - String contining the keyword
i - Token to return when the keyword is encountered.

getKeyValue

public int getKeyValue(java.lang.String s)
return the matching token given the keyword

Parameters:
s - Keyword.

resetKeyWords

public void resetKeyWords()
Clear the internal table containing the keyword/token pairs


nextWord

public int nextWord()
Read the input stream and return the next token found.


setStringChar

public void setStringChar(char c)
Set the character that delimeters a string.

Parameters:
c - character to delimeter strings. Default is ".

getNumber

protected int getNumber(java.lang.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.

resetWordSyntax

protected void resetWordSyntax()
Reset the syntax of the parent class


closeStream

protected void closeStream()
Close the input stream



Copyright © 2003 MBARI.

The Monterey Bay Aquarium Research Institute (MBARI) provides this documentation and code "as is", with no warranty, express or implied, of its quality or consistency. It is provided without support and without obligation on the part of MBARI to assist in its use, correction, modification, or enhancement.