|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--dfki.util.config.Config
Class to support application and software module configuration.
An instance of the Config
class stores a number
of property settings. A property can be either single valued
(like the java Properties
) or it can have multiple
values (an array of values). Values are always strings.
Settings and default settings are distinguished. They
can be set by using the setProperyValue(...)
methods or by applying ConfigReader
s.
ConfigReaders can read settings from various sources
(probably stored in different representations).
See direct subclasses of ConfigReader
for currently availabe readers.
Additional self made readers can be defined by extending the
abstract ConfigReader
class.
When property values change:
It is possible to subscribe to config changes by adding
a Config.ChangeListener
. Whenever the settings
of the config intstance to which the listener is subscribed to change,
its Config.ChangeListener.hasChanged()
method
is called.
Inner Class Summary | |
static interface |
Config.ChangeListener
Listener interface for publishing change events. |
static class |
Config.Exception
|
static class |
Config.MultiValueException
Exception denoting illegal value/multivalue assignments. |
static class |
Config.Property
Defines a property in a configuration. |
Field Summary | |
static java.lang.String |
ENABLED
|
Method Summary | |
void |
addChangeListener(Config.ChangeListener l)
|
void |
addDefaultSettings(ConfigReader r)
Adds some default settings to the current configuration. |
void |
addSettings(ConfigReader r)
Adds some new settings to the current configuration. |
static Config |
cfg()
|
static Config |
cfg(ConfigReader r)
|
java.lang.Object |
clone()
Creates a copy of the configuration. |
void |
fillInDefaultPropertyValue(Config.Property p,
java.lang.String value)
Set the default value for a property only if no value has been set already. |
void |
fillInDefaultPropertyValue(Config.Property p,
java.lang.String[] values)
Set the default values for a property only if no values have been set already. |
java.lang.String[] |
getDefaultPropertyValues(Config.Property p)
|
java.lang.String |
getPropertyValue(Config.Property p)
Reads the value for a given property. |
java.lang.String |
getPropertyValue(java.lang.String moduleName,
Config.Property p)
Reads the value of a given property local to a particular module. |
java.lang.String |
getPropertyValueInPath(Config.Property p)
Searches for the value of the given property p . |
java.lang.String |
getPropertyValueInPath(java.lang.String moduleName,
Config.Property p)
Uses the same search strategy as getPropertyValueInPath(Config.Property) . |
java.lang.String[] |
getPropertyValues(Config.Property p)
Reads the multivalue of a given property. |
java.lang.String[] |
getPropertyValues(java.lang.String moduleName,
Config.Property p)
|
java.lang.String[] |
getPropertyValuesInPath(Config.Property p)
|
boolean |
hasDefaultValue(Config.Property p)
|
boolean |
hasProperty(Config.Property p)
Tests if any value has been set for a property. |
boolean |
isEnabled(Config.Property p)
Checks whether a property is enabled or not. |
java.lang.String |
printProperty(Config.Property p)
|
void |
printSettings(Config.Property[] props,
java.io.PrintWriter pw)
Prints the settigs for the given properties to PrintWriter w . |
void |
printSettings(Config.Property[] props,
java.io.Writer w)
Prints the settigs for the given properties to Writer w . |
void |
printTo(java.io.OutputStream os)
|
void |
printTo(java.io.PrintWriter pw)
|
void |
printTo(java.io.Writer w)
|
void |
removeChangeListener(Config.ChangeListener l)
|
void |
setDefaultPropertyValue(Config.Property p,
java.lang.String value)
Sets the default value for a property. |
void |
setDefaultPropertyValues(Config.Property p,
java.lang.String[] values)
Sets the default values for a property. |
void |
setPropertyValue(Config.Property p,
java.lang.String value)
Sets the value for a property, overriding the default value (if any). |
void |
setPropertyValues(Config.Property p,
java.lang.String[] values)
Sets the values for a property, overriding the default value (if any). |
java.lang.String |
toString()
|
java.lang.String |
toString(Config.Property[] props)
|
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final java.lang.String ENABLED
Method Detail |
public static Config cfg()
public static Config cfg(ConfigReader r) throws ConfigReader.Exception
public java.lang.Object clone()
public void addChangeListener(Config.ChangeListener l)
public void removeChangeListener(Config.ChangeListener l)
public void addDefaultSettings(ConfigReader r) throws ConfigReader.Exception
public void addSettings(ConfigReader r) throws ConfigReader.Exception
ConfigReader.Exception
- public java.lang.String getPropertyValue(Config.Property p) throws Config.MultiValueException
p
- The given property.public java.lang.String getPropertyValue(java.lang.String moduleName, Config.Property p) throws Config.MultiValueException
Modulename.Property = ...
public java.lang.String getPropertyValueInPath(Config.Property p) throws Config.MultiValueException
p
.
If the property value is not defined this methods searches
the value in the enclosing module(s) (from innermost to the outermost).Module.SubModule.Debug
this
method will search the properties Module.SubModule.Debug
,
Module.Debug
and Module.SubModule.Debug
(in this
order).public java.lang.String getPropertyValueInPath(java.lang.String moduleName, Config.Property p) throws Config.MultiValueException
getPropertyValueInPath(Config.Property)
.
The string moduleName
is used as an prefix.getPropertyValueInPath(Config.Property)
,
getPropertyValue(String,Config.Property)
public java.lang.String[] getPropertyValues(Config.Property p)
public java.lang.String[] getPropertyValues(java.lang.String moduleName, Config.Property p)
public java.lang.String[] getDefaultPropertyValues(Config.Property p)
public java.lang.String[] getPropertyValuesInPath(Config.Property p) throws Config.MultiValueException
public boolean hasProperty(Config.Property p)
true
, if a value for the given
property is available (or a default value).public boolean hasDefaultValue(Config.Property p)
public boolean isEnabled(Config.Property p)
true
, if the given property is enabled.ServletRequestReader
public void setDefaultPropertyValue(Config.Property p, java.lang.String value)
public void setDefaultPropertyValues(Config.Property p, java.lang.String[] values) throws Config.Exception
public void fillInDefaultPropertyValue(Config.Property p, java.lang.String value)
public void fillInDefaultPropertyValue(Config.Property p, java.lang.String[] values) throws Config.Exception
public void setPropertyValue(Config.Property p, java.lang.String value)
public void setPropertyValues(Config.Property p, java.lang.String[] values) throws Config.Exception
public java.lang.String toString()
toString
in class java.lang.Object
public void printTo(java.io.OutputStream os) throws java.io.IOException
public void printTo(java.io.Writer w) throws java.io.IOException
public void printTo(java.io.PrintWriter pw) throws java.io.IOException
public java.lang.String toString(Config.Property[] props)
public void printSettings(Config.Property[] props, java.io.Writer w) throws java.io.IOException
w
.public void printSettings(Config.Property[] props, java.io.PrintWriter pw) throws java.io.IOException
w
.public java.lang.String printProperty(Config.Property p)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |