|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.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. Also, when a specific property in the
object changes, a PropertyChangeEvent
is fired.
Properties
,
kiwi.io.ConfigFile
,
ChangeEvent
,
PropertyChangeEvent
,
Serialized FormNested Class Summary |
Nested classes inherited from class java.util.Hashtable |
|
Field Summary | |
private static java.lang.String |
DEFAULT_DESCRIPTION
|
protected java.lang.String |
description
The description for this set of configuration parameters. |
protected java.beans.PropertyChangeSupport |
psupport
The support object for firing |
protected ChangeSupport |
support
The support object for firing ChangeEvent s when the object
changes. |
Fields inherited from class java.util.Properties |
defaults |
Fields inherited from class java.util.Hashtable |
|
Constructor Summary | |
Config()
Construct a new Config with a default description. |
|
Config(java.util.Properties properties,
java.lang.String description)
Construct a new Config object from a Properties
list. |
|
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 |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Add a PropertyChangeListener 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 |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Remove a PropertyChangeListener 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 |
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 |
private static final java.lang.String DEFAULT_DESCRIPTION
protected java.lang.String description
protected ChangeSupport support
ChangeEvent
s when the object
changes.
protected java.beans.PropertyChangeSupport psupport
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).public Config(java.util.Properties properties, java.lang.String description)
Config
object from a Properties
list.
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.
null
if
there was no previous value.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.
boolean
, or
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.
false
if
there was no previous value.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.
null
if
there was no previous value.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.
null
if
there was no previous value.getFont(java.lang.String)
public java.lang.Object put(java.lang.Object key, java.lang.Object value)
put
in interface java.util.Map
key
- The object that identifies the property.value
- The value of the property.
null
if
there was no previous value.public java.lang.Object remove(java.lang.Object key)
remove
in interface java.util.Map
key
- The object that identifies the property.
null
if there
was no property with the given key in this object.clear()
public void clear()
clear
in interface java.util.Map
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.public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
PropertyChangeListener
to this object's list of
listeners.
addPropertyChangeListener
in interface PropertyChangeSource
listener
- The listener to add.public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
PropertyChangeListener
from this object's list of
listeners.
removePropertyChangeListener
in interface PropertyChangeSource
listener
- The listener to remove.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |