arlut.csd.Util
Class Parser

java.lang.Object
  |
  +--arlut.csd.Util.Parser

public class Parser
extends java.lang.Object

This class provides some extra utility methods to apply to a StreamTokenizer to make parsing the GASH files easier.

The Parser code assumes that the tokenizer has been set up to treat ':', ',', and '\n' as distinct tokens, with everything else treated as word chars.


Field Summary
(package private)  java.io.StreamTokenizer tokens
           
 
Constructor Summary
Parser(java.io.StreamTokenizer tokens)
           
 
Method Summary
 boolean atEOF()
          Returns true if we're at EOF
 boolean atEOL()
          Returns true if we're at EOL
 int checkNextToken()
          This method returns a peek at the next token in the StreamTokenizer that this Parser was initialized with.
 int checkNextToken(java.io.StreamTokenizer tokens)
          This method returns a peek at the next token in the StreamTokenizer passed in.
 boolean EOFnext()
          Returns true if the next thing to be read is EOF
 boolean EOLnext()
          Returns true if the next thing to be read is EOL
 java.lang.String getNextBit()
          getNextBit() returns the next String from the StreamTokenizer that this Parser was initialized with, skipping a single leading ':'s and ','s along the way, up to the next ',' or ':'.
 java.lang.String getNextBit(boolean skipleading)
          getNextBit() returns the next String from the StreamTokenizer that this Parser was initialized with.
 java.lang.String getNextBit(java.io.StreamTokenizer tokens)
          getNextBit() returns the next String from the StreamTokenizer, where the bits are separated by colons and commas.
 java.lang.String getNextBit(java.io.StreamTokenizer tokens, boolean skipleading, boolean includeCommas)
          getNextBit() returns the next String from the StreamTokenizer, where the bits are separated by colons and commas.
 int getNextInt()
          getNextBit() returns the next String from the StreamTokenizer that this Parser was initialized with.
 java.lang.String getNextLongBit()
          getNextLongBit() returns the next String from the StreamTokenizer that this Parser was initialized with, skipping a single leading ':'s along the way, up to the next ':'.
 void setStream(java.io.StreamTokenizer tokens)
          This method connects this Parser object to a different StreamTokenizer.
 void skipToEndLine()
          This method runs tokens to the end of the line.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tokens

java.io.StreamTokenizer tokens
Constructor Detail

Parser

public Parser(java.io.StreamTokenizer tokens)
Method Detail

setStream

public void setStream(java.io.StreamTokenizer tokens)
This method connects this Parser object to a different StreamTokenizer.


atEOL

public boolean atEOL()
Returns true if we're at EOL


atEOF

public boolean atEOF()
Returns true if we're at EOF


EOLnext

public boolean EOLnext()
                throws java.io.IOException
Returns true if the next thing to be read is EOL

java.io.IOException

EOFnext

public boolean EOFnext()
                throws java.io.IOException
Returns true if the next thing to be read is EOF

java.io.IOException

skipToEndLine

public void skipToEndLine()
                   throws java.io.IOException
This method runs tokens to the end of the line.

java.io.IOException

getNextInt

public int getNextInt()
               throws java.io.IOException,
                      java.lang.NumberFormatException
getNextBit() returns the next String from the StreamTokenizer that this Parser was initialized with.

java.io.IOException
java.lang.NumberFormatException

getNextBit

public java.lang.String getNextBit()
                            throws java.io.IOException
getNextBit() returns the next String from the StreamTokenizer that this Parser was initialized with, skipping a single leading ':'s and ','s along the way, up to the next ',' or ':'.

java.io.IOException

getNextLongBit

public java.lang.String getNextLongBit()
                                throws java.io.IOException
getNextLongBit() returns the next String from the StreamTokenizer that this Parser was initialized with, skipping a single leading ':'s along the way, up to the next ':'.

java.io.IOException

getNextBit

public java.lang.String getNextBit(boolean skipleading)
                            throws java.io.IOException
getNextBit() returns the next String from the StreamTokenizer that this Parser was initialized with.

Parameters:
skipleading - if true, getNextBit will chew through leading commas and colons until it gets to either a normal string or eol/eof.
java.io.IOException

getNextBit

public java.lang.String getNextBit(java.io.StreamTokenizer tokens)
                            throws java.io.IOException
getNextBit() returns the next String from the StreamTokenizer, where the bits are separated by colons and commas.

Parameters:
tokens - The StreamTokenizer to read from
java.io.IOException

getNextBit

public java.lang.String getNextBit(java.io.StreamTokenizer tokens,
                                   boolean skipleading,
                                   boolean includeCommas)
                            throws java.io.IOException
getNextBit() returns the next String from the StreamTokenizer, where the bits are separated by colons and commas.

Parameters:
skipleading - if true, getNextBit will chew through leading commas and colons until it gets to either a normal string or eol/eof.
includeCommas - if true, getNextBit will not treat commas as field separators
java.io.IOException

checkNextToken

public int checkNextToken()
                   throws java.io.IOException
This method returns a peek at the next token in the StreamTokenizer that this Parser was initialized with.

java.io.IOException

checkNextToken

public int checkNextToken(java.io.StreamTokenizer tokens)
                   throws java.io.IOException
This method returns a peek at the next token in the StreamTokenizer passed in.

java.io.IOException