Class ConfigurationDynaBean
- java.lang.Object
-
- java.util.AbstractMap<java.lang.Object,java.lang.Object>
-
- org.apache.commons.configuration2.ConfigurationMap
-
- org.apache.commons.configuration2.beanutils.ConfigurationDynaBean
-
- All Implemented Interfaces:
java.util.Map<java.lang.Object,java.lang.Object>
,org.apache.commons.beanutils.DynaBean
public class ConfigurationDynaBean extends ConfigurationMap implements org.apache.commons.beanutils.DynaBean
TheConfigurationDynaBean
dynamically reads and writes configurations properties from a wrapped configuration-collectionConfiguration
instance. It also implements aMap
interface so that it can be used in JSP 2.0 Expression Language expressions.The
ConfigurationDynaBean
maps nested and mapped properties to the appropriateConfiguration
subset using theConfiguration.subset(java.lang.String)
method. Similarly, indexed properties reference lists of configuration properties using theImmutableConfiguration.getList(String)
method. Setting an indexed property is supported, too.Note: Some of the methods expect that a dot (".") is used as property delimiter for the wrapped configuration. This is true for most of the default configurations. Hierarchical configurations, for which a specific expression engine is set, may cause problems.
- Since:
- 1.0-rc1
-
-
Field Summary
Fields Modifier and Type Field Description private static org.apache.commons.logging.Log
LOG
The logger.private static java.lang.String
PROPERTY_DELIMITER
Constant for the property delimiter.
-
Constructor Summary
Constructors Constructor Description ConfigurationDynaBean(Configuration configuration)
Constructs a new instance ofConfigurationDynaBean
and sets the configuration this bean is associated with.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private boolean
checkIndexedProperty(java.lang.String name)
Checks whether the given name references an indexed property.boolean
contains(java.lang.String name, java.lang.String key)
java.lang.Object
get(java.lang.String name)
java.lang.Object
get(java.lang.String name, int index)
java.lang.Object
get(java.lang.String name, java.lang.String key)
org.apache.commons.beanutils.DynaClass
getDynaClass()
void
remove(java.lang.String name, java.lang.String key)
void
set(java.lang.String name, int index, java.lang.Object value)
void
set(java.lang.String name, java.lang.Object value)
void
set(java.lang.String name, java.lang.String key, java.lang.Object value)
-
Methods inherited from class org.apache.commons.configuration2.ConfigurationMap
entrySet, get, getConfiguration, put
-
Methods inherited from class java.util.AbstractMap
clear, clone, containsKey, containsValue, equals, hashCode, isEmpty, keySet, putAll, remove, size, toString, values
-
-
-
-
Field Detail
-
PROPERTY_DELIMITER
private static final java.lang.String PROPERTY_DELIMITER
Constant for the property delimiter.- See Also:
- Constant Field Values
-
LOG
private static final org.apache.commons.logging.Log LOG
The logger.
-
-
Constructor Detail
-
ConfigurationDynaBean
public ConfigurationDynaBean(Configuration configuration)
Constructs a new instance ofConfigurationDynaBean
and sets the configuration this bean is associated with.- Parameters:
configuration
- the configuration
-
-
Method Detail
-
checkIndexedProperty
private boolean checkIndexedProperty(java.lang.String name)
Checks whether the given name references an indexed property. This implementation tests for properties of type list or array. If the property does not exist, an exception is thrown.- Parameters:
name
- the name of the property to check- Returns:
- a flag whether this is an indexed property
- Throws:
java.lang.IllegalArgumentException
- if the property does not exist
-
contains
public boolean contains(java.lang.String name, java.lang.String key)
- Specified by:
contains
in interfaceorg.apache.commons.beanutils.DynaBean
-
get
public java.lang.Object get(java.lang.String name)
- Specified by:
get
in interfaceorg.apache.commons.beanutils.DynaBean
-
get
public java.lang.Object get(java.lang.String name, int index)
- Specified by:
get
in interfaceorg.apache.commons.beanutils.DynaBean
-
get
public java.lang.Object get(java.lang.String name, java.lang.String key)
- Specified by:
get
in interfaceorg.apache.commons.beanutils.DynaBean
-
getDynaClass
public org.apache.commons.beanutils.DynaClass getDynaClass()
- Specified by:
getDynaClass
in interfaceorg.apache.commons.beanutils.DynaBean
-
remove
public void remove(java.lang.String name, java.lang.String key)
- Specified by:
remove
in interfaceorg.apache.commons.beanutils.DynaBean
-
set
public void set(java.lang.String name, int index, java.lang.Object value)
- Specified by:
set
in interfaceorg.apache.commons.beanutils.DynaBean
-
set
public void set(java.lang.String name, java.lang.Object value)
- Specified by:
set
in interfaceorg.apache.commons.beanutils.DynaBean
-
set
public void set(java.lang.String name, java.lang.String key, java.lang.Object value)
- Specified by:
set
in interfaceorg.apache.commons.beanutils.DynaBean
-
-