Class DynaBeanELResolver

java.lang.Object
jakarta.el.ELResolver
org.apache.struts.faces.application.DynaBeanELResolver

public class DynaBeanELResolver extends ELResolver
Defines property resolution behavior on instances of 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:
  • Constructor Details

    • DynaBeanELResolver

      public DynaBeanELResolver()
      Creates a new read/write DynaBeanELResolver.
    • DynaBeanELResolver

      public DynaBeanELResolver(boolean readOnly)
      Creates a new DynaBeanELResolver whose read-only status is determined by the given parameter.
      Parameters:
      readOnly - true if this resolver cannot modify properties; false otherwise.
  • Method Details

    • getType

      public Class<?> getType(ELContext context, Object base, Object property)
      If the base object is a DynaBean, returns the most general acceptable type for a value in this map..

      If the base is a DynaBean, the propertyResolved property of the ELContext object must be set to true by this resolver, before returning. If this property is not true 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 class ELResolver
      Parameters:
      context - The context of this evaluation.
      base - The base to analyze. Only bases of type DynaBean are handled by this resolver.
      property - The key to return the acceptable type for.
      Returns:
      If the propertyResolved property of ELContext was set to true, then the most general acceptable type; otherwise undefined.
      Throws:
      NullPointerException - if context is null
      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

      public Object getValue(ELContext context, Object base, Object property)
      If the base object is a DynaBean, returns the value associated with the given key, as specified by the property argument. If the key was not found, PropertyNotFoundException is thrown.

      If the base is a DynaBean, the propertyResolved property of the ELContext object must be set to true by this resolver, before returning. If this property is not true after this method is called, the caller should ignore the return value.

      Just as in DynaBean.get(String), just because null is returned doesn't mean there is no mapping for the key; it's also possible that the method explicitly returns null.

      Specified by:
      getValue in class ELResolver
      Parameters:
      context - The context of this evaluation.
      base - The base to be analyzed. Only bases of type DynaBean are handled by this resolver.
      property - The key whose associated value is to be returned.
      Returns:
      If the propertyResolved property of ELContext was set to true, then the value associated with the given key.
      Throws:
      NullPointerException - if context is null.
      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

      public void setValue(ELContext context, Object base, Object property, Object value)
      If the base is a DynaBean, attempts to set the value associated with the given key, as specified by the property argument.

      If the base is a DynaBean, the propertyResolved property of the ELContext object must be set to true by this resolver, before returning. If this property is not true 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 class ELResolver
      Parameters:
      context - The context of this evaluation.
      base - The base to be modified. Only bases of type DynaBean 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 is null or if an attempt is made to set a primitive property to null.
      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

      public boolean isReadOnly(ELContext context, Object base, Object property)
      If the base object is a DynaBean, returns whether a call to setValue(jakarta.el.ELContext, java.lang.Object, java.lang.Object, java.lang.Object) will always fail.

      If the base is a DynaBean, the propertyResolved property of the ELContext object must be set to true by this resolver, before returning. If this property is not true 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 class ELResolver
      Parameters:
      context - The context of this evaluation.
      base - The base to analyze. Only bases of type DynaBean are handled by this resolver.
      property - The key to return the read-only status for.
      Returns:
      If the propertyResolved property of ELContext was set to true, then true if calling the setValue method will always fail or false if it is possible that such a call may succeed; otherwise undefined.
      Throws:
      NullPointerException - if context is null.
      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

      public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base)
      Returns information about the set of variables or properties that can be resolved for the given base object. One use for this method is to assist tools in auto-completion.

      If the base parameter is null, the resolver must enumerate the list of top-level variables it can resolve.

      The Iterator returned must contain zero or more instances of FeatureDescriptor, in no guaranteed order. Each info object contains information about a property in the DynaBean, as obtained by calling the DynaClass.getDynaProperties() method. The FeatureDescriptor is initialized using the same fields as are present in the DynaProperty, with the additional required named attributes "type" and "resolvableAtDesignTime" set as follows:

      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 ELResolvers will return completely accurate results, but all must be callable at both design-time and runtime (i.e. whether or not Beans.isDesignTime() returns true), without causing errors.

      The propertyResolved property of the ELContext is not relevant to this method. The results of all ELResolvers are concatenated in the case of composite resolvers.

      Specified by:
      getFeatureDescriptors in class ELResolver
      Parameters:
      context - The context of this evaluation.
      base - The base object whose set of valid properties is to be enumerated, or null 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, or null if this resolver does not handle the given base object or that the results are too complex to represent with this method
      See Also:
    • getCommonPropertyType

      public Class<?> getCommonPropertyType(ELContext context, Object base)
      If the base object is a DynaBean, returns the most general type that this resolver accepts for the property argument. Otherwise, returns null.

      Assuming the base is a DynaBean, this method will always return Object.class. This is because any object is accepted as a key and is coerced into a string.

      Specified by:
      getCommonPropertyType in class ELResolver
      Parameters:
      context - The context of this evaluation.
      base - The base to analyze. Only bases of type DynaBean are handled by this resolver.
      Returns:
      null if base is not a DynaBean; otherwise Object.class.