|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.bluemarsh.jswat.AppSettings
Implements a properties storage class. This is used to store a variety of properties, each associated with a key string. Each key string must be unique or otherwise you will overwrite existing properties in the table. The properties can be saved to a file and restored at a later time, allowing persistent data storage.
This class implements the Singleton design pattern to ensure that only one instance of this class exists in the system. To get the single instance you can call the instanceOf() method.
Properties
Field Summary | |
protected java.io.File |
iniFile
Ini file passed to load(). |
protected static AppSettings |
instance
Reference to the singular instance of this class. |
protected java.util.Properties |
table
Table that stores our properties. |
Constructor Summary | |
protected |
AppSettings()
No-arg constructor; sets up the hash table used to store the properites. |
Method Summary | |
void |
commit()
This saves the current settings to the file given in load(). |
boolean |
contains(java.lang.String key)
Tests if the specified key maps to an entry in the table. |
boolean |
getBoolean(java.lang.String key)
Get the value of the given boolean. |
double |
getDouble(java.lang.String key)
Get the value of the given double. |
int |
getInteger(java.lang.String key)
Get the value of the given integer. |
java.lang.String |
getString(java.lang.String key)
Get the value of the given string. |
static AppSettings |
instanceOf()
Returns a reference to the single instance of this class. |
boolean |
load(java.io.File file)
Loads a new set of properties from the given file. |
void |
remove(java.lang.String key)
Removes the key and value from the properties table. |
void |
setBoolean(java.lang.String key,
boolean value)
Set the value of a boolean, given the name of the property and the new boolean value. |
void |
setDouble(java.lang.String key,
double value)
Set the value of a double, given the name of the property and the new double value. |
void |
setInteger(java.lang.String key,
int value)
Set the value of a integer, given the name of the property and the new integer value. |
void |
setString(java.lang.String key,
java.lang.String value)
Set the value of a string, given the name of the property and the new string value. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected java.util.Properties table
protected static AppSettings instance
protected java.io.File iniFile
Constructor Detail |
protected AppSettings()
Method Detail |
public void commit()
java.lang.IllegalStateException
- Thrown if load()
method has not already
been called to set the INI file.public boolean contains(java.lang.String key)
key
- key to look up in the tablepublic boolean getBoolean(java.lang.String key)
key
- name of the boolean property to retrievepublic double getDouble(java.lang.String key)
key
- name of the double property to retrievepublic int getInteger(java.lang.String key)
key
- name of the integer property to retrievepublic java.lang.String getString(java.lang.String key)
key
- name of the string property to retrievepublic static AppSettings instanceOf()
public boolean load(java.io.File file)
file
- file containing propertiespublic void remove(java.lang.String key)
key
- key to remove from tablepublic void setBoolean(java.lang.String key, boolean value)
key
- name of the boolean property to setvalue
- new value for the boolean propertypublic void setDouble(java.lang.String key, double value)
key
- name of the boolean property to setvalue
- new value for the double propertypublic void setInteger(java.lang.String key, int value)
key
- name of the boolean property to setvalue
- new value for the integer propertypublic void setString(java.lang.String key, java.lang.String value)
key
- name of the boolean property to setvalue
- new value for the string property
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |