Package jakarta.el

Class RecordELResolver

java.lang.Object
jakarta.el.ELResolver
jakarta.el.RecordELResolver

public class RecordELResolver extends ELResolver
Defines property resolution behavior on instances of Record.

The resolver handles base objects of type Record. It accepts any non-null object as a property and coerces it to a String using Object.toString(). The property string is used to find an accessor method for a field with the same name.

This resolver is always read-only since Records are always read-only.

ELResolvers are combined together using CompositeELResolvers to define rich semantics for evaluating an expression. See the javadocs for ELResolver for details.

  • Constructor Details

    • RecordELResolver

      public RecordELResolver()
  • Method Details

    • getValue

      public Object getValue(ELContext context, Object base, Object property)
      If the base object is an instance of Record, returns the value of the given field of this Record.

      If the base object is an instance of Record, the propertyResolved property of the provided ELContext 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.

      Specified by:
      getValue in class ELResolver
      Parameters:
      context - The context of this evaluation.
      base - The Record on which to get the property.
      property - The property to get. Will be coerced to a String.
      Returns:
      If the propertyResolved property of the provided ELContext was set to true then the value of the given property. Otherwise, undefined.
      Throws:
      NullPointerException - if the provided ELContext is null.
      PropertyNotFoundException - if the base is an instance of Record and the specified property does not exist.
      ELException - if an exception was throws while performing the property resolution. The thrown exception must be included as the cause of this exception, if available.
    • getType

      public Class<?> getType(ELContext context, Object base, Object property)
      If the base object is an instance of Record, always returns null since Records are always read-only.

      If the base object is an instance of Record, the propertyResolved property of the provided ELContext 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.

      Specified by:
      getType in class ELResolver
      Parameters:
      context - The context of this evaluation.
      base - The Record to analyze.
      property - The name of the property to analyze. Will be coerced to a String.
      Returns:
      Always null
      Throws:
      NullPointerException - if the provided ELContext is null.
      PropertyNotFoundException - if the base is an instance of Record and the specified property does not exist.
    • setValue

      public void setValue(ELContext context, Object base, Object property, Object value)
      If the base object is an instance of Record, always throws an exception since Records are read-only.

      If the base object is an instance of Record, the propertyResolved property of the provided ELContext 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.

      Specified by:
      setValue in class ELResolver
      Parameters:
      context - The context of this evaluation.
      base - The Record on which to set the property.
      property - The name of the property to set. Will be coerced to a String.
      value - The value to set the property or variable to.
      Throws:
      NullPointerException - if the provided ELContext is null.
      PropertyNotFoundException - if the base is an instance of Record and the specified property does not exist.
      PropertyNotWritableException - if the base is an instance of Record and the specified property exists.
    • isReadOnly

      public boolean isReadOnly(ELContext context, Object base, Object property)
      If the base object is an instance of Record, always returns true.

      If the base object is an instance of Record, the propertyResolved property of the provided ELContext 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.

      Specified by:
      isReadOnly in class ELResolver
      Parameters:
      context - The context of this evaluation.
      base - The Record to analyze.
      property - The name of the property to analyze. Will be coerced to a String.
      Returns:
      If the propertyResolved property of ELContext was set to true, then true if the property is read-only or false if not; otherwise undefined.
      Throws:
      NullPointerException - if the provided ELContext is null.
      PropertyNotFoundException - if the base is an instance of Record and the specified property does not exist.
    • getCommonPropertyType

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

      If the base object is an instance of Record this method will always return Object since any object is accepted for the property argument and coerced to a String.

      Specified by:
      getCommonPropertyType in class ELResolver
      Parameters:
      context - The context of this evaluation.
      base - The Record to analyze.
      Returns:
      Object is base is an instance of Record, otherwise null.