Class DynaBeanMapDecorator
- java.lang.Object
-
- org.apache.commons.beanutils.BaseDynaBeanMapDecorator<java.lang.Object>
-
- org.apache.commons.beanutils.DynaBeanMapDecorator
-
- All Implemented Interfaces:
java.util.Map<java.lang.Object,java.lang.Object>
@Deprecated public class DynaBeanMapDecorator extends BaseDynaBeanMapDecorator<java.lang.Object>
Deprecated.UseDynaBeanPropertyMapDecoratorinstead. When adding generics it turned out that it was not possible to use the correct type parameters without breaking backwards compatibility. Therefore, classDynaBeanPropertyMapDecoratorwas introduced as a replacement.Decorates a
DynaBeanto provideMapbehavior.The motivation for this implementation is to provide access to
DynaBeanproperties in technologies that are unaware of BeanUtils andDynaBeans - such as the expression languages of JSTL and JSF.This can be achieved either by wrapping the
DynaBeanprior to providing it to the technolody to process or by providing aMapaccessor method on the DynaBean implementation:public Map getMap() { return new DynaBeanMapDecorator(this); }This, for example, could be used in JSTL in the following way to access a DynaBean's
fooProperty:${myDynaBean.map.fooProperty}UsageTo decorate a
DynaBeansimply instantiate this class with the targetDynaBean:Map fooMap = new DynaBeanMapDecorator(fooDynaBean);The above example creates a read only
Map. To create aMapwhich can be modified, construct aDynaBeanMapDecoratorwith the read only attribute set tofalse:Map fooMap = new DynaBeanMapDecorator(fooDynaBean, false);LimitationsIn this implementation the
entrySet(),keySet()andvalues()methods create an unmodifiableSetand it does not support the Map'sclear()andremove()operations.For reasons of backwards compatibility, the generic types of this
Mapimplementation are<Object, Object>. However, the keys of the map are typically strings.- Since:
- BeanUtils 1.8.0
-
-
Constructor Summary
Constructors Constructor Description DynaBeanMapDecorator(DynaBean dynaBean)Deprecated.Constructs a read only Map for the specifiedDynaBean.DynaBeanMapDecorator(DynaBean dynaBean, boolean readOnly)Deprecated.Construct a Map for the specifiedDynaBean.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected java.lang.ObjectconvertKey(java.lang.String propertyName)Deprecated.Converts the name of a property to the key type of this decorator.-
Methods inherited from class org.apache.commons.beanutils.BaseDynaBeanMapDecorator
clear, containsKey, containsValue, entrySet, get, getDynaBean, isEmpty, isReadOnly, keySet, put, putAll, remove, size, values
-
-
-
-
Constructor Detail
-
DynaBeanMapDecorator
public DynaBeanMapDecorator(DynaBean dynaBean)
Deprecated.Constructs a read only Map for the specifiedDynaBean.- Parameters:
dynaBean- The dyna bean being decorated- Throws:
java.lang.IllegalArgumentException- if theDynaBeanis null.
-
DynaBeanMapDecorator
public DynaBeanMapDecorator(DynaBean dynaBean, boolean readOnly)
Deprecated.Construct a Map for the specifiedDynaBean.- Parameters:
dynaBean- The dyna bean being decoratedreadOnly-trueif the Map is read only otherwisefalse- Throws:
java.lang.IllegalArgumentException- if theDynaBeanis null.
-
-
Method Detail
-
convertKey
protected java.lang.Object convertKey(java.lang.String propertyName)
Deprecated.Description copied from class:BaseDynaBeanMapDecoratorConverts the name of a property to the key type of this decorator.- Specified by:
convertKeyin classBaseDynaBeanMapDecorator<java.lang.Object>- Parameters:
propertyName- the name of a property- Returns:
- the converted key to be used in the decorated map
-
-