Class Expressions
- Since:
- 3.0.0
- Author:
- tomyeh
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ExpressionAn dummy expression that does nothing.static final FunctionMapperAn empty function mapper, i.e., it has no function defined at all.static final VariableResolverAn empty variable resolver, i.e., it has no variable defined at all. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic final Objectevaluate(XelContext ctx, String expression, Class<?> expectedType) Evaluates an expression.static final Class<? extends ExpressionFactory>Returns the implementation of the expression factory that is used by the whole system, or null to use the system default.static final ExpressionFactoryInstantiates an instance ofExpressionFactory.static final ExpressionFactorynewExpressionFactory(Class<? extends ExpressionFactory> expfcls) Instantiates an instance ofExpressionFactory.static final voidsetExpressionFactoryClass(Class<? extends ExpressionFactory> expfcls) Sets the implementation of the expression factory that shall be used by the whole system, or null to use the system default.
-
Field Details
-
EMPTY_MAPPER
An empty function mapper, i.e., it has no function defined at all. It is serializable. -
EMPTY_RESOLVER
An empty variable resolver, i.e., it has no variable defined at all. It is serializable. -
DUMMY_EXPRESSION
An dummy expression that does nothing. It is usually used as a flag to denote exceptional cases. It it serializable.
-
-
Constructor Details
-
Expressions
public Expressions()
-
-
Method Details
-
newExpressionFactory
Instantiates an instance ofExpressionFactory.The default class is
ELFactory, which supports EL 2.0. If you run under JVM 1.5 or later and deploy zel.jar in your class path, the default class is thenELFactorywhich supports EL 2.2. To override it, you can specify the class by callingsetExpressionFactoryClass(java.lang.Class<? extends org.zkoss.xel.ExpressionFactory>), or usenewExpressionFactory(Class)instead.For the ZK user, you can override it with zk.xml or org.zkoss.zk.ui.util.Configuration.
- Throws:
XelException- if the specified class failed to load, or instantiate.
-
newExpressionFactory
public static final ExpressionFactory newExpressionFactory(Class<? extends ExpressionFactory> expfcls) Instantiates an instance ofExpressionFactory.The default class is
ELFactory, which supports EL 2.0. If you run under JVM 1.5 or later and deploy zel.jar in your class path, the default class is thenELFactorywhich supports EL 2.2. To override it, you can specify the class by callingsetExpressionFactoryClass(java.lang.Class<? extends org.zkoss.xel.ExpressionFactory>), or specifying the class you prefer in the expfcls argument.For the ZK user, you can override it with zk.xml or org.zkoss.zk.ui.util.Configuration.
- Parameters:
expfcls- the class that implementsExpressionFactory, or null to use the default.- Throws:
XelException- if the specified class failed to load, or instantiate.
-
evaluate
public static final Object evaluate(XelContext ctx, String expression, Class<?> expectedType) throws XelException Evaluates an expression.- Parameters:
ctx- the context information to evaluate the expression It can be null, in which case no functions are supported for this invocation.expression- the expression to be evaluated. Note: the expression is enclosed with ${ and }, regardless of what implementation is used.expectedType- the expected type of the result of the evaluation- Throws:
XelException
-
setExpressionFactoryClass
Sets the implementation of the expression factory that shall be used by the whole system, or null to use the system default.Default: null - it means
ELFactory, which supports EL 2.0. If you run under JVM 1.5 or later and deploy zel.jar in your class path, the default class is thenELFactorywhich supports EL 2.2.Note: you can only specify an implementation that is compatible with JSP EL here, since all built-in pages depend on it.
- Parameters:
expfcls- the implementation class, or null to use the default. Note: expfcls must implementExpressionFactory. If null, the system default is used.
-
getExpressionFactoryClass
Returns the implementation of the expression factory that is used by the whole system, or null to use the system default.
-