|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.Dictionary
java.util.Hashtable
common.ParseConfig
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.
| 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 |
static final java.lang.String prefix
| Constructor Detail |
public ParseConfig()
public ParseConfig(java.lang.String aFname)
throws java.io.FileNotFoundException,
java.io.IOException
aFname - Configuration file name
public ParseConfig(java.io.Reader in)
throws java.io.IOException
The configuration file syntax:
name value
or
name = value
assigns a value to the named variable. The equal sign is optional.
There can be a semicolon at the end of the line, but it's optional.
The value may be a number (with no quotes), or a string
surrounded by double quotes. If the string consists only of
alphanumeric characters, with possible '/' and ':' chars, then
quotes are optional too.
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.
in - A Reader (a file reader, etc.)| Method Detail |
public java.lang.String getOption(java.lang.String aName,
java.lang.String aDefault)
public double getOptionDouble(java.lang.String aName,
double aDefault)
public int getOption(java.lang.String aName,
int aDefault)
public boolean getOption(java.lang.String aName,
boolean aDefault)
public java.lang.String getParameter(java.lang.String aName)
throws java.io.IOException
java.io.IOException
public static void main(java.lang.String[] argv)
throws java.io.FileNotFoundException,
java.io.IOException
java.io.FileNotFoundException
java.io.IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||