|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.util.Dictionary | +--java.util.Hashtable | +--java.util.Properties | +--kiwi.util.Config
Configuration object. This class extends
Properties
, adding convenience methods for storing and
retrieving properties as strings, integers, booleans, and
Color
s. All values are stored internally as strings, so that
persisting the object will produce a human-readable and
-modifiable file.
Whenever the contents of the Config
object change, a
ChangeEvent
is fired.
Properties
,
kiwi.io.ConfigFile
,
ChangeEvent
, Serialized FormInner classes inherited from class java.util.Map |
java.util.Map.Entry |
Field Summary | |
private static java.lang.String |
DEFAULT_DESCRIPTION
|
protected java.lang.String |
description
The description for this set of configuration parameters. |
protected ChangeSupport |
support
The support object for firing ChangeEvent s when the object
changes. |
Fields inherited from class java.util.Properties |
defaults, hexDigit, keyValueSeparators, serialVersionUID, specialSaveChars, strictKeyValueSeparators, whiteSpaceChars |
Fields inherited from class java.util.Hashtable |
count, emptyEnumerator, emptyIterator, ENTRIES, entrySet, KEYS, keySet, loadFactor, modCount, table, threshold, values, VALUES |
Constructor Summary | |
Config()
Construct a new Config with a default description. |
|
Config(java.lang.String description)
Construct a new Config object. |
Method Summary | |
void |
addChangeListener(javax.swing.event.ChangeListener listener)
Add a ChangeListener to this object's list of listeners. |
void |
clear()
Remove all properties. |
boolean |
getBoolean(java.lang.String key)
Look up an boolean property. |
boolean |
getBoolean(java.lang.String key,
boolean defaultValue)
Look up a boolean property. |
java.awt.Color |
getColor(java.lang.String key)
Look up a Color property. |
java.awt.Color |
getColor(java.lang.String key,
java.awt.Color defaultValue)
Look up a Color property. |
java.lang.String |
getDescription()
Get the description for this set of configuration parameters. |
java.awt.Font |
getFont(java.lang.String key)
Look up a Font property. |
java.awt.Font |
getFont(java.lang.String key,
java.awt.Font defaultValue)
Look up a Font property. |
int |
getInt(java.lang.String key)
Look up an integer property. |
int |
getInt(java.lang.String key,
int defaultValue)
Look up an integer property. |
java.lang.String |
getString(java.lang.String key)
Look up a String property. |
java.lang.String |
getString(java.lang.String key,
java.lang.String defaultValue)
Look up a String property. |
java.util.Enumeration |
list()
Get a list of properties. |
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value)
Store an arbitrary property. |
boolean |
putBoolean(java.lang.String key,
boolean value)
Store a boolean property. |
java.awt.Color |
putColor(java.lang.String key,
java.awt.Color value)
Store a Color property. |
java.awt.Font |
putFont(java.lang.String key,
java.awt.Font value)
Store a Font property. |
int |
putInt(java.lang.String key,
int value)
Store an integer property. |
java.lang.String |
putString(java.lang.String key,
java.lang.String value)
Store a String property. |
java.lang.Object |
remove(java.lang.Object key)
Remove a property. |
void |
removeChangeListener(javax.swing.event.ChangeListener listener)
Remove a ChangeListener from this object's list of
listeners. |
void |
setDescription(java.lang.String description)
Set the description for this set of configuration parameters. |
Methods inherited from class java.util.Properties |
|
Methods inherited from class java.util.Hashtable |
clone, contains, containsKey, containsValue, elements, entrySet, equals, get, getEnumeration, getIterator, hashCode, isEmpty, keys, keySet, putAll, readObject, rehash, size, toString, values, writeObject |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, registerNatives, wait, wait, wait |
Field Detail |
private static final java.lang.String DEFAULT_DESCRIPTION
protected java.lang.String description
protected ChangeSupport support
ChangeEvent
s when the object
changes.Constructor Detail |
public Config()
Config
with a default description.public Config(java.lang.String description)
Config
object.description
- The description of the configuration parameters that
will be stored in this object (one line of text).Method Detail |
public java.lang.String getDescription()
setDescription(java.lang.String)
public void setDescription(java.lang.String description)
description
- The new description, or null if a default
description should be used.getDescription()
public java.lang.String getString(java.lang.String key)
String
property.key
- The name of the property.String
, or null if
a property with the specified name does not exist.putString(java.lang.String, java.lang.String)
public java.lang.String getString(java.lang.String key, java.lang.String defaultValue)
String
property.key
- The name of the property.defaultValue
- The default value to return.String
, or
defaultValue
if a property with the specified name does not
exist.putString(java.lang.String, java.lang.String)
public java.lang.String putString(java.lang.String key, java.lang.String value)
String
property.key
- The name of the property.value
- The value of the property.getString(java.lang.String)
public int getInt(java.lang.String key)
key
- The name of the property.int
, or 0 if a
property with the specified name does not exist.putInt(java.lang.String, int)
public int getInt(java.lang.String key, int defaultValue)
key
- The name of the property.defaultValue
- The default value to return.String
, or
defaultValue
if a property with the specified name does not
exist.putInt(java.lang.String, int)
public int putInt(java.lang.String key, int value)
key
- The name of the property.value
- The value of the property.getInt(java.lang.String)
public boolean getBoolean(java.lang.String key)
key
- The name of the property.boolean
. Returns
false if a property with the specified name does not exist.putBoolean(java.lang.String, boolean)
public boolean getBoolean(java.lang.String key, boolean defaultValue)
key
- The name of the property.defaultValue
- The default value to return.defaultValue
if a property with the specified name does not
exist.putBoolean(java.lang.String, boolean)
public boolean putBoolean(java.lang.String key, boolean value)
key
- The name of the property.value
- The value of the property.getBoolean(java.lang.String)
public java.awt.Color getColor(java.lang.String key)
Color
property.key
- The name of the property.Color
. Returns
null if a property with the specified name does not exist, or is
not a properly formatted color specification.putColor(java.lang.String, java.awt.Color)
public java.awt.Color getColor(java.lang.String key, java.awt.Color defaultValue)
Color
property.key
- The name of the property.defaultValue
- The default value to return.Color
, or
defaultValue
if a property with the specified name does not
exist.putColor(java.lang.String, java.awt.Color)
public java.awt.Color putColor(java.lang.String key, java.awt.Color value)
Color
property.key
- The name of the property.value
- The value of the property.getColor(java.lang.String)
public java.awt.Font getFont(java.lang.String key)
Font
property.key
- The name of the property.Font
. Returns
null if a property with the specified name does not exist, or is
not a properly formatted font specification.putFont(java.lang.String, java.awt.Font)
public java.awt.Font getFont(java.lang.String key, java.awt.Font defaultValue)
Font
property.key
- The name of the property.defaultValue
- The default value to return.Font
, or
defaultValue
if a property with the specified name does not
exist.putFont(java.lang.String, java.awt.Font)
public java.awt.Font putFont(java.lang.String key, java.awt.Font value)
Font
property.key
- The name of the property.value
- The value of the property.getFont(java.lang.String)
public java.lang.Object put(java.lang.Object key, java.lang.Object value)
put
in class java.util.Hashtable
key
- The object that identifies the property.value
- The value of the property.public java.lang.Object remove(java.lang.Object key)
remove
in class java.util.Hashtable
key
- The object that identifies the property.clear()
public void clear()
clear
in class java.util.Hashtable
public java.util.Enumeration list()
Enumeration
.public void addChangeListener(javax.swing.event.ChangeListener listener)
ChangeListener
to this object's list of listeners.listener
- The listener to add.public void removeChangeListener(javax.swing.event.ChangeListener listener)
ChangeListener
from this object's list of
listeners.listener
- The listener to remove.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |