|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.configuration.event.EventSource
org.apache.commons.configuration.AbstractConfiguration
public abstract class AbstractConfiguration
Abstract configuration class. Provides basic functionality but does not store any data.
If you want to write your own Configuration class then you should
implement only abstract methods from this class. A lot of functionality
needed by typical implementations of the Configuration
interface is already provided by this base class. Following is a list of
feauters implemented here:
Data conversion support. The various data types required by the
Configuration
interface are already handled by this base class.
A concrete sub class only needs to provide a generic getProperty()
method.
- Support for variable interpolation. Property values containing special
variable tokens (like
${var}
) will be replaced by their
corresponding values.
- Support for string lists. The values of properties to be added to this
configuration are checked whether they contain a list delimiter character. If
this is the case and if list splitting is enabled, the string is splitted and
multiple values are added for this property. (With the
setListDelimiter()
method the delimiter character can be
specified; per default a comma is used. The
setDelimiterParsingDisabled()
method can be used to disable
list splitting completely.)
- Allows to specify how missing properties are treated. Per default the
get methods returning an object will return null if the searched
property key is not found (and no default value is provided). With the
setThrowExceptionOnMissing()
method this behavior can be
changed to throw an exception when a requested property cannot be found.
- Basic event support. Whenever this configuration is modified registered
event listeners are notified. Refer to the various
EVENT_XXX
constants to get an impression about which event types are supported.
- Version:
- $Id: AbstractConfiguration.java,v 1.29 2004/12/02 22:05:52 ebourg
Exp $
- Author:
- Konstantin Shaposhnikov , Oliver Heger , Henning P. Schmiedehausen
Field Summary
protected static String
END_TOKEN
end token
static int
EVENT_ADD_PROPERTY
Constant for the add property event type.
static int
EVENT_CLEAR
Constant for the clear configuration event type.
static int
EVENT_CLEAR_PROPERTY
Constant for the clear property event type.
static int
EVENT_READ_PROPERTY
Constant for the get property event type.
static int
EVENT_SET_PROPERTY
Constant for the set property event type.
protected static String
START_TOKEN
start token
Constructor Summary
AbstractConfiguration()
Creates a new instance of AbstractConfiguration
.
Method Summary
void
addErrorLogListener()
Adds a special
ConfigurationErrorListener
object to this configuration that will log all internal errors.
void
addProperty(String key,
Object value)
Add a property to the configuration.
protected abstract void
addPropertyDirect(String key,
Object value)
Adds a key/value pair to the Configuration.
void
clear()
Remove all properties from the configuration.
void
clearProperty(String key)
Removes the specified property from this configuration.
protected void
clearPropertyDirect(String key)
Removes the specified property from this configuration.
abstract boolean
containsKey(String key)
Check if the configuration contains the specified key.
protected ConfigurationInterpolator
createInterpolator()
Creates the interpolator object that is responsible for variable
interpolation.
BigDecimal
getBigDecimal(String key)
Get a BigDecimal
associated with the given configuration key.
BigDecimal
getBigDecimal(String key,
BigDecimal defaultValue)
Get a BigDecimal
associated with the given configuration key.
BigInteger
getBigInteger(String key)
Get a BigInteger
associated with the given configuration key.
BigInteger
getBigInteger(String key,
BigInteger defaultValue)
Get a BigInteger
associated with the given configuration key.
boolean
getBoolean(String key)
Get a boolean associated with the given configuration key.
boolean
getBoolean(String key,
boolean defaultValue)
Get a boolean associated with the given configuration key.
Boolean
getBoolean(String key,
Boolean defaultValue)
Obtains the value of the specified key and tries to convert it into a
Boolean
object.
byte
getByte(String key)
Get a byte associated with the given configuration key.
byte
getByte(String key,
byte defaultValue)
Get a byte associated with the given configuration key.
Byte
getByte(String key,
Byte defaultValue)
Get a Byte
associated with the given configuration key.
static char
getDefaultListDelimiter()
Retrieve the current delimiter.
static char
getDelimiter()
Deprecated. Use AbstractConfiguration.getDefaultListDelimiter() instead
double
getDouble(String key)
Get a double associated with the given configuration key.
double
getDouble(String key,
double defaultValue)
Get a double associated with the given configuration key.
Double
getDouble(String key,
Double defaultValue)
Get a Double
associated with the given configuration key.
float
getFloat(String key)
Get a float associated with the given configuration key.
float
getFloat(String key,
float defaultValue)
Get a float associated with the given configuration key.
Float
getFloat(String key,
Float defaultValue)
Get a Float
associated with the given configuration key.
int
getInt(String key)
Get a int associated with the given configuration key.
int
getInt(String key,
int defaultValue)
Get a int associated with the given configuration key.
Integer
getInteger(String key,
Integer defaultValue)
Get an Integer
associated with the given configuration key.
ConfigurationInterpolator
getInterpolator()
Returns the ConfigurationInterpolator
object that manages
the lookup objects for resolving variables.
abstract Iterator
getKeys()
Get the list of the keys contained in the configuration.
Iterator
getKeys(String prefix)
Get the list of the keys contained in the configuration that match the
specified prefix.
List
getList(String key)
Get a List of strings associated with the given configuration key.
List
getList(String key,
List defaultValue)
Get a List of strings associated with the given configuration key.
char
getListDelimiter()
Retrieve the delimiter for this configuration.
org.apache.commons.logging.Log
getLogger()
Returns the logger used by this configuration object.
long
getLong(String key)
Get a long associated with the given configuration key.
long
getLong(String key,
long defaultValue)
Get a long associated with the given configuration key.
Long
getLong(String key,
Long defaultValue)
Get a Long
associated with the given configuration key.
Properties
getProperties(String key)
Get a list of properties associated with the given configuration key.
Properties
getProperties(String key,
Properties defaults)
Get a list of properties associated with the given configuration key.
short
getShort(String key)
Get a short associated with the given configuration key.
short
getShort(String key,
short defaultValue)
Get a short associated with the given configuration key.
Short
getShort(String key,
Short defaultValue)
Get a Short
associated with the given configuration key.
String
getString(String key)
Get a string associated with the given configuration key.
String
getString(String key,
String defaultValue)
Get a string associated with the given configuration key.
String[]
getStringArray(String key)
Get an array of strings associated with the given configuration key.
StrSubstitutor
getSubstitutor()
Returns the object that is responsible for variable interpolation.
protected Object
interpolate(Object value)
Returns the interpolated value.
protected String
interpolate(String base)
interpolate key names to handle ${key} stuff
protected String
interpolateHelper(String base,
List priorVariables)
Deprecated. Interpolation is now handled by
PropertyConverter
; this method will no longer be
called
boolean
isDelimiterParsingDisabled()
Determine if this configuration is using delimiters when parsing
property values to convert them to lists of values.
abstract boolean
isEmpty()
Check if the configuration is empty.
boolean
isThrowExceptionOnMissing()
Returns true if missing values throw Exceptions.
protected Object
resolveContainerStore(String key)
Returns an object from the store described by the key.
static void
setDefaultListDelimiter(char delimiter)
For configurations extending AbstractConfiguration, allow them to change
the listDelimiter from the default comma (",").
static void
setDelimiter(char delimiter)
Deprecated. Use AbstractConfiguration.setDefaultListDelimiter(char)
instead
void
setDelimiterParsingDisabled(boolean delimiterParsingDisabled)
Set whether this configuration should use delimiters when parsing
property values to convert them to lists of values.
void
setListDelimiter(char listDelimiter)
Change the list delimiter for this configuration.
void
setLogger(org.apache.commons.logging.Log log)
Allows to set the logger to be used by this configuration object.
void
setProperty(String key,
Object value)
Set a property, this will replace any previously set values.
void
setThrowExceptionOnMissing(boolean throwExceptionOnMissing)
Allows to set the throwExceptionOnMissing
flag.
Configuration
subset(String prefix)
Return a decorator Configuration containing every key from the current
Configuration that starts with the specified prefix.
Methods inherited from class org.apache.commons.configuration.event.EventSource
addConfigurationListener, addErrorListener, clearConfigurationListeners, clearErrorListeners, clone, createErrorEvent, createEvent, fireError, fireEvent, getConfigurationListeners, getErrorListeners, isDetailEvents, removeConfigurationListener, removeErrorListener, setDetailEvents
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.commons.configuration.Configuration
getProperty
Field Detail
EVENT_ADD_PROPERTY
public static final int EVENT_ADD_PROPERTY
- Constant for the add property event type.
- Since:
- 1.3
- See Also:
- Constant Field Values
EVENT_CLEAR_PROPERTY
public static final int EVENT_CLEAR_PROPERTY
- Constant for the clear property event type.
- Since:
- 1.3
- See Also:
- Constant Field Values
EVENT_SET_PROPERTY
public static final int EVENT_SET_PROPERTY
- Constant for the set property event type.
- Since:
- 1.3
- See Also:
- Constant Field Values
EVENT_CLEAR
public static final int EVENT_CLEAR
- Constant for the clear configuration event type.
- Since:
- 1.3
- See Also:
- Constant Field Values
EVENT_READ_PROPERTY
public static final int EVENT_READ_PROPERTY
- Constant for the get property event type. This event type is used for
error events.
- Since:
- 1.4
- See Also:
- Constant Field Values
START_TOKEN
protected static final String START_TOKEN
- start token
- See Also:
- Constant Field Values
END_TOKEN
protected static final String END_TOKEN
- end token
- See Also:
- Constant Field Values
Constructor Detail
AbstractConfiguration
public AbstractConfiguration()
- Creates a new instance of
AbstractConfiguration
.
Method Detail
setDefaultListDelimiter
public static void setDefaultListDelimiter(char delimiter)
- For configurations extending AbstractConfiguration, allow them to change
the listDelimiter from the default comma (","). This value will be used
only when creating new configurations. Those already created will not be
affected by this change
- Parameters:
delimiter
- The new listDelimiter
setDelimiter
public static void setDelimiter(char delimiter)
- Deprecated. Use AbstractConfiguration.setDefaultListDelimiter(char)
instead
- Sets the default list delimiter.
- Parameters:
delimiter
- the delimiter character
getDefaultListDelimiter
public static char getDefaultListDelimiter()
- Retrieve the current delimiter. By default this is a comma (",").
- Returns:
- The delimiter in use
getDelimiter
public static char getDelimiter()
- Deprecated. Use AbstractConfiguration.getDefaultListDelimiter() instead
- Returns the default list delimiter.
- Returns:
- the default list delimiter
setListDelimiter
public void setListDelimiter(char listDelimiter)
- Change the list delimiter for this configuration.
Note: this change will only be effective for new parsings. If you
want it to take effect for all loaded properties use the no arg constructor
and call this method before setting the source.
- Parameters:
listDelimiter
- The new listDelimiter
getListDelimiter
public char getListDelimiter()
- Retrieve the delimiter for this configuration. The default
is the value of defaultListDelimiter.
- Returns:
- The listDelimiter in use
isDelimiterParsingDisabled
public boolean isDelimiterParsingDisabled()
- Determine if this configuration is using delimiters when parsing
property values to convert them to lists of values. Defaults to false
- Returns:
- true if delimiters are not being used
setDelimiterParsingDisabled
public void setDelimiterParsingDisabled(boolean delimiterParsingDisabled)
- Set whether this configuration should use delimiters when parsing
property values to convert them to lists of values. By default delimiter
parsing is enabled
Note: this change will only be effective for new parsings. If you
want it to take effect for all loaded properties use the no arg constructor
and call this method before setting source.
- Parameters:
delimiterParsingDisabled
- a flag whether delimiter parsing should
be disabled
setThrowExceptionOnMissing
public void setThrowExceptionOnMissing(boolean throwExceptionOnMissing)
- Allows to set the
throwExceptionOnMissing
flag. This
flag controls the behavior of property getter methods that return
objects if the requested property is missing. If the flag is set to
false (which is the default value), these methods will return
null. If set to true, they will throw a
NoSuchElementException
exception. Note that getter methods
for primitive data types are not affected by this flag.
- Parameters:
throwExceptionOnMissing
- The new value for the property
isThrowExceptionOnMissing
public boolean isThrowExceptionOnMissing()
- Returns true if missing values throw Exceptions.
- Returns:
- true if missing values throw Exceptions
getSubstitutor
public StrSubstitutor getSubstitutor()
- Returns the object that is responsible for variable interpolation.
- Returns:
- the object responsible for variable interpolation
- Since:
- 1.4
getInterpolator
public ConfigurationInterpolator getInterpolator()
- Returns the
ConfigurationInterpolator
object that manages
the lookup objects for resolving variables. Note: If this
object is manipulated (e.g. new lookup objects added), synchronisation
has to be manually ensured. Because
ConfigurationInterpolator
is not thread-safe concurrent
access to properties of this configuration instance (which causes the
interpolator to be invoked) may cause race conditions.
- Returns:
- the
ConfigurationInterpolator
associated with this
configuration - Since:
- 1.4
createInterpolator
protected ConfigurationInterpolator createInterpolator()
- Creates the interpolator object that is responsible for variable
interpolation. This method is invoked on first access of the
interpolation features. It creates a new instance of
ConfigurationInterpolator
and sets the default lookup
object to an implementation that queries this configuration.
- Returns:
- the newly created interpolator object
- Since:
- 1.4
getLogger
public org.apache.commons.logging.Log getLogger()
- Returns the logger used by this configuration object.
- Returns:
- the logger
- Since:
- 1.4
setLogger
public void setLogger(org.apache.commons.logging.Log log)
- Allows to set the logger to be used by this configuration object. This
method makes it possible for clients to exactly control logging behavior.
Per default a logger is set that will ignore all log messages. Derived
classes that want to enable logging should call this method during their
initialization with the logger to be used.
- Parameters:
log
- the new logger- Since:
- 1.4
addErrorLogListener
public void addErrorLogListener()
- Adds a special
ConfigurationErrorListener
object to this configuration that will log all internal errors. This
method is intended to be used by certain derived classes, for which it is
known that they can fail on property access (e.g.
DatabaseConfiguration
).
- Since:
- 1.4
addProperty
public void addProperty(String key,
Object value)
- Add a property to the configuration. If it already exists then the value
stated here will be added to the configuration entry. For example, if
the property:
resource.loader = file
is already present in the configuration and you call
addProperty("resource.loader", "classpath")
Then you will end up with a List like the following:
["file", "classpath"]
- Specified by:
addProperty
in interface Configuration
- Parameters:
key
- The key to add the property to.value
- The value to add.
addPropertyDirect
protected abstract void addPropertyDirect(String key,
Object value)
- Adds a key/value pair to the Configuration. Override this method to
provide write acces to underlying Configuration store.
- Parameters:
key
- key to use for mappingvalue
- object to store
interpolate
protected String interpolate(String base)
- interpolate key names to handle ${key} stuff
- Parameters:
base
- string to interpolate
- Returns:
- returns the key name with the ${key} substituted
interpolate
protected Object interpolate(Object value)
- Returns the interpolated value. Non String values are returned without change.
- Parameters:
value
- the value to interpolate
- Returns:
- returns the value with variables substituted
interpolateHelper
protected String interpolateHelper(String base,
List priorVariables)
- Deprecated. Interpolation is now handled by
PropertyConverter
; this method will no longer be
called
- Recursive handler for multple levels of interpolation.
When called the first time, priorVariables should be null.
- Parameters:
base
- string with the ${key} variablespriorVariables
- serves two purposes: to allow checking for loops,
and creating a meaningful exception message should a loop occur. It's
0'th element will be set to the value of base from the first call. All
subsequent interpolated variables are added afterward.
- Returns:
- the string with the interpolation taken care of
subset
public Configuration subset(String prefix)
- Return a decorator Configuration containing every key from the current
Configuration that starts with the specified prefix. The prefix is
removed from the keys in the subset. For example, if the configuration
contains the following properties:
prefix.number = 1
prefix.string = Apache
prefixed.foo = bar
prefix = Jakarta
the Configuration returned by subset("prefix")
will contain
the properties:
number = 1
string = Apache
= Jakarta
(The key for the value "Jakarta" is an empty string)
Since the subset is a decorator and not a modified copy of the initial
Configuration, any change made to the subset is available to the
Configuration, and reciprocally.
- Specified by:
subset
in interface Configuration
- Parameters:
prefix
- The prefix used to select the properties.
- Returns:
- a subset configuration
- See Also:
SubsetConfiguration
isEmpty
public abstract boolean isEmpty()
- Check if the configuration is empty.
- Specified by:
isEmpty
in interface Configuration
- Returns:
true
if the configuration contains no property,
false
otherwise.
containsKey
public abstract boolean containsKey(String key)
- Check if the configuration contains the specified key.
- Specified by:
containsKey
in interface Configuration
- Parameters:
key
- the key whose presence in this configuration is to be tested
- Returns:
true
if the configuration contains a value for this
key, false
otherwise
setProperty
public void setProperty(String key,
Object value)
- Set a property, this will replace any previously set values. Set values
is implicitly a call to clearProperty(key), addProperty(key, value).
- Specified by:
setProperty
in interface Configuration
- Parameters:
key
- The key of the property to changevalue
- The new value
clearProperty
public void clearProperty(String key)
- Removes the specified property from this configuration. This
implementation performs some preparations and then delegates to
clearPropertyDirect()
, which will do the real work.
- Specified by:
clearProperty
in interface Configuration
- Parameters:
key
- the key to be removed
clearPropertyDirect
protected void clearPropertyDirect(String key)
- Removes the specified property from this configuration. This method is
called by
clearProperty()
after it has done some
preparations. It should be overriden in sub classes. This base
implementation is just left empty.
- Parameters:
key
- the key to be removed
clear
public void clear()
- Remove all properties from the configuration.
- Specified by:
clear
in interface Configuration
getKeys
public abstract Iterator getKeys()
- Get the list of the keys contained in the configuration. The returned
iterator can be used to obtain all defined keys. Note that the exact
behavior of the iterator's
remove()
method is specific to
a concrete implementation. It may remove the corresponding
property from the configuration, but this is not guaranteed. In any case
it is no replacement for calling
Configuration.clearProperty(String)
for this property. So it is
highly recommended to avoid using the iterator's remove()
method.
- Specified by:
getKeys
in interface Configuration
- Returns:
- An Iterator.
getKeys
public Iterator getKeys(String prefix)
- Get the list of the keys contained in the configuration that match the
specified prefix.
- Specified by:
getKeys
in interface Configuration
- Parameters:
prefix
- The prefix to test against.
- Returns:
- An Iterator of keys that match the prefix.
- See Also:
Configuration.getKeys()
getProperties
public Properties getProperties(String key)
- Get a list of properties associated with the given configuration key.
This method expects the given key to have an arbitrary number of String
values, each of which is of the form
key=value
. These
strings are splitted at the equals sign, and the key parts will become
keys of the returned Properties
object, the value parts
become values.
- Specified by:
getProperties
in interface Configuration
- Parameters:
key
- The configuration key.
- Returns:
- The associated properties if key is found.
getProperties
public Properties getProperties(String key,
Properties defaults)
- Get a list of properties associated with the given configuration key.
- Parameters:
key
- The configuration key.defaults
- Any default values for the returned
Properties
object. Ignored if null
.
- Returns:
- The associated properties if key is found.
- Throws:
ConversionException
- is thrown if the key maps to an object that
is not a String/List of Strings.
IllegalArgumentException
- if one of the tokens is malformed (does
not contain an equals sign).
getBoolean
public boolean getBoolean(String key)
- Get a boolean associated with the given configuration key.
- Specified by:
getBoolean
in interface Configuration
- Parameters:
key
- The configuration key.
- Returns:
- The associated boolean.
- See Also:
PropertyConverter.toBoolean(Object)
getBoolean
public boolean getBoolean(String key,
boolean defaultValue)
- Get a boolean associated with the given configuration key.
If the key doesn't map to an existing object, the default value
is returned.
- Specified by:
getBoolean
in interface Configuration
- Parameters:
key
- The configuration key.defaultValue
- The default value.
- Returns:
- The associated boolean.
- See Also:
PropertyConverter.toBoolean(Object)
getBoolean
public Boolean getBoolean(String key,
Boolean defaultValue)
- Obtains the value of the specified key and tries to convert it into a
Boolean
object. If the property has no value, the passed
in default value will be used.
- Specified by:
getBoolean
in interface Configuration
- Parameters:
key
- the key of the propertydefaultValue
- the default value
- Returns:
- the value of this key converted to a
Boolean
- Throws:
ConversionException
- if the value cannot be converted to a
Boolean
- See Also:
PropertyConverter.toBoolean(Object)
getByte
public byte getByte(String key)
- Get a byte associated with the given configuration key.
- Specified by:
getByte
in interface Configuration
- Parameters:
key
- The configuration key.
- Returns:
- The associated byte.
getByte
public byte getByte(String key,
byte defaultValue)
- Get a byte associated with the given configuration key.
If the key doesn't map to an existing object, the default value
is returned.
- Specified by:
getByte
in interface Configuration
- Parameters:
key
- The configuration key.defaultValue
- The default value.
- Returns:
- The associated byte.
getByte
public Byte getByte(String key,
Byte defaultValue)
- Get a
Byte
associated with the given configuration key.
- Specified by:
getByte
in interface Configuration
- Parameters:
key
- The configuration key.defaultValue
- The default value.
- Returns:
- The associated byte if key is found and has valid format, default
value otherwise.
getDouble
public double getDouble(String key)
- Get a double associated with the given configuration key.
- Specified by:
getDouble
in interface Configuration
- Parameters:
key
- The configuration key.
- Returns:
- The associated double.
getDouble
public double getDouble(String key,
double defaultValue)
- Get a double associated with the given configuration key.
If the key doesn't map to an existing object, the default value
is returned.
- Specified by:
getDouble
in interface Configuration
- Parameters:
key
- The configuration key.defaultValue
- The default value.
- Returns:
- The associated double.
getDouble
public Double getDouble(String key,
Double defaultValue)
- Get a
Double
associated with the given configuration key.
- Specified by:
getDouble
in interface Configuration
- Parameters:
key
- The configuration key.defaultValue
- The default value.
- Returns:
- The associated double if key is found and has valid
format, default value otherwise.
getFloat
public float getFloat(String key)
- Get a float associated with the given configuration key.
- Specified by:
getFloat
in interface Configuration
- Parameters:
key
- The configuration key.
- Returns:
- The associated float.
getFloat
public float getFloat(String key,
float defaultValue)
- Get a float associated with the given configuration key.
If the key doesn't map to an existing object, the default value
is returned.
- Specified by:
getFloat
in interface Configuration
- Parameters:
key
- The configuration key.defaultValue
- The default value.
- Returns:
- The associated float.
getFloat
public Float getFloat(String key,
Float defaultValue)
- Get a
Float
associated with the given configuration key.
If the key doesn't map to an existing object, the default value
is returned.
- Specified by:
getFloat
in interface Configuration
- Parameters:
key
- The configuration key.defaultValue
- The default value.
- Returns:
- The associated float if key is found and has valid
format, default value otherwise.
getInt
public int getInt(String key)
- Get a int associated with the given configuration key.
- Specified by:
getInt
in interface Configuration
- Parameters:
key
- The configuration key.
- Returns:
- The associated int.
getInt
public int getInt(String key,
int defaultValue)
- Get a int associated with the given configuration key.
If the key doesn't map to an existing object, the default value
is returned.
- Specified by:
getInt
in interface Configuration
- Parameters:
key
- The configuration key.defaultValue
- The default value.
- Returns:
- The associated int.
getInteger
public Integer getInteger(String key,
Integer defaultValue)
- Get an
Integer
associated with the given configuration key.
If the key doesn't map to an existing object, the default value
is returned.
- Specified by:
getInteger
in interface Configuration
- Parameters:
key
- The configuration key.defaultValue
- The default value.
- Returns:
- The associated int if key is found and has valid format, default
value otherwise.
getLong
public long getLong(String key)
- Get a long associated with the given configuration key.
- Specified by:
getLong
in interface Configuration
- Parameters:
key
- The configuration key.
- Returns:
- The associated long.
getLong
public long getLong(String key,
long defaultValue)
- Get a long associated with the given configuration key.
If the key doesn't map to an existing object, the default value
is returned.
- Specified by:
getLong
in interface Configuration
- Parameters:
key
- The configuration key.defaultValue
- The default value.
- Returns:
- The associated long.
getLong
public Long getLong(String key,
Long defaultValue)
- Get a
Long
associated with the given configuration key.
If the key doesn't map to an existing object, the default value
is returned.
- Specified by:
getLong
in interface Configuration
- Parameters:
key
- The configuration key.defaultValue
- The default value.
- Returns:
- The associated long if key is found and has valid
format, default value otherwise.
getShort
public short getShort(String key)
- Get a short associated with the given configuration key.
- Specified by:
getShort
in interface Configuration
- Parameters:
key
- The configuration key.
- Returns:
- The associated short.
getShort
public short getShort(String key,
short defaultValue)
- Get a short associated with the given configuration key.
- Specified by:
getShort
in interface Configuration
- Parameters:
key
- The configuration key.defaultValue
- The default value.
- Returns:
- The associated short.
getShort
public Short getShort(String key,
Short defaultValue)
- Get a
Short
associated with the given configuration key.
If the key doesn't map to an existing object, the default value
is returned.
- Specified by:
getShort
in interface Configuration
- Parameters:
key
- The configuration key.defaultValue
- The default value.
- Returns:
- The associated short if key is found and has valid
format, default value otherwise.
getBigDecimal
public BigDecimal getBigDecimal(String key)
- Get a
BigDecimal
associated with the given configuration key.
- Specified by:
getBigDecimal
in interface Configuration
- Parameters:
key
- The configuration key.
- Returns:
- The associated BigDecimal if key is found and has valid format
- See Also:
setThrowExceptionOnMissing(boolean)
getBigDecimal
public BigDecimal getBigDecimal(String key,
BigDecimal defaultValue)
- Get a
BigDecimal
associated with the given configuration key.
If the key doesn't map to an existing object, the default value
is returned.
- Specified by:
getBigDecimal
in interface Configuration
- Parameters:
key
- The configuration key.defaultValue
- The default value.
- Returns:
- The associated BigDecimal if key is found and has valid
format, default value otherwise.
getBigInteger
public BigInteger getBigInteger(String key)
- Get a
BigInteger
associated with the given configuration key.
- Specified by:
getBigInteger
in interface Configuration
- Parameters:
key
- The configuration key.
- Returns:
- The associated BigInteger if key is found and has valid format
- See Also:
setThrowExceptionOnMissing(boolean)
getBigInteger
public BigInteger getBigInteger(String key,
BigInteger defaultValue)
- Get a
BigInteger
associated with the given configuration key.
If the key doesn't map to an existing object, the default value
is returned.
- Specified by:
getBigInteger
in interface Configuration
- Parameters:
key
- The configuration key.defaultValue
- The default value.
- Returns:
- The associated BigInteger if key is found and has valid
format, default value otherwise.
getString
public String getString(String key)
- Get a string associated with the given configuration key.
- Specified by:
getString
in interface Configuration
- Parameters:
key
- The configuration key.
- Returns:
- The associated string.
- See Also:
setThrowExceptionOnMissing(boolean)
getString
public String getString(String key,
String defaultValue)
- Get a string associated with the given configuration key.
If the key doesn't map to an existing object, the default value
is returned.
- Specified by:
getString
in interface Configuration
- Parameters:
key
- The configuration key.defaultValue
- The default value.
- Returns:
- The associated string if key is found and has valid
format, default value otherwise.
getStringArray
public String[] getStringArray(String key)
- Get an array of strings associated with the given configuration key.
If the key doesn't map to an existing object, an empty array is returned.
If a property is added to a configuration, it is checked whether it
contains multiple values. This is obvious if the added object is a list
or an array. For strings it is checked whether the string contains the
list delimiter character that can be specified using the
setListDelimiter()
method. If this is the case, the string
is splitted at these positions resulting in a property with multiple
values.
- Specified by:
getStringArray
in interface Configuration
- Parameters:
key
- The configuration key.
- Returns:
- The associated string array if key is found.
- Throws:
ConversionException
- is thrown if the key maps to an
object that is not a String/List of Strings.- See Also:
setListDelimiter(char)
,
setDelimiterParsingDisabled(boolean)
getList
public List getList(String key)
- Get a List of strings associated with the given configuration key.
If the key doesn't map to an existing object an empty List is returned.
- Specified by:
getList
in interface Configuration
- Parameters:
key
- The configuration key.
- Returns:
- The associated List.
- See Also:
getStringArray(String)
getList
public List getList(String key,
List defaultValue)
- Get a List of strings associated with the given configuration key.
If the key doesn't map to an existing object, the default value
is returned.
- Specified by:
getList
in interface Configuration
- Parameters:
key
- The configuration key.defaultValue
- The default value.
- Returns:
- The associated List of strings.
resolveContainerStore
protected Object resolveContainerStore(String key)
- Returns an object from the store described by the key. If the value is a
List object, replace it with the first object in the list.
- Parameters:
key
- The property key.
- Returns:
- value Value, transparently resolving a possible List dependency.
Overview
Package
Class
Use
Tree
Deprecated
Index
Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
Copyright © 2001-2007 The Apache Software Foundation. All Rights Reserved.