Class EvaluationContext
java.lang.Object
jakarta.el.ELContext
org.apache.el.lang.EvaluationContext
Extended EL context that wraps an existing ELContext and provides additional
functionality for lambda expression evaluation.
-
Constructor Summary
ConstructorsConstructorDescriptionEvaluationContext(ELContext elContext, FunctionMapper fnMapper, VariableMapper varMapper) Creates a new EvaluationContext wrapping the given ELContext. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddEvaluationListener(EvaluationListener listener) Register an EvaluationListener with this ELContext.<T> TconvertToType(Object obj, Class<T> type) Coerce the supplied object to the requested type.voidenterLambdaScope(Map<String, Object> arguments) Called when starting to evaluate a lambda expression so that the arguments are available to the EL context during evaluation.voidCalled after evaluating a lambda expression to signal that the arguments are no longer required.getContext(Class<?> key) Obtain the context object for the given key.Returns the underlying wrapped ELContext.Returns the ELResolver used to resolve properties and method invocations during expression evaluation.Obtain the list of registered EvaluationListeners.Returns the FunctionMapper used to resolve EL function names to Java methods during expression evaluation.Obtain the ImportHandler for this ELContext, creating one if necessary.getLambdaArgument(String name) Obtain the value of the lambda argument with the given name.Returns the lambda expression nested state, if this context or its wrapped context is associated with a nested lambda expression.Returns the locale associated with this EL context.Returns the VariableMapper used to resolve EL variable names toValueExpressioninstances during expression evaluation.booleanisLambdaArgument(String name) Determine if the specified name is recognised as the name of a lambda argument.booleanReturns whether a property has been resolved during the current evaluation step.voidnotifyAfterEvaluation(String expression) Notify interested listeners that an expression has been evaluated.voidnotifyBeforeEvaluation(String expression) Notify interested listeners that an expression will be evaluated.voidnotifyPropertyResolved(Object base, Object property) Notify interested listeners that a property has been resolved.voidputContext(Class<?> key, Object contextObject) Add an object to this EL context under the given key.voidsetLambdaExpressionNestedState(LambdaExpressionNestedState lambdaExpressionNestedState) Sets the lambda expression nested state for this context.voidSets the locale for this EL context.voidsetPropertyResolved(boolean resolved) Sets the internal flag indicating whether a property has been resolved during the current evaluation step.voidsetPropertyResolved(Object base, Object property) Mark the given property as resolved and notify any interested listeners.
-
Constructor Details
-
EvaluationContext
Creates a new EvaluationContext wrapping the given ELContext.- Parameters:
elContext- The underlying ELContext to wrapfnMapper- The function mappervarMapper- The variable mapper
-
-
Method Details
-
getELContext
Returns the underlying wrapped ELContext.- Returns:
- the wrapped ELContext
-
getFunctionMapper
Description copied from class:jakarta.el.ELContextReturns the FunctionMapper used to resolve EL function names to Java methods during expression evaluation.- Specified by:
getFunctionMapperin classELContext- Returns:
- the FunctionMapper for this context
-
getVariableMapper
Description copied from class:jakarta.el.ELContextReturns the VariableMapper used to resolve EL variable names toValueExpressioninstances during expression evaluation.- Specified by:
getVariableMapperin classELContext- Returns:
- the VariableMapper for this context
-
getContext
Description copied from class:jakarta.el.ELContextObtain the context object for the given key.- Overrides:
getContextin classELContext- Parameters:
key- The key of the required context object- Returns:
- The value of the context object associated with the given key
-
getELResolver
Description copied from class:jakarta.el.ELContextReturns the ELResolver used to resolve properties and method invocations during expression evaluation.- Specified by:
getELResolverin classELContext- Returns:
- the ELResolver for this context
-
isPropertyResolved
public boolean isPropertyResolved()Description copied from class:jakarta.el.ELContextReturns whether a property has been resolved during the current evaluation step. ELResolver implementations callELContext.setPropertyResolved(boolean)to indicate resolution, and the expression evaluator checks this flag to determine if resolution was successful.- Overrides:
isPropertyResolvedin classELContext- Returns:
trueif a property has been resolved,falseotherwise
-
putContext
Description copied from class:jakarta.el.ELContextAdd an object to this EL context under the given key.- Overrides:
putContextin classELContext- Parameters:
key- The key under which to store the objectcontextObject- The object to add
-
setPropertyResolved
public void setPropertyResolved(boolean resolved) Description copied from class:jakarta.el.ELContextSets the internal flag indicating whether a property has been resolved during the current evaluation step. This method is used byELResolverimplementations to signal that they have handled the current base/property combination.- Overrides:
setPropertyResolvedin classELContext- Parameters:
resolved-trueif a property has been resolved,falseotherwise
-
getLocale
Description copied from class:jakarta.el.ELContextReturns the locale associated with this EL context. The locale is used for type conversion operations such as parsing numbers and dates during expression evaluation. -
setLocale
Description copied from class:jakarta.el.ELContextSets the locale for this EL context. The locale is used for type conversion operations such as parsing numbers and dates during expression evaluation. -
setPropertyResolved
Description copied from class:jakarta.el.ELContextMark the given property as resolved and notify any interested listeners.- Overrides:
setPropertyResolvedin classELContext- Parameters:
base- The base object on which the property was foundproperty- The property that was resolved
-
getImportHandler
Description copied from class:jakarta.el.ELContextObtain the ImportHandler for this ELContext, creating one if necessary. This method is not thread-safe.- Overrides:
getImportHandlerin classELContext- Returns:
- the ImportHandler for this ELContext.
-
addEvaluationListener
Description copied from class:jakarta.el.ELContextRegister an EvaluationListener with this ELContext.- Overrides:
addEvaluationListenerin classELContext- Parameters:
listener- The EvaluationListener to register
-
getEvaluationListeners
Description copied from class:jakarta.el.ELContextObtain the list of registered EvaluationListeners.- Overrides:
getEvaluationListenersin classELContext- Returns:
- A list of the EvaluationListener registered with this ELContext
-
notifyBeforeEvaluation
Description copied from class:jakarta.el.ELContextNotify interested listeners that an expression will be evaluated.- Overrides:
notifyBeforeEvaluationin classELContext- Parameters:
expression- The expression that will be evaluated
-
notifyAfterEvaluation
Description copied from class:jakarta.el.ELContextNotify interested listeners that an expression has been evaluated.- Overrides:
notifyAfterEvaluationin classELContext- Parameters:
expression- The expression that was evaluated
-
notifyPropertyResolved
Description copied from class:jakarta.el.ELContextNotify interested listeners that a property has been resolved.- Overrides:
notifyPropertyResolvedin classELContext- Parameters:
base- The object on which the property was resolvedproperty- The property that was resolved
-
isLambdaArgument
Description copied from class:jakarta.el.ELContextDetermine if the specified name is recognised as the name of a lambda argument.- Overrides:
isLambdaArgumentin classELContext- Parameters:
name- The name of the lambda argument- Returns:
trueif the name is recognised as the name of a lambda argument, otherwisefalse
-
getLambdaArgument
Description copied from class:jakarta.el.ELContextObtain the value of the lambda argument with the given name.- Overrides:
getLambdaArgumentin classELContext- Parameters:
name- The name of the lambda argument- Returns:
- The value of the specified argument
-
enterLambdaScope
Description copied from class:jakarta.el.ELContextCalled when starting to evaluate a lambda expression so that the arguments are available to the EL context during evaluation.- Overrides:
enterLambdaScopein classELContext- Parameters:
arguments- The arguments in scope for the current lambda expression.
-
exitLambdaScope
public void exitLambdaScope()Description copied from class:jakarta.el.ELContextCalled after evaluating a lambda expression to signal that the arguments are no longer required.- Overrides:
exitLambdaScopein classELContext
-
convertToType
Description copied from class:jakarta.el.ELContextCoerce the supplied object to the requested type.- Overrides:
convertToTypein classELContext- Type Parameters:
T- The type to which the object should be coerced- Parameters:
obj- The object to be coercedtype- The type to which the object should be coerced- Returns:
- An instance of the requested type.
-
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
nullif none
-
setLambdaExpressionNestedState
Sets the lambda expression nested state for this context.- Parameters:
lambdaExpressionNestedState- The lambda expression nested state- Throws:
IllegalStateException- if a nested state has already been set
-