|
|||||||||
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
,
ConfigFile
,
ChangeEvent
, Serialized FormField Summary | |
protected 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 |
Constructor Summary | |
Config()
Construct a new Config with a default description. |
|
Config(String description)
Construct a new Config object. |
Method Summary | |
void |
addChangeListener(ChangeListener listener)
Add a ChangeListener to this object's list of listeners. |
void |
clear()
Remove all properties. |
boolean |
getBoolean(String key)
Look up an boolean property. |
boolean |
getBoolean(String key,
boolean defaultValue)
Look up a boolean property. |
Color |
getColor(String key)
Look up a Color property. |
Color |
getColor(String key,
Color defaultValue)
Look up a Color property. |
String |
getDescription()
Get the description for this set of configuration parameters. |
int |
getInt(String key)
Look up an integer property. |
int |
getInt(String key,
int defaultValue)
Look up an integer property. |
String |
getString(String key)
Look up a String property. |
String |
getString(String key,
String defaultValue)
Look up a String property. |
Enumeration |
list()
Get a list of properties. |
Object |
put(Object key,
Object value)
Store an arbitrary property. |
boolean |
putBoolean(String key,
boolean value)
Store a boolean property. |
Color |
putColor(String key,
Color value)
Store a Color property. |
int |
putInt(String key,
int value)
Store an integer property. |
String |
putString(String key,
String value)
Store a String property. |
Object |
remove(Object key)
Remove a property. |
void |
removeChangeListener(ChangeListener listener)
Remove a ChangeListener from this object's list of
listeners. |
void |
setDescription(String description)
Set the description for this set of configuration parameters. |
Methods inherited from class java.util.Properties |
getProperty,
getProperty,
list,
list,
load,
propertyNames,
save,
setProperty,
store |
Methods inherited from class java.util.Hashtable |
clone,
contains,
containsKey,
containsValue,
elements,
entrySet,
equals,
get,
hashCode,
isEmpty,
keys,
keySet,
putAll,
rehash,
size,
toString,
values |
Methods inherited from class java.lang.Object |
finalize,
getClass,
notify,
notifyAll,
wait,
wait,
wait |
Field Detail |
protected String description
protected ChangeSupport support
ChangeEvent
s when the object
changes.Constructor Detail |
public Config()
Config
with a default description.public Config(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 String getDescription()
setDescription(java.lang.String)
public void setDescription(String description)
description
- The new description, or null if a default
description should be used.getDescription()
public String getString(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 String getString(String key, 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 String putString(String key, String value)
String
property.key
- The name of the property.value
- The value of the property.getString(java.lang.String)
public int getInt(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(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(String key, int value)
key
- The name of the property.value
- The value of the property.getInt(java.lang.String)
public boolean getBoolean(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(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(String key, boolean value)
key
- The name of the property.value
- The value of the property.getBoolean(java.lang.String)
public Color getColor(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 Color getColor(String key, 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 Color putColor(String key, Color value)
Color
property.key
- The name of the property.value
- The value of the property.getColor(java.lang.String)
public Object put(Object key, Object value)
key
- The object that identifies the property.value
- The value of the property.public Object remove(Object key)
key
- The object that identifies the property.clear()
public void clear()
public Enumeration list()
Enumeration
.public void addChangeListener(ChangeListener listener)
ChangeListener
to this object's list of listeners.listener
- The listener to add.public void removeChangeListener(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 |