com.isti.util
Class CfgFileTokenizer

java.lang.Object
  extended bycom.isti.util.CfgFileTokenizer

public class CfgFileTokenizer
extends java.lang.Object

Class CfgFileTokenizer extends StreamTokenizer and sets up for configuration file parsing.


Field Summary
static int TT_EOF
          A constant indicating that the end of the stream has been read.
static int TT_EOL
          A constant indicating that the end of the line has been read.
static int TT_NUMBER
          A constant indicating that a number token has been read.
static int TT_WORD
          A constant indicating that a word token has been read.
 
Constructor Summary
CfgFileTokenizer(java.io.Reader rdr)
          Creates an object which reads from the given input stream.
CfgFileTokenizer(java.io.Reader rdr, boolean wordSlashFlag)
          Creates an object which reads from the given input stream.
CfgFileTokenizer(java.io.Reader rdr, boolean wordSlashFlag, boolean commaSepFlag)
          Creates an object which reads from the given input stream.
 
Method Summary
 void dumpTokens(java.io.PrintStream out)
          Sends display of tokens to the given print stream.
 java.lang.String getNonNullTokenString()
          Returns the token string fetched by 'nextToken()'.
 java.lang.Number getNumberToken()
          Returns the token fetched by 'nextToken()' as a numeric object.
 java.lang.String getTokenString()
          Returns the token string fetched by 'nextToken()'.
 int lineno()
          Returns the current line number.
 int nextToken()
          Parses the next token from the input stream.
 int nextToken(boolean eolFlag)
          Parses the next token from the input stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TT_EOF

public static final int TT_EOF
A constant indicating that the end of the stream has been read.

See Also:
Constant Field Values

TT_EOL

public static final int TT_EOL
A constant indicating that the end of the line has been read.

See Also:
Constant Field Values

TT_NUMBER

public static final int TT_NUMBER
A constant indicating that a number token has been read.

See Also:
Constant Field Values

TT_WORD

public static final int TT_WORD
A constant indicating that a word token has been read.

See Also:
Constant Field Values
Constructor Detail

CfgFileTokenizer

public CfgFileTokenizer(java.io.Reader rdr,
                        boolean wordSlashFlag,
                        boolean commaSepFlag)
Creates an object which reads from the given input stream.

Parameters:
rdr - the input stream to read from.
wordSlashFlag - true to allow the forward-slash character to be parsed as part of a word token (this disables '//' comments); false to make the forward-slash character be a token separator.
commaSepFlag - true for comma to be a token separator; false for comma to be parsed as part of a word token.

CfgFileTokenizer

public CfgFileTokenizer(java.io.Reader rdr,
                        boolean wordSlashFlag)
Creates an object which reads from the given input stream. Commas are parsed as part of a word token.

Parameters:
rdr - the input stream to read from.
wordSlashFlag - true to allow the forward-slash character to be parsed as part of a word token (this disables '//' comments); false to make the forward-slash character be a token separator.

CfgFileTokenizer

public CfgFileTokenizer(java.io.Reader rdr)
Creates an object which reads from the given input stream. The forward-slash character is parsed as a token separator (and '//' comments are enabled) and commas are parsed as part of a word token.

Parameters:
rdr - the input stream to read from.
Method Detail

nextToken

public int nextToken(boolean eolFlag)
              throws java.io.IOException
Parses the next token from the input stream.

Parameters:
eolFlag - if true then all tokens and words until the next end-of-line are read in and returned as a single token string.
Returns:
'StreamTokenizer.TT_WORD' if a word or a quoted string token was found (retrieve token with 'getTokenString()'); 'StreamTokenizer.TT_NUMBER' if a numeric value was parsed (retrieve token with 'getTokenString()'); or 'StreamTokenizer.TT_EOF' if the end of the input stream was reached.
Throws:
java.io.IOException - if an I/O error occurs.

nextToken

public int nextToken()
              throws java.io.IOException
Parses the next token from the input stream.

Returns:
'StreamTokenizer.TT_WORD' if a word or a quoted string token was found (retrieve token with 'getTokenString()') or 'StreamTokenizer.TT_EOF' if the end of the input stream was reached.
Throws:
java.io.IOException - if an I/O error occurs.

getTokenString

public java.lang.String getTokenString()
Returns the token string fetched by 'nextToken()'.

Returns:
the token string, or null if none available.

getNonNullTokenString

public java.lang.String getNonNullTokenString()
Returns the token string fetched by 'nextToken()'.

Returns:
the token string, or an empty string if none available.

getNumberToken

public java.lang.Number getNumberToken()
Returns the token fetched by 'nextToken()' as a numeric object.

Returns:
One of the Number-extended class objects 'Integer', 'Double' or 'params.Boolean.Cp'; or null if the token could not be converted.

lineno

public int lineno()
Returns the current line number.

Returns:
the current line number.

dumpTokens

public void dumpTokens(java.io.PrintStream out)
                throws java.io.IOException
Sends display of tokens to the given print stream.

Parameters:
out - output stream
Throws:
java.io.IOException - if an I/O error occurs.