The main Configuration interface.
This interface allows accessing and manipulating a configuration object. The major part of the methods defined in this interface deals with accessing properties of various data types. There is a generic getProperty()
method, which returns the value of the queried property in its raw data type. Other getter methods try to convert this raw data type into a specific data type. If this fails, a ConversionException
will be thrown.
For most of the property getter methods an overloaded version exists that allows to specify a default value, which will be returned if the queried property cannot be found in the configuration. The behavior of the methods that do not take a default value in case of a missing property is not defined by this interface and depends on a concrete implementation. E.g. the {@link AbstractConfiguration}
class, which is the base class of most configuration implementations provided by this package, per default returns null if a property is not found, but provides the {@link org.apache.commons.configuration.AbstractConfiguration#setThrowExceptionOnMissing(boolean) setThrowExceptionOnMissing()}
method, with which it can be configured to throw a NoSuchElementException
exception in that case. (Note that getter methods for primitive types in AbstractConfiguration
always throw an exception for missing properties because there is no way of overloading the return value.)
With the addProperty()
and setProperty()
methods new properties can be added to a configuration or the values of properties can be changed. With clearProperty()
a property can be removed. Other methods allow to iterate over the contained properties or to create a subset configuration.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|