|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.el.ExpressionFactory
de.odysseus.el.ExpressionFactoryImpl
public class ExpressionFactoryImpl
Expression factory implementation.
This class is also used as an EL "service provider".
The JUEL jar files specify this class as their expression factory
implementation in META-INF/services/javax.el.ExpressionFactory
.
Calling ExpressionFactory#getExpressionFactory()
will then return
an instance of this class, configured as described below.
The default constructor loads properties from resources
JAVA_HOME/lib/el.properties
-
If this file exists and if it contains property javax.el.ExpressionFactory
whose value is the name of this class, these properties are taken as default properties.
el.properties
on your classpath. These properties override the
properties from JAVA_HOME/lib/el.properties
.
Properties
.
Having this, the following properties are read:
javax.el.cacheSize
- cache size (int, default is 1000)
javax.el.methodInvocations
- allow method invocations
as in ${foo.bar(baz)}
(boolean, default is false
).
javax.el.nullProperties
- resolve null
properties
as in ${foo[null]}
(boolean, default is false
).
Constructor Summary | |
---|---|
ExpressionFactoryImpl()
Create a new expression factory using the default parser and tree cache implementations. |
|
ExpressionFactoryImpl(java.util.Properties properties)
Create a new expression factory using the default builder and cache implementations. |
|
ExpressionFactoryImpl(TreeStore store)
Create a new expression factory. |
Method Summary | |
---|---|
java.lang.Object |
coerceToType(java.lang.Object obj,
java.lang.Class<?> targetType)
Coerces an object to a specific type according to the EL type conversion rules. |
TreeMethodExpression |
createMethodExpression(ELContext context,
java.lang.String expression,
java.lang.Class<?> expectedReturnType,
java.lang.Class<?>[] expectedParamTypes)
Parses an expression into a MethodExpression for later
evaluation. |
protected TreeStore |
createTreeStore(int defaultCacheSize,
java.util.Properties properties)
Create the factory's tree store. |
TreeValueExpression |
createValueExpression(ELContext context,
java.lang.String expression,
java.lang.Class<?> expectedType)
Parses an expression into a ValueExpression for later
evaluation. |
ObjectValueExpression |
createValueExpression(java.lang.Object instance,
java.lang.Class<?> expectedType)
Creates a ValueExpression that wraps an object instance. |
Methods inherited from class javax.el.ExpressionFactory |
---|
newInstance, newInstance |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ExpressionFactoryImpl()
el.properties
(see above).
The maximum cache size will be 1000 unless overridden in el.properties
.
public ExpressionFactoryImpl(java.util.Properties properties)
javax.el.cacheSize
.
properties
- used to initialize builder and cache (may be null
)public ExpressionFactoryImpl(TreeStore store)
store
- the tree store used to parse and cache parse trees.Method Detail |
---|
protected TreeStore createTreeStore(int defaultCacheSize, java.util.Properties properties)
javax.el.cacheSize
.
public final java.lang.Object coerceToType(java.lang.Object obj, java.lang.Class<?> targetType)
ExpressionFactory
An ELException
is thrown if an error results from
applying the conversion rules.
coerceToType
in class ExpressionFactory
obj
- The object to coerce.targetType
- The target type for the coercion.public final ObjectValueExpression createValueExpression(java.lang.Object instance, java.lang.Class<?> expectedType)
ExpressionFactory
getValue()
method, optionally coerced.
createValueExpression
in class ExpressionFactory
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,public final TreeValueExpression createValueExpression(ELContext context, java.lang.String expression, java.lang.Class<?> expectedType)
ExpressionFactory
ValueExpression
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
.
createValueExpression
in class ExpressionFactory
context
- The EL context used to parse the expression.
The 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 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 parseexpectedType
- The type the result of the expression
will be coerced to after evaluation.
public final TreeMethodExpression createMethodExpression(ELContext context, java.lang.String expression, java.lang.Class<?> expectedReturnType, java.lang.Class<?>[] expectedParamTypes)
ExpressionFactory
MethodExpression
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
.
createMethodExpression
in class ExpressionFactory
context
- The EL context used to parse the expression.
The 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.
expression
- The expression to parseexpectedReturnType
- The expected return type for the method
to be found. After evaluating the expression, the
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.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 pass null
.
|
Copyright © 2006, 2007 Odysseus Software GmbH. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |