de.grogra.util
Class Configuration
java.lang.Object
de.grogra.util.Configuration
- All Implemented Interfaces:
- Map, ModifiableMap
public final class Configuration
- extends java.lang.Object
- implements ModifiableMap
A Configuration is a ModifiableMap which uses
Strings as keys and maintains three levels of associations:
- The basic level is represented by default values and is not modified
by methods of this class.
- The next level overrides the basic level, it is defined by
the
override methods.
- The third level overrides the other levels, it is defined by the
put method.
- Author:
- Ole Kniemeyer
| Nested classes/interfaces inherited from interface de.grogra.util.Map |
Map.Chain |
|
Method Summary |
java.lang.Object |
get(java.lang.Object key,
java.lang.Object defaultValue)
Returns the value associated with key. |
void |
override(java.lang.String key,
java.lang.Object value)
Overrides default values of this configuration. |
void |
overrideIfUnset(java.lang.String key,
java.lang.Object value)
Sets a default value if no default value is provided by the
map for default values. |
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value)
Maps key to value. |
void |
writeBack()
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Configuration
public Configuration(KeyDescription[] keys,
Map values)
- Creates a new
Configuration. Its keys are described
by keys, its default values by the map values.
- Parameters:
keys - the keys of this configurationvalues - the default values of this configuration
get
public java.lang.Object get(java.lang.Object key,
java.lang.Object defaultValue)
- Description copied from interface:
Map
- Returns the value associated with
key. If there is
no value associated with key, defaultValue
is returned.
- Specified by:
get in interface Map
- Parameters:
key - a key for the mapdefaultValue - the default value
- Returns:
- the associated value, or
defaultValue
override
public void override(java.lang.String key,
java.lang.Object value)
- Overrides default values of this configuration.
- Parameters:
key - a keyvalue - the new default value for key
overrideIfUnset
public void overrideIfUnset(java.lang.String key,
java.lang.Object value)
- Sets a default value if no default value is provided by the
map for default values.
- Parameters:
key - a keyvalue - the default value for key
put
public java.lang.Object put(java.lang.Object key,
java.lang.Object value)
- Description copied from interface:
ModifiableMap
- Maps
key to value. Following invocations
of the get-method with key as key will
return value.
- Specified by:
put in interface ModifiableMap
- Parameters:
key - a keyvalue - the value to be associated with key
- Returns:
- the previously associated value, or
null
writeBack
public void writeBack()