public class HierarchicalConfiguration extends java.lang.Object implements ModifiableConfiguration, PublicCloneable
Modifier and Type | Field and Description |
---|---|
private java.util.Properties |
configuration
The instance configuration properties.
|
private Configuration |
parentConfiguration
The parent configuration (null if this is the root configuration).
|
Constructor and Description |
---|
HierarchicalConfiguration()
Creates a new configuration.
|
HierarchicalConfiguration(Configuration parentConfiguration)
Creates a new configuration.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
clone()
Returns a clone of this instance.
|
private void |
collectPropertyKeys(java.lang.String prefix,
Configuration config,
java.util.TreeSet collector)
Collects property keys from this and all parent report configurations,
which start with the given prefix.
|
protected void |
configurationLoaded()
A callback method to reconnect this configuration with the global
configuration after deserialization.
|
java.util.Iterator |
findPropertyKeys(java.lang.String prefix)
Searches all property keys that start with a given prefix.
|
java.util.Enumeration |
getConfigProperties()
Returns all defined configuration properties for the report.
|
java.lang.String |
getConfigProperty(java.lang.String key)
Returns the configuration property with the specified key.
|
java.lang.String |
getConfigProperty(java.lang.String key,
java.lang.String defaultValue)
Returns the configuration property with the specified key (or the
specified default value if there is no such property).
|
protected java.util.Properties |
getConfiguration()
Returns the collection of properties for the configuration.
|
protected Configuration |
getParentConfig()
Returns the parent configuration.
|
void |
insertConfiguration(HierarchicalConfiguration config)
The new configuartion will be inserted into the list of report
configuration, so that this configuration has the given report
configuration instance as parent.
|
boolean |
isLocallyDefined(java.lang.String key)
Checks, whether the given key is localy defined in this instance or
whether the key's value is inherited.
|
protected boolean |
isParentSaved()
Checks, whether the parent configuration can be serialized.
|
private boolean |
isRootConfig()
Returns true if this object has no parent.
|
private void |
readObject(java.io.ObjectInputStream in)
Helper method for serialization.
|
void |
setConfigProperty(java.lang.String key,
java.lang.String value)
Sets a configuration property.
|
protected void |
setParentConfig(Configuration config)
Set the parent configuration.
|
private void |
writeObject(java.io.ObjectOutputStream out)
Helper method for serialization.
|
private java.util.Properties configuration
private transient Configuration parentConfiguration
public HierarchicalConfiguration()
public HierarchicalConfiguration(Configuration parentConfiguration)
parentConfiguration
- the parent configuration.public java.lang.String getConfigProperty(java.lang.String key)
getConfigProperty
in interface Configuration
key
- the property key.public java.lang.String getConfigProperty(java.lang.String key, java.lang.String defaultValue)
If the property is not defined in this configuration, the code will lookup the property in the parent configuration.
getConfigProperty
in interface Configuration
key
- the property key.defaultValue
- the default value.public void setConfigProperty(java.lang.String key, java.lang.String value)
setConfigProperty
in interface ModifiableConfiguration
key
- the property key.value
- the property value.private boolean isRootConfig()
public boolean isLocallyDefined(java.lang.String key)
key
- the key that should be checked.protected java.util.Properties getConfiguration()
public void insertConfiguration(HierarchicalConfiguration config)
config
- the new report configuration.protected void setParentConfig(Configuration config)
config
- the parent configuration.protected Configuration getParentConfig()
public java.util.Enumeration getConfigProperties()
getConfigProperties
in interface ModifiableConfiguration
getConfigProperties
in interface Configuration
public java.util.Iterator findPropertyKeys(java.lang.String prefix)
findPropertyKeys
in interface ModifiableConfiguration
findPropertyKeys
in interface Configuration
prefix
- the prefix that all selected property keys should shareprivate void collectPropertyKeys(java.lang.String prefix, Configuration config, java.util.TreeSet collector)
prefix
- the prefix, that selects the property keys.config
- the currently processed report configuration.collector
- the target list, that should receive all valid keys.protected boolean isParentSaved()
protected void configurationLoaded()
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException
out
- the output stream where to write the object.java.io.IOException
- if errors occur while writing the stream.private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException
in
- the input stream from where to read the serialized object.java.io.IOException
- when reading the stream fails.java.lang.ClassNotFoundException
- if a class definition for a serialized
object could not be found.public java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in interface Configuration
clone
in interface PublicCloneable
clone
in class java.lang.Object
java.lang.CloneNotSupportedException
- if there is a problem cloning.