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.
ELResolvers are combined together using
CompositeELResolvers, 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
ConstructorsConstructorDescriptionCreates a new read/writeDynaBeanELResolver.DynaBeanELResolver(boolean readOnly) Creates a newDynaBeanELResolverwhose 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 thepropertyargument.getFeatureDescriptors(ELContext context, Object base) Returns information about the set of variables or properties that can be resolved for the givenbaseobject.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 thepropertyargument.booleanisReadOnly(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.voidIf the base is aDynaBean, attempts to set the value associated with the given key, as specified by thepropertyargument.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 newDynaBeanELResolverwhose read-only status is determined by the given parameter.- Parameters:
readOnly-trueif this resolver cannot modify properties;falseotherwise.
-
-
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, thepropertyResolvedproperty of theELContextobject must be set totrueby this resolver, before returning. If this property is nottrueafter 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:
getTypein classELResolver- Parameters:
context- The context of this evaluation.base- The base to analyze. Only bases of typeDynaBeanare handled by this resolver.property- The key to return the acceptable type for.- Returns:
- If the
propertyResolvedproperty ofELContextwas set totrue, then the most general acceptable type; otherwise undefined. - Throws:
NullPointerException- if context isnullPropertyNotFoundException- 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 thepropertyargument. If the key was not found,PropertyNotFoundExceptionis thrown.If the base is a
DynaBean, thepropertyResolvedproperty of theELContextobject must be set totrueby this resolver, before returning. If this property is nottrueafter this method is called, the caller should ignore the return value.Just as in
DynaBean.get(String), just becausenullis returned doesn't mean there is no mapping for the key; it's also possible that the method explicitly returnsnull.- Specified by:
getValuein classELResolver- Parameters:
context- The context of this evaluation.base- The base to be analyzed. Only bases of typeDynaBeanare handled by this resolver.property- The key whose associated value is to be returned.- Returns:
- If the
propertyResolvedproperty ofELContextwas 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 thepropertyargument.If the base is a
DynaBean, thepropertyResolvedproperty of theELContextobject must be set totrueby this resolver, before returning. If this property is nottrueafter 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:
setValuein classELResolver- Parameters:
context- The context of this evaluation.base- The base to be modified. Only bases of typeDynaBeanare 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 isnullor if an attempt is made to set a primitive property tonull.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, thepropertyResolvedproperty of theELContextobject must be set totrueby this resolver, before returning. If this property is nottrueafter 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:
isReadOnlyin classELResolver- Parameters:
context- The context of this evaluation.base- The base to analyze. Only bases of typeDynaBeanare handled by this resolver.property- The key to return the read-only status for.- Returns:
- If the
propertyResolvedproperty ofELContextwas set totrue, thentrueif calling thesetValuemethod will always fail orfalseif 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 givenbaseobject. One use for this method is to assist tools in auto-completion.If the
baseparameter isnull, the resolver must enumerate the list of top-level variables it can resolve.The
Iteratorreturned 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. TheFeatureDescriptoris 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
Iteratorreturned 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
ELResolvers 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
propertyResolvedproperty of theELContextis not relevant to this method. The results of allELResolvers are concatenated in the case of composite resolvers.- Specified by:
getFeatureDescriptorsin classELResolver- Parameters:
context- The context of this evaluation.base- The base object whose set of valid properties is to be enumerated, ornullto enumerate the set of top-level variables that this resolver can evaluate.- Returns:
- An
Iteratorcontaining zero or more (possibly infinitely more)FeatureDescriptorobjects, ornullif this resolver does not handle the givenbaseobject 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 thepropertyargument. 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:
getCommonPropertyTypein classELResolver- Parameters:
context- The context of this evaluation.base- The base to analyze. Only bases of typeDynaBeanare handled by this resolver.- Returns:
nullif base is not aDynaBean; otherwiseObject.class.
-