com.isti.util
Class CfgFileParser

java.lang.Object
  extended by com.isti.util.CfgFileParser
Direct Known Subclasses:
CollectIniParser, ControlIniParser, RuleSetParser, StationInfoParser

public class CfgFileParser
extends java.lang.Object

Class CfgFileParser contains support functions for reading from configuration files.


Field Summary
protected static char CLOSE_BRACKET_CHAR
           
protected  boolean commaSepFlag
           
protected  java.lang.String errorMessage
           
protected  CfgFileTokenizer inTokens
           
protected static char OPEN_BRACKET_CHAR
           
protected  boolean wordSlashFlag
           
 
Constructor Summary
CfgFileParser(java.io.Reader rdr)
          Creates parser object which reads from the given stream.
CfgFileParser(java.io.Reader rdr, boolean wordSlashFlag)
          Creates parser object which reads from the given stream.
CfgFileParser(java.io.Reader rdr, boolean wordSlashFlag, boolean commaSepFlag)
          Creates parser object which reads from the given stream.
 
Method Summary
 java.lang.String getErrorMessage()
          Returns message string for last error (or 'No error' if none).
protected  java.lang.Number parseEqualsNumber()
          Parses "equals" sign ('=') followed by a number.
protected  java.lang.String parseEqualsString()
          Parses "equals" sign ('=') followed by a string.
 void resetInput(java.io.Reader rdr)
          Resets the input stream for this parser.
protected  void setDupFieldMsg(java.lang.String fieldName)
          Builds "Duplicate entry for field" error message with given string.
protected  void setIllegalCharMsg(int charVal)
          Builds "Illegal character" error message with given character value.
protected  void setNoCloseBracketMsg()
          Builds "Close bracket not found" error message.
protected  void setNoOpenBracketMsg()
          Builds "Open bracket not found" error message.
protected  void setUnexpectedEOFMsg()
          Builds "Unexpected end-of-file" error message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OPEN_BRACKET_CHAR

protected static final char OPEN_BRACKET_CHAR
See Also:
Constant Field Values

CLOSE_BRACKET_CHAR

protected static final char CLOSE_BRACKET_CHAR
See Also:
Constant Field Values

wordSlashFlag

protected final boolean wordSlashFlag

commaSepFlag

protected final boolean commaSepFlag

inTokens

protected CfgFileTokenizer inTokens

errorMessage

protected java.lang.String errorMessage
Constructor Detail

CfgFileParser

public CfgFileParser(java.io.Reader rdr,
                     boolean wordSlashFlag,
                     boolean commaSepFlag)
Creates parser object which reads from the given stream. The comma character is parsed as part of a word token.

Parameters:
rdr - reader
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.

CfgFileParser

public CfgFileParser(java.io.Reader rdr,
                     boolean wordSlashFlag)
Creates parser object which reads from the given stream. The comma character is parsed as part of a word token.

Parameters:
rdr - reader
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.

CfgFileParser

public CfgFileParser(java.io.Reader rdr)
Creates parser object which reads from the given stream. The forward-slash character is treated as a separator and the comma character is parsed as part of a word token.

Parameters:
rdr - reader
Method Detail

resetInput

public void resetInput(java.io.Reader rdr)
Resets the input stream for this parser.

Parameters:
rdr - reader input stream object to use.

parseEqualsString

protected java.lang.String parseEqualsString()
                                      throws java.io.IOException
Parses "equals" sign ('=') followed by a string.

Returns:
The string if successful; returns null and builds error message if error.
Throws:
java.io.IOException

parseEqualsNumber

protected java.lang.Number parseEqualsNumber()
                                      throws java.io.IOException
Parses "equals" sign ('=') followed by a number.

Returns:
The number if successful; returns false and builds error message if error.
Throws:
java.io.IOException

setIllegalCharMsg

protected void setIllegalCharMsg(int charVal)
Builds "Illegal character" error message with given character value.

Parameters:
charVal - character value

setUnexpectedEOFMsg

protected void setUnexpectedEOFMsg()
Builds "Unexpected end-of-file" error message.


setNoOpenBracketMsg

protected void setNoOpenBracketMsg()
Builds "Open bracket not found" error message.


setNoCloseBracketMsg

protected void setNoCloseBracketMsg()
Builds "Close bracket not found" error message.


setDupFieldMsg

protected void setDupFieldMsg(java.lang.String fieldName)
Builds "Duplicate entry for field" error message with given string.

Parameters:
fieldName - field name

getErrorMessage

public java.lang.String getErrorMessage()
Returns message string for last error (or 'No error' if none).

Returns:
error message