Classes that implement the Jakarta Expression Language expression language expose their functionality via this abstract class. An implementation supports the following functionalities.
String into a ValueExpression or MethodExpression instance for later
evaluation.ELResolver for query operators
The newInstance method can be used to obtain an instance of the implementation. Technologies such as
Jakarta Server Pages and Jakarta Faces provide access to an implementation via factory methods.
The createValueExpression method is used to parse expressions that evaluate to values (both l-values and
r-values are supported). The createMethodExpression method is used to parse expressions that evaluate to a
reference to a method on an object.
Resolution of model objects is performed at evaluation time, via the ELResolver associated with the
ELContext passed to the ValueExpression or MethodExpression.
The ELContext object also provides access to the FunctionMapper and VariableMapper to be used when
parsing the expression. Jakarta Expression Language function and variable mapping is performed at parse-time, and the
results are bound to the expression. Therefore, the ELContext, FunctionMapper, and
VariableMapper are not stored for future use and do not have to be Serializable.
The createValueExpression and createMethodExpression methods must be thread-safe. That is,
multiple threads may call these methods on the same ExpressionFactory object simultaneously.
Implementations should synchronize access if they depend on transient state. Implementations should not, however,
assume that only one object of each ExpressionFactory type will be instantiated; global caching should
therefore be static.
The ExpressionFactory must be able to handle the following types of input for the
expression parameter:
${} delimiter (e.g. "${employee.lastName}").#{} delimiter (e.g. "#{employee.lastName}").${} or #{} delimiters (e.g. "John Doe")."${employee.firstName}${employee.lastName}" or
"#{employee.firstName}#{employee.lastName}")."Name: ${employee.firstName} ${employee.lastName}").
The following types of input are illegal and must cause an ELException to be thrown:
"${employee.firstName}#{employee.lastName}")."Name: ${employee.firstName} #{employee.lastName}").| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public abstract <T> T | Returns: an object coerced totargetTypeThe object to coerce. obj, Class<T> The target type for the coercion. targetType)Coerces an object to a specific type according to the Jakarta Expression Language type conversion rules. |
| public abstract MethodExpression | Returns: The parsed expressionThe Jakarta Expression Language context used to parse the expression. The context, String FunctionMapper
and VariableMapper stored in the ELContext are used to resolve functions and variables found in the
expression. They can be null, 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 provided FunctionMapper and VariableMapper instances change
between calling ExpressionFactory.createMethodExpression() and any method on
MethodExpression. 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.The expression to parse expression, Class<?> The expected return type for the method to be found. After evaluating the expression, the
expectedReturnType, Class<?>[] MethodExpression must check that the return type of the actual method matches this type. Passing in a
value of null indicates the caller does not care what the return type is, and the check is disabled.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 pass expectedParamTypes)null, 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.Parses an expression into a |
| public abstract ValueExpression | Returns: The parsed expressionThe Jakarta Expression Language context used to parse the expression. The context, String FunctionMapper
and VariableMapper stored in the ELContext are used to resolve functions and variables found in the
expression. They can be null, 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 provided FunctionMapper and VariableMapper instances change
between calling ExpressionFactory.createValueExpression() and any method on
ValueExpression. 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.The expression to parse expression, Class<?> The type the result of the expression will be coerced to after evaluation. expectedType)Parses an expression into a |
| public abstract ValueExpression | Returns: a ValueExpression that wraps an object instanceThe object instance to be wrapped. instance, Class<?> The type the result of the expression will be coerced to after evaluation. There will be no
coercion if it is Object.class, expectedType)Creates a ValueExpression that wraps an object instance. |
| public Map | Returns: A initial map for functions, null if there is none.Retrieve a function map containing a pre-configured function mapping. |
| public ELResolver | Returns: TheELResolver that implements the Query Operators.Retrieves an ELResolver that implements the operations in collections. |
| public static ExpressionFactory | Returns: a newExpressionFactory instanceCreates a new instance of a |
| public static ExpressionFactory | Returns: a newExpressionFactory instanceProperties passed to the implementation. If null, then no properties. properties)Create a new instance of a |
| ExpressionFactory | back to summary |
|---|---|
| public ExpressionFactory() | |
| coerceToType | back to summary |
|---|---|
| public abstract <T> T coerceToType(Object obj, Class<T> targetType) Coerces an object to a specific type according to the Jakarta Expression Language type conversion rules. The custom
type conversions in the
An
| |
| createMethodExpression | back to summary |
|---|---|
| public abstract MethodExpression createMethodExpression(ELContext context, String expression, Class<?> expectedReturnType, Class<?>[] expectedParamTypes) Parses an expression into a
If the expression is a String literal, a
This method should perform syntactic validation of the expression. If in doing so it detects errors, it should raise
an
| |
| createValueExpression | back to summary |
|---|---|
| public abstract ValueExpression createValueExpression(ELContext context, String expression, Class<?> expectedType) Parses an expression into a
This method should perform syntactic validation of the expression. If in doing so it detects errors, it should raise
an
| |
| createValueExpression | back to summary |
|---|---|
| public abstract ValueExpression createValueExpression(Object instance, Class<?> expectedType) 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
| |
| getInitFunctionMap | back to summary |
|---|---|
| public Map Retrieve a function map containing a pre-configured function mapping. | |
| getStreamELResolver | back to summary |
|---|---|
| public ELResolver getStreamELResolver() Retrieves an ELResolver that implements the operations in collections.
This ELResolver resolves the method invocation on the pair ( See the specification document for detailed descriptions of these operators, their arguments, and return values.
| |
| newInstance | back to summary |
|---|---|
| public static ExpressionFactory newInstance() Creates a new instance of a
| |
| newInstance | back to summary |
|---|---|
| public static ExpressionFactory newInstance(Properties properties) Create a new instance of a
This method uses the same lookup procedure as the one used in
If the argument Properties are optional and can be ignored by an implementation. The name of a property should start with "jakarta.el." The following are some suggested names for properties.
| |