A specialized configuration class that extends its base class by the
ability of keeping more structure in the stored properties.
There
are some sources of configuration data that cannot be stored very well in a
BaseConfiguration object because then their structure is lost.
This is especially true for XML documents. This class can deal with such
structured configuration sources by storing the properties in a tree-like
organization.
The internal used storage form allows for a more
sophisticated access to single properties. As an example consider the
following XML document:
If this document is parsed and stored in a
HierarchicalConfiguration object (which can be done by one of
the sub classes), there are enhanced possibilities of accessing properties.
The keys for querying information can contain indices that select a certain
element if there are multiple hits.
For instance the key
tables.table(0).name can be used to find out the name of the
first table. In opposite tables.table.name would return a
collection with the names of all available tables. Similarily the key
tables.table(1).fields.field.name returns a collection with
the names of all fields of the second table. If another index is added after
the field element, a single field can be accessed:
tables.table(1).fields.field(0).name.
There is a
getMaxIndex() method that returns the maximum allowed index
that can be added to a given property key. This method can be used to iterate
over all values defined for a certain property.
A specialized configuration class that extends its base class by the ability of keeping more structure in the stored properties.
There are some sources of configuration data that cannot be stored very well in a
BaseConfigurationobject because then their structure is lost. This is especially true for XML documents. This class can deal with such structured configuration sources by storing the properties in a tree-like organization.The internal used storage form allows for a more sophisticated access to single properties. As an example consider the following XML document:
<database> <tables> <table> <name>users</name> <fields> <field> <name>lid</name> <type>long</name> </field> <field> <name>usrName</name> <type>java.lang.String</type> </field> ... </fields> </table> <table> <name>documents</name> <fields> <field> <name>docid</name> <type>long</type> </field> ... </fields> </table> ... </tables> </database>If this document is parsed and stored in a
HierarchicalConfigurationobject (which can be done by one of the sub classes), there are enhanced possibilities of accessing properties. The keys for querying information can contain indices that select a certain element if there are multiple hits.For instance the key
tables.table(0).namecan be used to find out the name of the first table. In oppositetables.table.namewould return a collection with the names of all available tables. Similarily the keytables.table(1).fields.field.namereturns a collection with the names of all fields of the second table. If another index is added after thefieldelement, a single field can be accessed:tables.table(1).fields.field(0).name.There is a
getMaxIndex()method that returns the maximum allowed index that can be added to a given property key. This method can be used to iterate over all values defined for a certain property.