java.lang.Object | |
↳ | org.apache.commons.beanutils.DynaBeanMapDecorator |
Decorates a DynaBean
to provide Map
behaviour.
The motivation for this implementation is to provide access to DynaBean
properties in technologies that are unaware of BeanUtils and DynaBean
s -
such as the expression languages of JSTL and JSF.
This can be achieved either by wrapping the DynaBean
prior to
providing it to the technolody to process or by providing a Map
accessor 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}
To decorate a DynaBean
simply instantiate this class with the
target DynaBean
:
Map fooMap = new DynaBeanMapDecorator(fooDynaBean);
The above example creates a read only Map
.
To create a Map
which can be modified, construct a
DynaBeanMapDecorator
with the read only
attribute set to false
:
Map fooMap = new DynaBeanMapDecorator(fooDynaBean, false);
In this implementation the entrySet()
, keySet()
and values()
methods create an unmodifiable
Set
and it does not support the Map's clear()
and remove()
operations.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Constructs a read only Map for the specified
DynaBean . | |||||||||||
Construct a Map for the specified
DynaBean . |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
clear() operation is not supported.
| |||||||||||
Indicate whether the
DynaBean contains a specified
value for one (or more) of its properties. | |||||||||||
Indicates whether the decorated
DynaBean contains
a specified value. | |||||||||||
Returns the Set of the property/value mappings
in the decorated | |||||||||||
Return the value for the specified key from
the decorated
DynaBean . | |||||||||||
Provide access to the underlying
DynaBean
this Map decorates. | |||||||||||
Indicate whether the decorated
DynaBean has
any properties. | |||||||||||
Indicate whether the Map is read only.
| |||||||||||
Returns the Set of the property
names in the decorated | |||||||||||
Set the value for the specified property in
the decorated
DynaBean . | |||||||||||
Copy the contents of a Map to the decorated
DynaBean . | |||||||||||
remove() operation is not supported.
| |||||||||||
Returns the number properties in the decorated
DynaBean . | |||||||||||
Returns the set of property values in the
decorated
DynaBean . |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
From interface
java.util.Map
|
Constructs a read only Map for the specified
DynaBean
.
dynaBean | The dyna bean being decorated |
---|
IllegalArgumentException | if the DynaBean is null.
|
---|
Construct a Map for the specified DynaBean
.
dynaBean | The dyna bean being decorated |
---|---|
readOnly | true if the Mpa is read only
otherwise false |
IllegalArgumentException | if the DynaBean is null.
|
---|
Returns the Set of the property/value mappings
in the decorated DynaBean
.
Each element in the Set is a Map.Entry
type.
Indicate whether the Map is read only.
true
if the Map is read only,
otherwise false
.
Returns the Set of the property
names in the decorated DynaBean
.
N.B.For DynaBean
s whose associated DynaClass
is a MutableDynaClass
a new Set is created every
time, otherwise the Set is created only once and cached.
DynaBean
s
property names.
Set the value for the specified property in
the decorated DynaBean
.
key | The DynaBean 's property name |
---|---|
value | The value for the specified property. |
UnsupportedOperationException | if
isReadOnly() is true.
|
---|
Copy the contents of a Map to the decorated DynaBean
.
map | The Map of values to copy. |
---|
UnsupportedOperationException | if
isReadOnly() is true.
|
---|
remove() operation is not supported.
key | The DynaBean 's property name |
---|
Returns the number properties in the decorated
DynaBean
.
Returns the set of property values in the
decorated DynaBean
.