opale.mathtools
Class ScanString

java.lang.Object
  |
  +--opale.mathtools.ScanString
Direct Known Subclasses:
ParseFunction

public class ScanString
extends java.lang.Object

This class is similar to the ScanWord class, except it scans a string for keywords rather than an input stream.


Field Summary
static int EOS
          flag the End of String
static int ERROR
          Flag an error
static int NUMBER
          Flag a Number
 double nval
           
 java.lang.String sval
           
static int UNKNOWN
          flag an unknown token
 
Constructor Summary
ScanString()
          Instantiate the Class
ScanString(java.lang.String s)
          Instantaite the Class
 
Method Summary
 void addKeyWord(java.lang.String s, int i)
          Add a keyword/token pair to the table of keywords to scan for.
 int getKeyValue(java.lang.String s)
           
 int nextWord()
          Process the string and return the next token found.
 void resetKeyWords()
          Clear the table containing the keyword/token pairs
 void setString(java.lang.String s)
          Set the string to be scanned
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNKNOWN

public static final int UNKNOWN
flag an unknown token

ERROR

public static final int ERROR
Flag an error

NUMBER

public static final int NUMBER
Flag a Number

EOS

public static final int EOS
flag the End of String

sval

public java.lang.String sval

nval

public double nval
Constructor Detail

ScanString

public ScanString()
Instantiate the Class

ScanString

public ScanString(java.lang.String s)
Instantaite the Class
Parameters:
s - String to scan for tokens
Method Detail

setString

public void setString(java.lang.String s)
Set the string to be scanned
Parameters:
s - String

addKeyWord

public void addKeyWord(java.lang.String s,
                       int i)
Add a keyword/token pair to the table of keywords to scan for.
Parameters:
s - keyword string to scan for
i - token to return when the keyword is found

getKeyValue

public int getKeyValue(java.lang.String s)
Parameters:
s - keyword string
Returns:
the token corresponding to the keyword

resetKeyWords

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

nextWord

public int nextWord()
Process the string and return the next token found.
Returns:
token found