Class EvaluationContext


  • public final class EvaluationContext
    extends ELContext
    Extended EL context that wraps an existing ELContext and provides additional functionality for lambda expression evaluation.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addEvaluationListener​(EvaluationListener listener)
      Register an EvaluationListener with this ELContext.
      <T> T convertToType​(java.lang.Object obj, java.lang.Class<T> type)
      Coerce the supplied object to the requested type.
      void enterLambdaScope​(java.util.Map<java.lang.String,​java.lang.Object> arguments)
      Called when starting to evaluate a lambda expression so that the arguments are available to the EL context during evaluation.
      void exitLambdaScope()
      Called after evaluating a lambda expression to signal that the arguments are no longer required.
      java.lang.Object getContext​(java.lang.Class<?> key)
      Obtain the context object for the given key.
      ELContext getELContext()
      Returns the underlying wrapped ELContext.
      ELResolver getELResolver()
      Returns the ELResolver used to resolve properties and method invocations during expression evaluation.
      java.util.List<EvaluationListener> getEvaluationListeners()
      Obtain the list of registered EvaluationListeners.
      FunctionMapper getFunctionMapper()
      Returns the FunctionMapper used to resolve EL function names to Java methods during expression evaluation.
      ImportHandler getImportHandler()
      Obtain the ImportHandler for this ELContext, creating one if necessary.
      java.lang.Object getLambdaArgument​(java.lang.String name)
      Obtain the value of the lambda argument with the given name.
      LambdaExpressionNestedState getLambdaExpressionNestedState()
      Returns the lambda expression nested state, if this context or its wrapped context is associated with a nested lambda expression.
      java.util.Locale getLocale()
      Returns the locale associated with this EL context.
      VariableMapper getVariableMapper()
      Returns the VariableMapper used to resolve EL variable names to ValueExpression instances during expression evaluation.
      boolean isLambdaArgument​(java.lang.String name)
      Determine if the specified name is recognised as the name of a lambda argument.
      boolean isPropertyResolved()
      Returns whether a property has been resolved during the current evaluation step.
      void notifyAfterEvaluation​(java.lang.String expression)
      Notify interested listeners that an expression has been evaluated.
      void notifyBeforeEvaluation​(java.lang.String expression)
      Notify interested listeners that an expression will be evaluated.
      void notifyPropertyResolved​(java.lang.Object base, java.lang.Object property)
      Notify interested listeners that a property has been resolved.
      void putContext​(java.lang.Class<?> key, java.lang.Object contextObject)
      Add an object to this EL context under the given key.
      void setLambdaExpressionNestedState​(LambdaExpressionNestedState lambdaExpressionNestedState)
      Sets the lambda expression nested state for this context.
      void setLocale​(java.util.Locale locale)
      Sets the locale for this EL context.
      void setPropertyResolved​(boolean resolved)
      Sets the internal flag indicating whether a property has been resolved during the current evaluation step.
      void setPropertyResolved​(java.lang.Object base, java.lang.Object property)
      Mark the given property as resolved and notify any interested listeners.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • EvaluationContext

        public EvaluationContext​(ELContext elContext,
                                 FunctionMapper fnMapper,
                                 VariableMapper varMapper)
        Creates a new EvaluationContext wrapping the given ELContext.
        Parameters:
        elContext - The underlying ELContext to wrap
        fnMapper - The function mapper
        varMapper - The variable mapper
    • Method Detail

      • getELContext

        public ELContext getELContext()
        Returns the underlying wrapped ELContext.
        Returns:
        the wrapped ELContext
      • getFunctionMapper

        public FunctionMapper getFunctionMapper()
        Description copied from class: jakarta.el.ELContext
        Returns the FunctionMapper used to resolve EL function names to Java methods during expression evaluation.
        Specified by:
        getFunctionMapper in class ELContext
        Returns:
        the FunctionMapper for this context
      • getContext

        public java.lang.Object getContext​(java.lang.Class<?> key)
        Description copied from class: jakarta.el.ELContext
        Obtain the context object for the given key.
        Overrides:
        getContext in class ELContext
        Parameters:
        key - The key of the required context object
        Returns:
        The value of the context object associated with the given key
      • getELResolver

        public ELResolver getELResolver()
        Description copied from class: jakarta.el.ELContext
        Returns the ELResolver used to resolve properties and method invocations during expression evaluation.
        Specified by:
        getELResolver in class ELContext
        Returns:
        the ELResolver for this context
      • isPropertyResolved

        public boolean isPropertyResolved()
        Description copied from class: jakarta.el.ELContext
        Returns whether a property has been resolved during the current evaluation step. ELResolver implementations call ELContext.setPropertyResolved(boolean) to indicate resolution, and the expression evaluator checks this flag to determine if resolution was successful.
        Overrides:
        isPropertyResolved in class ELContext
        Returns:
        true if a property has been resolved, false otherwise
      • putContext

        public void putContext​(java.lang.Class<?> key,
                               java.lang.Object contextObject)
        Description copied from class: jakarta.el.ELContext
        Add an object to this EL context under the given key.
        Overrides:
        putContext in class ELContext
        Parameters:
        key - The key under which to store the object
        contextObject - The object to add
      • setPropertyResolved

        public void setPropertyResolved​(boolean resolved)
        Description copied from class: jakarta.el.ELContext
        Sets the internal flag indicating whether a property has been resolved during the current evaluation step. This method is used by ELResolver implementations to signal that they have handled the current base/property combination.
        Overrides:
        setPropertyResolved in class ELContext
        Parameters:
        resolved - true if a property has been resolved, false otherwise
      • getLocale

        public java.util.Locale getLocale()
        Description copied from class: jakarta.el.ELContext
        Returns the locale associated with this EL context. The locale is used for type conversion operations such as parsing numbers and dates during expression evaluation.
        Overrides:
        getLocale in class ELContext
        Returns:
        the locale for this context, or null if not set
      • setLocale

        public void setLocale​(java.util.Locale locale)
        Description copied from class: jakarta.el.ELContext
        Sets the locale for this EL context. The locale is used for type conversion operations such as parsing numbers and dates during expression evaluation.
        Overrides:
        setLocale in class ELContext
        Parameters:
        locale - the locale to use for this context
      • setPropertyResolved

        public void setPropertyResolved​(java.lang.Object base,
                                        java.lang.Object property)
        Description copied from class: jakarta.el.ELContext
        Mark the given property as resolved and notify any interested listeners.
        Overrides:
        setPropertyResolved in class ELContext
        Parameters:
        base - The base object on which the property was found
        property - The property that was resolved
      • getImportHandler

        public ImportHandler getImportHandler()
        Description copied from class: jakarta.el.ELContext
        Obtain the ImportHandler for this ELContext, creating one if necessary. This method is not thread-safe.
        Overrides:
        getImportHandler in class ELContext
        Returns:
        the ImportHandler for this ELContext.
      • notifyBeforeEvaluation

        public void notifyBeforeEvaluation​(java.lang.String expression)
        Description copied from class: jakarta.el.ELContext
        Notify interested listeners that an expression will be evaluated.
        Overrides:
        notifyBeforeEvaluation in class ELContext
        Parameters:
        expression - The expression that will be evaluated
      • notifyAfterEvaluation

        public void notifyAfterEvaluation​(java.lang.String expression)
        Description copied from class: jakarta.el.ELContext
        Notify interested listeners that an expression has been evaluated.
        Overrides:
        notifyAfterEvaluation in class ELContext
        Parameters:
        expression - The expression that was evaluated
      • notifyPropertyResolved

        public void notifyPropertyResolved​(java.lang.Object base,
                                           java.lang.Object property)
        Description copied from class: jakarta.el.ELContext
        Notify interested listeners that a property has been resolved.
        Overrides:
        notifyPropertyResolved in class ELContext
        Parameters:
        base - The object on which the property was resolved
        property - The property that was resolved
      • isLambdaArgument

        public boolean isLambdaArgument​(java.lang.String name)
        Description copied from class: jakarta.el.ELContext
        Determine if the specified name is recognised as the name of a lambda argument.
        Overrides:
        isLambdaArgument in class ELContext
        Parameters:
        name - The name of the lambda argument
        Returns:
        true if the name is recognised as the name of a lambda argument, otherwise false
      • getLambdaArgument

        public java.lang.Object getLambdaArgument​(java.lang.String name)
        Description copied from class: jakarta.el.ELContext
        Obtain the value of the lambda argument with the given name.
        Overrides:
        getLambdaArgument in class ELContext
        Parameters:
        name - The name of the lambda argument
        Returns:
        The value of the specified argument
      • enterLambdaScope

        public void enterLambdaScope​(java.util.Map<java.lang.String,​java.lang.Object> arguments)
        Description copied from class: jakarta.el.ELContext
        Called when starting to evaluate a lambda expression so that the arguments are available to the EL context during evaluation.
        Overrides:
        enterLambdaScope in class ELContext
        Parameters:
        arguments - The arguments in scope for the current lambda expression.
      • exitLambdaScope

        public void exitLambdaScope()
        Description copied from class: jakarta.el.ELContext
        Called after evaluating a lambda expression to signal that the arguments are no longer required.
        Overrides:
        exitLambdaScope in class ELContext
      • convertToType

        public <T> T convertToType​(java.lang.Object obj,
                                   java.lang.Class<T> type)
        Description copied from class: jakarta.el.ELContext
        Coerce the supplied object to the requested type.
        Overrides:
        convertToType in class ELContext
        Type Parameters:
        T - The type to which the object should be coerced
        Parameters:
        obj - The object to be coerced
        type - The type to which the object should be coerced
        Returns:
        An instance of the requested type.
      • getLambdaExpressionNestedState

        public LambdaExpressionNestedState getLambdaExpressionNestedState()
        Returns the lambda expression nested state, if this context or its wrapped context is associated with a nested lambda expression.
        Returns:
        the lambda expression nested state, or null if none
      • setLambdaExpressionNestedState

        public void setLambdaExpressionNestedState​(LambdaExpressionNestedState lambdaExpressionNestedState)
        Sets the lambda expression nested state for this context.
        Parameters:
        lambdaExpressionNestedState - The lambda expression nested state
        Throws:
        java.lang.IllegalStateException - if a nested state has already been set