Class ExpressionFactoryImpl
- Version:
- $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: kchung $
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncoerceToType
(Object obj, Class<?> type) Coerces an object to a specific type according to the Jakarta Expression Language type conversion rules.createMethodExpression
(ELContext context, String expression, Class<?> expectedReturnType, Class<?>[] expectedParamTypes) Parses an expression into aMethodExpression
for later evaluation.createValueExpression
(ELContext context, String expression, Class<?> expectedType) Parses an expression into aValueExpression
for later evaluation.createValueExpression
(Object instance, Class<?> expectedType) Creates a ValueExpression that wraps an object instance.Retrieve a function map containing a pre-configured function mapping.getProperty
(String key) Retrieves an ELResolver that implements the operations in collections.Methods inherited from class jakarta.el.ExpressionFactory
newInstance, newInstance
-
Field Details
-
properties
-
isBackwardCompatible22
private boolean isBackwardCompatible22
-
-
Constructor Details
-
ExpressionFactoryImpl
public ExpressionFactoryImpl() -
ExpressionFactoryImpl
-
-
Method Details
-
coerceToType
Coerces an object to a specific type according to the Jakarta Expression Language type conversion rules. The custom type conversions in theELResolver
s are not considered. Jakarta Expression Language version 2.2 backward compatibility conversion rules apply if ExpressionFactoryImpl was created with property "jakarta.el.bc2.2" set to true.- Specified by:
coerceToType
in classExpressionFactory
- Parameters:
obj
- The object to coerce.type
- The target type for the coercion.- Returns:
- an object coerced to
targetType
-
createMethodExpression
public MethodExpression createMethodExpression(ELContext context, String expression, Class<?> expectedReturnType, Class<?>[] expectedParamTypes) Description copied from class:ExpressionFactory
Parses an expression into aMethodExpression
for later evaluation. Use this method for expressions that refer to methods.If the expression is a String literal, a
MethodExpression
is created, which when invoked, returns the String literal, coerced to expectedReturnType. An ELException is thrown if expectedReturnType is void or if the coercion of the String literal to the expectedReturnType yields an error (see Section "1.16 Type Conversion").This method should perform syntactic validation of the expression. If in doing so it detects errors, it should raise an
ELException
.- Specified by:
createMethodExpression
in classExpressionFactory
- Parameters:
context
- The Jakarta Expression Language context used to parse the expression. TheFunctionMapper
andVariableMapper
stored in the ELContext are used to resolve functions and variables found in the expression. They can benull
, in which case functions or variables are not supported for this expression. The object returned must invoke the same functions and access the same variable mappings regardless of whether the mappings in the providedFunctionMapper
andVariableMapper
instances change between callingExpressionFactory.createMethodExpression()
and any method onMethodExpression
. Note that within the EL, the ${} and #{} syntaxes are treated identically. This includes the use of VariableMapper and FunctionMapper at expression creation time. Each is invoked if not null, independent of whether the #{} or ${} syntax is used for the expression.expression
- The expression to parseexpectedReturnType
- The expected return type for the method to be found. After evaluating the expression, theMethodExpression
must check that the return type of the actual method matches this type. Passing in a value ofnull
indicates the caller does not care what the return type is, and the check is disabled.expectedParamTypes
- The expected parameter types for the method to be found. Must be an array with no elements if there are no parameters expected. It is illegal to passnull
, unless the method is specified with arguments in the Jakarta Expression Language expression, in which case these arguments are used for method selection, and this parameter is ignored.- Returns:
- The parsed expression
-
createValueExpression
public ValueExpression createValueExpression(ELContext context, String expression, Class<?> expectedType) Description copied from class:ExpressionFactory
Parses an expression into aValueExpression
for later evaluation. Use this method for expressions that refer to values.This method should perform syntactic validation of the expression. If in doing so it detects errors, it should raise an
ELException
.- Specified by:
createValueExpression
in classExpressionFactory
- Parameters:
context
- The Jakarta Expression Language context used to parse the expression. TheFunctionMapper
andVariableMapper
stored in the ELContext are used to resolve functions and variables found in the expression. They can benull
, in which case functions or variables are not supported for this expression. The object returned must invoke the same functions and access the same variable mappings regardless of whether the mappings in the providedFunctionMapper
andVariableMapper
instances change between callingExpressionFactory.createValueExpression()
and any method onValueExpression
. Note that within Jakarta Expression Language, the ${} and #{} syntaxes are treated identically. This includes the use of VariableMapper and FunctionMapper at expression creation time. Each is invoked if not null, independent of whether the #{} or ${} syntax is used for the expression.expression
- The expression to parseexpectedType
- The type the result of the expression will be coerced to after evaluation.- Returns:
- The parsed expression
-
createValueExpression
Description copied from class:ExpressionFactory
Creates a ValueExpression that wraps an object instance.This method can be used to pass any object as a ValueExpression. The wrapper ValueExpression is read only, and returns the wrapped object via its
getValue()
method, optionally coerced.- Specified by:
createValueExpression
in classExpressionFactory
- Parameters:
instance
- The object instance to be wrapped.expectedType
- The type the result of the expression will be coerced to after evaluation. There will be no coercion if it is Object.class,- Returns:
- a ValueExpression that wraps an object instance
-
getProperty
-
getStreamELResolver
Description copied from class:ExpressionFactory
Retrieves an ELResolver that implements the operations in collections.This ELResolver resolves the method invocation on the pair (
base
,property
) whenbase
is aCollection
or aMap
, andproperty
is the name of the operation.See the specification document for detailed descriptions of these operators, their arguments, and return values.
- Overrides:
getStreamELResolver
in classExpressionFactory
- Returns:
- The
ELResolver
that implements the Query Operators.
-
getInitFunctionMap
Description copied from class:ExpressionFactory
Retrieve a function map containing a pre-configured function mapping.- Overrides:
getInitFunctionMap
in classExpressionFactory
- Returns:
- A initial map for functions, null if there is none.
-