common
Class ParseConfig

java.lang.Object
  extended byjava.util.Dictionary
      extended byjava.util.Hashtable
          extended bycommon.ParseConfig
All Implemented Interfaces:
java.lang.Cloneable, java.util.Map, java.io.Serializable

public final class ParseConfig
extends java.util.Hashtable

This class is used to obtain configuration paramters, from a configuration file or from Java System Properties. If this is an applet, SecurityException is caught safely.

See Also:
Serialized Form

Field Summary
(package private) static java.lang.String prefix
           
 
Constructor Summary
ParseConfig()
          Creates an empty hashtable.
ParseConfig(java.io.Reader in)
          Creates a hashtable that contains the parsed data obtained from an open reader (which may, for example, be associated with an open file), and then closes the reader.
ParseConfig(java.lang.String aFname)
          Creates a hashtable that contains the parsed contents of the specified configuration file.
 
Method Summary
 boolean getOption(java.lang.String aName, boolean aDefault)
          Gets the requested integer value from the hash table or from the Java system property aName
 int getOption(java.lang.String aName, int aDefault)
          gets the requested integer value from the hash table or from the Java system property aName
 java.lang.String getOption(java.lang.String aName, java.lang.String aDefault)
          Gets the requested value from the hash table or from the Java system property aName The Java system property, if given, overrides the value from the hash table.
 double getOptionDouble(java.lang.String aName, double aDefault)
          gets the requested double value from the hash table or from the Java system property aName
 java.lang.String getParameter(java.lang.String aName)
          Gets the requested value from the hash table.
static void main(java.lang.String[] argv)
          Purely for testing
 
Methods inherited from class java.util.Hashtable
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, put, putAll, rehash, remove, size, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

prefix

static final java.lang.String prefix
See Also:
Constant Field Values
Constructor Detail

ParseConfig

public ParseConfig()
Creates an empty hashtable. That can be used simply as a convenient interface for accessing Java system options


ParseConfig

public ParseConfig(java.lang.String aFname)
            throws java.io.FileNotFoundException,
                   java.io.IOException
Creates a hashtable that contains the parsed contents of the specified configuration file.

Parameters:
aFname - Configuration file name

ParseConfig

public ParseConfig(java.io.Reader in)
            throws java.io.IOException
Creates a hashtable that contains the parsed data obtained from an open reader (which may, for example, be associated with an open file), and then closes the reader.

The configuration file syntax:

A ParseConfig structure is created by reading a specified configuration file. The values of parameters stored in the table can be accessed by using accessor methods, such as getOption or getOptionDouble.

This method throws various exceptions, so that the caller method could produce a meaningful error report.

Parameters:
in - A Reader (a file reader, etc.)
Method Detail

getOption

public java.lang.String getOption(java.lang.String aName,
                                  java.lang.String aDefault)
Gets the requested value from the hash table or from the Java system property aName The Java system property, if given, overrides the value from the hash table.


getOptionDouble

public double getOptionDouble(java.lang.String aName,
                              double aDefault)
gets the requested double value from the hash table or from the Java system property aName


getOption

public int getOption(java.lang.String aName,
                     int aDefault)
gets the requested integer value from the hash table or from the Java system property aName


getOption

public boolean getOption(java.lang.String aName,
                         boolean aDefault)
Gets the requested integer value from the hash table or from the Java system property aName


getParameter

public java.lang.String getParameter(java.lang.String aName)
                              throws java.io.IOException
Gets the requested value from the hash table. If the value is not found, IOException is thrown.

Throws:
java.io.IOException

main

public static void main(java.lang.String[] argv)
                 throws java.io.FileNotFoundException,
                        java.io.IOException
Purely for testing

Throws:
java.io.FileNotFoundException
java.io.IOException