Class DynaBeanELResolver
DynaBean
.
This resolver handles base objects of type DynaBean
.
It accepts any object as a property and uses that object as a key in
the map. The resulting value is the value in the map that is associated with
that key.
This resolver can be constructed in read-only mode, which means that
isReadOnly(jakarta.el.ELContext, java.lang.Object, java.lang.Object)
will always return true
and setValue(jakarta.el.ELContext, java.lang.Object, java.lang.Object, java.lang.Object)
will always throw PropertyNotWritableException
.
ELResolver
s are combined together using
CompositeELResolver
s, to define rich semantics for evaluating
an expression. See the JavaDocs for ELResolver
for details.
- Since:
- Struts 1.4.1
- See Also:
-
Field Summary
Fields inherited from class jakarta.el.ELResolver
RESOLVABLE_AT_DESIGN_TIME, TYPE
-
Constructor Summary
ConstructorDescriptionCreates a new read/writeDynaBeanELResolver
.DynaBeanELResolver
(boolean readOnly) Creates a newDynaBeanELResolver
whose read-only status is determined by the given parameter. -
Method Summary
Modifier and TypeMethodDescriptionClass
<?> getCommonPropertyType
(ELContext context, Object base) If the base object is aDynaBean
, returns the most general type that this resolver accepts for theproperty
argument.getFeatureDescriptors
(ELContext context, Object base) Returns information about the set of variables or properties that can be resolved for the givenbase
object.Class
<?> If the base object is aDynaBean
, returns the most general acceptable type for a value in this map..If the base object is aDynaBean
, returns the value associated with the given key, as specified by theproperty
argument.boolean
isReadOnly
(ELContext context, Object base, Object property) If the base object is aDynaBean
, returns whether a call tosetValue(jakarta.el.ELContext, java.lang.Object, java.lang.Object, java.lang.Object)
will always fail.void
If the base is aDynaBean
, attempts to set the value associated with the given key, as specified by theproperty
argument.Methods inherited from class jakarta.el.ELResolver
convertToType, invoke
-
Constructor Details
-
DynaBeanELResolver
public DynaBeanELResolver()Creates a new read/writeDynaBeanELResolver
. -
DynaBeanELResolver
public DynaBeanELResolver(boolean readOnly) Creates a newDynaBeanELResolver
whose read-only status is determined by the given parameter.- Parameters:
readOnly
-true
if this resolver cannot modify properties;false
otherwise.
-
-
Method Details
-
getType
If the base object is aDynaBean
, returns the most general acceptable type for a value in this map..If the base is a
DynaBean
, thepropertyResolved
property of theELContext
object must be set totrue
by this resolver, before returning. If this property is nottrue
after this method is called, the caller should ignore the return value.Assuming the base is a
DynaBean
, this method will always return the Java class representing the data type of the underlying property value.- Specified by:
getType
in classELResolver
- Parameters:
context
- The context of this evaluation.base
- The base to analyze. Only bases of typeDynaBean
are handled by this resolver.property
- The key to return the acceptable type for.- Returns:
- If the
propertyResolved
property ofELContext
was set totrue
, then the most general acceptable type; otherwise undefined. - Throws:
NullPointerException
- if context isnull
PropertyNotFoundException
- if the given property name is not found.ELException
- if an exception was thrown while performing the property or variable resolution. The thrown exception must be included as the cause property of this exception, if available.
-
getValue
If the base object is aDynaBean
, returns the value associated with the given key, as specified by theproperty
argument. If the key was not found,PropertyNotFoundException
is thrown.If the base is a
DynaBean
, thepropertyResolved
property of theELContext
object must be set totrue
by this resolver, before returning. If this property is nottrue
after this method is called, the caller should ignore the return value.Just as in
DynaBean.get(String)
, just becausenull
is returned doesn't mean there is no mapping for the key; it's also possible that the method explicitly returnsnull
.- Specified by:
getValue
in classELResolver
- Parameters:
context
- The context of this evaluation.base
- The base to be analyzed. Only bases of typeDynaBean
are handled by this resolver.property
- The key whose associated value is to be returned.- Returns:
- If the
propertyResolved
property ofELContext
was set totrue
, then the value associated with the given key. - Throws:
NullPointerException
- if context isnull
.PropertyNotFoundException
- if the given property does not exists.ELException
- if an exception was thrown while performing the property or variable resolution. The thrown exception must be included as the cause property of this exception, if available.
-
setValue
If the base is aDynaBean
, attempts to set the value associated with the given key, as specified by theproperty
argument.If the base is a
DynaBean
, thepropertyResolved
property of theELContext
object must be set totrue
by this resolver, before returning. If this property is nottrue
after this method is called, the caller can safely assume no value was set.If this resolver was constructed in read-only mode, this method will always throw
PropertyNotWritableException
.- Specified by:
setValue
in classELResolver
- Parameters:
context
- The context of this evaluation.base
- The base to be modified. Only bases of typeDynaBean
are handled by this resolver.property
- The key with which the specified value is to be associated.value
- The value to be associated with the specified key.- Throws:
NullPointerException
- if context isnull
or if an attempt is made to set a primitive property tonull
.org.apache.commons.beanutils.ConversionException
- if the specified value cannot be converted to the type required for this property.PropertyNotFoundException
- if the given property does not exists.PropertyNotWritableException
- if this resolver was constructed in read-only mode.ELException
- if an exception was thrown while performing the property or variable resolution. The thrown exception must be included as the cause property of this exception, if available.
-
isReadOnly
If the base object is aDynaBean
, returns whether a call tosetValue(jakarta.el.ELContext, java.lang.Object, java.lang.Object, java.lang.Object)
will always fail.If the base is a
DynaBean
, thepropertyResolved
property of theELContext
object must be set totrue
by this resolver, before returning. If this property is nottrue
after this method is called, the caller should ignore the return value.If this resolver was constructed in read-only mode, this method will always return
true
.- Specified by:
isReadOnly
in classELResolver
- Parameters:
context
- The context of this evaluation.base
- The base to analyze. Only bases of typeDynaBean
are handled by this resolver.property
- The key to return the read-only status for.- Returns:
- If the
propertyResolved
property ofELContext
was set totrue
, thentrue
if calling thesetValue
method will always fail orfalse
if it is possible that such a call may succeed; otherwise undefined. - Throws:
NullPointerException
- if context isnull
.PropertyNotFoundException
- if the given property does not exists.ELException
- if an exception was thrown while performing the property or variable resolution. The thrown exception must be included as the cause property of this exception, if available.
-
getFeatureDescriptors
Returns information about the set of variables or properties that can be resolved for the givenbase
object. One use for this method is to assist tools in auto-completion.If the
base
parameter isnull
, the resolver must enumerate the list of top-level variables it can resolve.The
Iterator
returned must contain zero or more instances ofFeatureDescriptor
, in no guaranteed order. Each info object contains information about a property in theDynaBean
, as obtained by calling theDynaClass.getDynaProperties()
method. TheFeatureDescriptor
is initialized using the same fields as are present in theDynaProperty
, with the additional required named attributes "type
" and "resolvableAtDesignTime
" set as follows:ELResolver.TYPE
- The runtime type of the property, from {link org.apache.commons.beanutils.DynaProperty#getType()}.ELResolver.RESOLVABLE_AT_DESIGN_TIME
-true
.
The caller should be aware that the
Iterator
returned might iterate through a very large or even infinitely large set of properties. Care should be taken by the caller to not get stuck in an infinite loop.This is a "best-effort" list. Not all
ELResolver
s will return completely accurate results, but all must be callable at both design-time and runtime (i.e. whether or notBeans.isDesignTime()
returnstrue
), without causing errors.The
propertyResolved
property of theELContext
is not relevant to this method. The results of allELResolver
s are concatenated in the case of composite resolvers.- Specified by:
getFeatureDescriptors
in classELResolver
- Parameters:
context
- The context of this evaluation.base
- The base object whose set of valid properties is to be enumerated, ornull
to enumerate the set of top-level variables that this resolver can evaluate.- Returns:
- An
Iterator
containing zero or more (possibly infinitely more)FeatureDescriptor
objects, ornull
if this resolver does not handle the givenbase
object or that the results are too complex to represent with this method - See Also:
-
getCommonPropertyType
If the base object is aDynaBean
, returns the most general type that this resolver accepts for theproperty
argument. Otherwise, returnsnull
.Assuming the base is a
DynaBean
, this method will always returnObject.class
. This is because any object is accepted as a key and is coerced into a string.- Specified by:
getCommonPropertyType
in classELResolver
- Parameters:
context
- The context of this evaluation.base
- The base to analyze. Only bases of typeDynaBean
are handled by this resolver.- Returns:
null
if base is not aDynaBean
; otherwiseObject.class
.
-