abstract class HierarchicalConfigurationConverter
extends java.lang.Object
A base class for converters that transform a normal configuration object into a hierarchical configuration.
This class provides a default mechanism for iterating over the keys in a configuration and to throw corresponding element start and end events. By handling these events a hierarchy can be constructed that is equivalent to the keys in the original configuration.
Concrete sub classes will implement event handlers that generate SAX
events for XML processing or construct a
HierarchicalConfiguration
root node. All in all with this class
it is possible to treat a default configuration as if it was a hierarchical
configuration, which can be sometimes useful.
HierarchicalConfiguration
Constructor and Description |
---|
HierarchicalConfigurationConverter() |
Modifier and Type | Method and Description |
---|---|
protected void |
closeElements(ConfigurationKey keyLast,
ConfigurationKey keyAct)
Fires all necessary element end events for the specified keys.
|
protected abstract void |
elementEnd(java.lang.String name)
An event handler method that is called when an element ends.
|
protected abstract void |
elementStart(java.lang.String name,
java.lang.Object value)
An event handler method that is called when an element starts.
|
protected void |
fireValue(java.lang.String name,
java.lang.Object value)
Fires all necessary element start events with the actual element values.
|
protected java.lang.String |
openElements(ConfigurationKey keyLast,
ConfigurationKey keyAct,
Configuration config,
java.util.Set keySet)
Fires all necessary element start events for the specified key.
|
void |
process(Configuration config)
Processes the specified configuration object.
|
protected java.util.Iterator |
reverseIterator(ConfigurationKey key)
Helper method for determining a reverse iterator for the specified key.
|
public void process(Configuration config)
elementStart()
and
elementEnd()
methods.config
- the configuration to be processedprotected abstract void elementStart(java.lang.String name, java.lang.Object value)
name
- the name of the new elementvalue
- the element's value; can be null if the element
does not have any valueprotected abstract void elementEnd(java.lang.String name)
elementStart()
there will be a corresponding call
of this method. Concrete sub classes must implement it to perform a
proper event handling.name
- the name of the ending elementprotected void closeElements(ConfigurationKey keyLast, ConfigurationKey keyAct)
keyLast
- the last processed keykeyAct
- the actual keyprotected java.util.Iterator reverseIterator(ConfigurationKey key)
key
- the keyprotected java.lang.String openElements(ConfigurationKey keyLast, ConfigurationKey keyAct, Configuration config, java.util.Set keySet)
keyLast
- the last processed keykeyAct
- the actual keyconfig
- the configuration to processkeySet
- the set with the processed keysprotected void fireValue(java.lang.String name, java.lang.Object value)
name
- the name of the actual elementvalue
- the element's value