Package org.zkoss.xel.util
Class Evaluators
java.lang.Object
org.zkoss.xel.util.Evaluators
It maps a name with an evaluator implementation.
- Since:
- 3.0.0
- Author:
- tomyeh
-
Method Summary
Modifier and TypeMethodDescriptionstatic final StringAdds an evaluator (a.k.a., the expression factory,ExpressionFactory).static final StringAdds an evaluator based on the XML declaration.static final booleanTests whether the evaluator (a.k.a., the expression factory) for the specified evaluator name exists.static final Class<? extends ExpressionFactory>getEvaluatorClass(String name) Returns the implementation for the specified evaluator name.static ObjectresolveVariable(VariableResolver resolver, String name) Resolves the variable based on the specified resolver.static ObjectresolveVariable(XelContext ctx, Object base, Object name) Resolves the variable based on the specified context.static ObjectresolveVariable(XelContext ctx, VariableResolver resolver, Object base, Object name) Resolves the variable based on the the specified context and variable resolver.
-
Method Details
-
getEvaluatorClass
Returns the implementation for the specified evaluator name.- Parameters:
name- the name of the evaluator, say, MVEL.- Throws:
SystemException- if not found or the class not found.
-
exists
Tests whether the evaluator (a.k.a., the expression factory) for the specified evaluator name exists.- Parameters:
name- the name of the evaluator, say, MVEL.
-
add
Adds an evaluator (a.k.a., the expression factory,ExpressionFactory).- Parameters:
name- the name of the evaluator, say, MVEL. It is case insensitive.evalcls- the class name of the evaluator, a.k.a., the expression factory (ExpressionFactory).- Returns:
- the previous class name, or null if not defined yet
-
add
Adds an evaluator based on the XML declaration. The evaluator is also known as the expression factory,ExpressionFactory.<xel-config> <evaluator-name>SuperEL</evaluator-name><!-- case insensitive --!> <evaluator-class>my.MySuperEvaluator</evaluator-class> </xel-config>- Parameters:
config- the XML element called zscript-config- Returns:
- the previous class, or null if not defined yet
-
resolveVariable
public static Object resolveVariable(XelContext ctx, VariableResolver resolver, Object base, Object name) Resolves the variable based on the the specified context and variable resolver.- Since:
- 5.0.0
-
resolveVariable
Resolves the variable based on the specified context. If the variable resolver (XelContext.getVariableResolver()is an instance ofVariableResolverX, thenVariableResolverX.resolveVariable(XelContext,Object,Object)will be invoked.- Parameters:
ctx- the context. If null, null will be returned.- Since:
- 5.0.0
-
resolveVariable
Resolves the variable based on the specified resolver. If the resolver is an instance ofVariableResolverX, thenVariableResolverX.resolveVariable(XelContext,Object,Object)will be invoked.Notice that it is always better to invoke
resolveVariable(XelContext,Object,Object)ifXelContextis available.- Parameters:
resolver- the variable resolver. If null, null will be returned.- Since:
- 5.0.0
-