JCommon 1.0.17-redhat-2

org.jfree.base.config
Class HierarchicalConfiguration

java.lang.Object
  extended by org.jfree.base.config.HierarchicalConfiguration
All Implemented Interfaces:
Serializable, Cloneable, ModifiableConfiguration, Configuration, PublicCloneable
Direct Known Subclasses:
PropertyFileConfiguration, SystemPropertyConfiguration

public class HierarchicalConfiguration
extends Object
implements ModifiableConfiguration, PublicCloneable

A hierarchical configuration. Such a configuration can have one or more parent configurations providing usefull default values.

Author:
Thomas Morgner
See Also:
Serialized Form

Constructor Summary
HierarchicalConfiguration()
          Creates a new configuration.
HierarchicalConfiguration(Configuration parentConfiguration)
          Creates a new configuration.
 
Method Summary
 Object clone()
          Returns a clone of this instance.
protected  void configurationLoaded()
          A callback method to reconnect this configuration with the global configuration after deserialization.
 Iterator findPropertyKeys(String prefix)
          Searches all property keys that start with a given prefix.
 Enumeration getConfigProperties()
          Returns all defined configuration properties for the report.
 String getConfigProperty(String key)
          Returns the configuration property with the specified key.
 String getConfigProperty(String key, String defaultValue)
          Returns the configuration property with the specified key (or the specified default value if there is no such property).
protected  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(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.
 void setConfigProperty(String key, String value)
          Sets a configuration property.
protected  void setParentConfig(Configuration config)
          Set the parent configuration.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HierarchicalConfiguration

public HierarchicalConfiguration()
Creates a new configuration.


HierarchicalConfiguration

public HierarchicalConfiguration(Configuration parentConfiguration)
Creates a new configuration.

Parameters:
parentConfiguration - the parent configuration.
Method Detail

getConfigProperty

public String getConfigProperty(String key)
Returns the configuration property with the specified key.

Specified by:
getConfigProperty in interface Configuration
Parameters:
key - the property key.
Returns:
the property value.

getConfigProperty

public String getConfigProperty(String key,
                                String defaultValue)
Returns the configuration property with the specified key (or the specified default value if there is no such property).

If the property is not defined in this configuration, the code will lookup the property in the parent configuration.

Specified by:
getConfigProperty in interface Configuration
Parameters:
key - the property key.
defaultValue - the default value.
Returns:
the property value.

setConfigProperty

public void setConfigProperty(String key,
                              String value)
Sets a configuration property.

Specified by:
setConfigProperty in interface ModifiableConfiguration
Parameters:
key - the property key.
value - the property value.

isLocallyDefined

public boolean isLocallyDefined(String key)
Checks, whether the given key is localy defined in this instance or whether the key's value is inherited.

Parameters:
key - the key that should be checked.
Returns:
true, if the key is defined locally, false otherwise.

getConfiguration

protected Properties getConfiguration()
Returns the collection of properties for the configuration.

Returns:
the properties.

insertConfiguration

public 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.

Parameters:
config - the new report configuration.

setParentConfig

protected void setParentConfig(Configuration config)
Set the parent configuration. The parent configuration is queried, if the requested configuration values was not found in this report configuration.

Parameters:
config - the parent configuration.

getParentConfig

protected Configuration getParentConfig()
Returns the parent configuration. The parent configuration is queried, if the requested configuration values was not found in this report configuration.

Returns:
the parent configuration.

getConfigProperties

public Enumeration getConfigProperties()
Returns all defined configuration properties for the report. The enumeration contains all keys of the changed properties, properties set from files or the system properties are not included.

Specified by:
getConfigProperties in interface ModifiableConfiguration
Specified by:
getConfigProperties in interface Configuration
Returns:
all defined configuration properties for the report.

findPropertyKeys

public Iterator findPropertyKeys(String prefix)
Searches all property keys that start with a given prefix.

Specified by:
findPropertyKeys in interface ModifiableConfiguration
Specified by:
findPropertyKeys in interface Configuration
Parameters:
prefix - the prefix that all selected property keys should share
Returns:
the properties as iterator.

isParentSaved

protected boolean isParentSaved()
Checks, whether the parent configuration can be serialized. Usually the global configuration is not serialized and should return false here.

Returns:
true, if the parent config can be serialized, false otherwise.

configurationLoaded

protected void configurationLoaded()
A callback method to reconnect this configuration with the global configuration after deserialization.


clone

public Object clone()
             throws CloneNotSupportedException
Returns a clone of this instance.

Specified by:
clone in interface Configuration
Specified by:
clone in interface PublicCloneable
Overrides:
clone in class Object
Returns:
A clone.
Throws:
CloneNotSupportedException - if there is a problem cloning.

JCommon 1.0.17-redhat-2

Copyright © 2001-2012 JFree.org. All Rights Reserved.