edu.cmu.sphinx.util
Class ExtendedStreamTokenizer

java.lang.Object
  extended byedu.cmu.sphinx.util.ExtendedStreamTokenizer

public class ExtendedStreamTokenizer
extends java.lang.Object

A class that provides a mechanism for tokenizing a stream


Constructor Summary
ExtendedStreamTokenizer(java.io.InputStream inputStream, boolean eolIsSignificant)
          Constructs an ExtendedStreamTokenizer from the given InputStream.
ExtendedStreamTokenizer(java.io.InputStream inputStream, int commentChar, boolean eolIsSignificant)
          Constructs an ExtendedStreamTokenizer from the given InputStream
ExtendedStreamTokenizer(java.io.Reader reader, boolean eolIsSignificant)
          Constructs an ExtendedStreamTokenizer from the given Reader.
ExtendedStreamTokenizer(java.lang.String path)
          Creates and returns a stream tokenizer that has been properly configured to parse sphinx3 data This ExtendedStreamTokenizer has no comment characters.
ExtendedStreamTokenizer(java.lang.String path, boolean eolIsSignificant)
          Creates and returns a stream tokenizer that has been properly configured to parse sphinx3 data This ExtendedStreamTokenizer has no comment characters.
 
Method Summary
 void close()
          Closes the tokenizer
 void commentChar(int ch)
          Specified that the character argument starts a single-line comment.
 void expectInt(java.lang.String name, int expecting)
          Loads an integer from the tokenizer and ensures that it matches 'expecting'
 void expectString(java.lang.String expecting)
          Loads a word from the tokenizer and ensures that it matches 'expecting'
 double getDouble(java.lang.String name)
          gets a double from the tokenizer stream
 float getFloat(java.lang.String name)
          gets a float from the tokenizer stream
 float getFloat(java.lang.String name, float defaultValue)
          gets a optional float from the tokenizer stream.
 int getInt(java.lang.String name)
          gets an integer from the tokenizer stream
 int getLineNumber()
          Gets the current line number
 java.lang.String getString()
          Gets the next word from the tokenizer
 boolean isEOF()
          Determines if the stream is at the end of file
 void skipwhite()
          Skip any carriage returns.
 void unget(java.lang.String string)
          Puts a string back, the next get will return this string
 void whitespaceChars(int low, int hi)
          Specifies that all the characters between low and hi incluseive are whitespace characters
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExtendedStreamTokenizer

public ExtendedStreamTokenizer(java.lang.String path)
                        throws java.io.FileNotFoundException
Creates and returns a stream tokenizer that has been properly configured to parse sphinx3 data This ExtendedStreamTokenizer has no comment characters.

Parameters:
path - the source of the data
Throws:
java.io.FileNotFoundException - if a file cannot be found

ExtendedStreamTokenizer

public ExtendedStreamTokenizer(java.lang.String path,
                               boolean eolIsSignificant)
                        throws java.io.FileNotFoundException
Creates and returns a stream tokenizer that has been properly configured to parse sphinx3 data This ExtendedStreamTokenizer has no comment characters.

Parameters:
path - the source of the data
eolIsSignificant - if true eol is significant
Throws:
java.io.FileNotFoundException - if a file cannot be found

ExtendedStreamTokenizer

public ExtendedStreamTokenizer(java.io.InputStream inputStream,
                               int commentChar,
                               boolean eolIsSignificant)
Constructs an ExtendedStreamTokenizer from the given InputStream

Parameters:
inputStream - the source of the data
commentChar - the comment character
eolIsSignificant - true if EOL is significant, false otherwise

ExtendedStreamTokenizer

public ExtendedStreamTokenizer(java.io.InputStream inputStream,
                               boolean eolIsSignificant)
Constructs an ExtendedStreamTokenizer from the given InputStream. This ExtendedStreamTokenizer has no comment characters.

Parameters:
inputStream - the source of the data
eolIsSignificant - true if EOL is significant, false otherwise

ExtendedStreamTokenizer

public ExtendedStreamTokenizer(java.io.Reader reader,
                               boolean eolIsSignificant)
Constructs an ExtendedStreamTokenizer from the given Reader. This ExtendedStreamTokenizer has no comment characters.

Parameters:
reader - the source of the data
eolIsSignificant - true if eol is significant
Method Detail

close

public void close()
           throws java.io.IOException
Closes the tokenizer

Throws:
java.io.IOException - if an error occurs while closing the stream

whitespaceChars

public void whitespaceChars(int low,
                            int hi)
Specifies that all the characters between low and hi incluseive are whitespace characters

Parameters:
low - the low end of the range
hi - the high end of the range

commentChar

public void commentChar(int ch)
Specified that the character argument starts a single-line comment. All characters from the comment character to the end of the line are ignored by this stream tokenizer.

Parameters:
ch - the comment character

getString

public java.lang.String getString()
                           throws java.io.StreamCorruptedException,
                                  java.io.IOException
Gets the next word from the tokenizer

Returns:
the next word
Throws:
java.io.StreamCorruptedException - if the word does not match
java.io.IOException - if an error occurs while loading the data

unget

public void unget(java.lang.String string)
Puts a string back, the next get will return this string

Parameters:
string - the string to unget

isEOF

public boolean isEOF()
Determines if the stream is at the end of file

Returns:
true if the stream is at EOF

getLineNumber

public int getLineNumber()
Gets the current line number

Returns:
the line number

expectString

public void expectString(java.lang.String expecting)
                  throws java.io.StreamCorruptedException,
                         java.io.IOException
Loads a word from the tokenizer and ensures that it matches 'expecting'

Parameters:
expecting - the word read must match this
Throws:
java.io.StreamCorruptedException - if the word does not match
java.io.IOException - if an error occurs while loading the data

expectInt

public void expectInt(java.lang.String name,
                      int expecting)
               throws java.io.StreamCorruptedException,
                      java.io.IOException
Loads an integer from the tokenizer and ensures that it matches 'expecting'

Parameters:
name - the name of the value
expecting - the word read must match this
Throws:
java.io.StreamCorruptedException - if the word does not match
java.io.IOException - if an error occurs while loading the data

getInt

public int getInt(java.lang.String name)
           throws java.io.StreamCorruptedException,
                  java.io.IOException
gets an integer from the tokenizer stream

Parameters:
name - the name of the parameter (for error reporting)
Returns:
the next word in the stream as an integer
Throws:
java.io.StreamCorruptedException - if the next value is not a
java.io.IOException - if an error occurs while loading the data number

getDouble

public double getDouble(java.lang.String name)
                 throws java.io.StreamCorruptedException,
                        java.io.IOException
gets a double from the tokenizer stream

Parameters:
name - the name of the parameter (for error reporting)
Returns:
the next word in the stream as a double
Throws:
java.io.StreamCorruptedException - if the next value is not a
java.io.IOException - if an error occurs while loading the data number

getFloat

public float getFloat(java.lang.String name)
               throws java.io.StreamCorruptedException,
                      java.io.IOException
gets a float from the tokenizer stream

Parameters:
name - the name of the parameter (for error reporting)
Returns:
the next word in the stream as a float
Throws:
java.io.StreamCorruptedException - if the next value is not a
java.io.IOException - if an error occurs while loading the data number

getFloat

public float getFloat(java.lang.String name,
                      float defaultValue)
               throws java.io.StreamCorruptedException,
                      java.io.IOException
gets a optional float from the tokenizer stream. If a float is not present, the default is returned

Parameters:
name - the name of the parameter (for error reporting)
defaultValue - the default value
Returns:
the next word in the stream as a float
Throws:
java.io.StreamCorruptedException - if the next value is not a
java.io.IOException - if an error occurs while loading the data number

skipwhite

public void skipwhite()
               throws java.io.IOException
Skip any carriage returns.

Throws:
java.io.IOException - if an error occurs while reading data from the stream.