Class ValueExpression

java.lang.Object
jakarta.el.Expression
jakarta.el.ValueExpression
All Implemented Interfaces:
Serializable

public abstract class ValueExpression extends Expression
Represents a parsed EL expression that can be evaluated to produce a value.

A value expression is created by parsing an EL expression string and can be evaluated multiple times in different contexts. It supports reading values, writing values, and introspecting the expression's type and mutability.

Since:
EL 2.1
See Also:
  • Constructor Details

    • ValueExpression

      public ValueExpression()
      Constructs a new value expression.
  • Method Details

    • getValue

      public abstract <T> T getValue(ELContext context)
      Evaluates this expression and returns the result.
      Type Parameters:
      T - The expected type for the result of evaluating this value expression
      Parameters:
      context - The EL context for this evaluation
      Returns:
      The result of evaluating this value expression
      Throws:
      NullPointerException - If the supplied context is null
      PropertyNotFoundException - If a property/variable resolution failed because no match was found or a match was found but was not readable
      ELException - Wraps any exception throw whilst resolving a property or variable
    • setValue

      public abstract void setValue(ELContext context, Object value)
      Sets the value of the property referenced by this expression.
      Parameters:
      context - The EL context for this evaluation
      value - The value to set the property to which this value expression refers
      Throws:
      NullPointerException - If the supplied context is null
      PropertyNotFoundException - If a property/variable resolution failed because no match was found
      PropertyNotWritableException - If a property/variable resolution failed because a match was found but was not writable
      ELException - Wraps any exception throw whilst resolving a property or variable
    • isReadOnly

      public abstract boolean isReadOnly(ELContext context)
      Determines whether the property referenced by this expression is read-only.
      Parameters:
      context - The EL context for this evaluation
      Returns:
      true if this expression is read only otherwise false
      Throws:
      NullPointerException - If the supplied context is null
      PropertyNotFoundException - If a property/variable resolution failed because no match was found or a match was found but was not readable
      ELException - Wraps any exception throw whilst resolving a property or variable
    • getType

      public abstract Class<?> getType(ELContext context)
      Returns the type of the result produced by evaluating this expression.
      Parameters:
      context - The EL context for this evaluation
      Returns:
      The type of the result of this value expression
      Throws:
      NullPointerException - If the supplied context is null
      PropertyNotFoundException - If a property/variable resolution failed because no match was found or a match was found but was not readable
      ELException - Wraps any exception throw whilst resolving a property or variable
    • getExpectedType

      public abstract Class<?> getExpectedType()
      Returns the expected type of the result of this expression.
      Returns:
      The expected result type, or Object.class if no specific type is expected
    • getValueReference

      public ValueReference getValueReference(ELContext context)
      Returns a reference to the resolved property for this expression.

      This default implementation always returns null. Subclasses should override this method to provide the resolved base object and property.

      Parameters:
      context - The EL context for this evaluation
      Returns:
      This default implementation always returns null
      Since:
      EL 2.2