Interface JexlContext
-
- All Known Subinterfaces:
JexlContext.ThreadLocal
- All Known Implementing Classes:
JexlEngine.EmptyContext,JexlScriptEngine.JexlContextWrapper,MapContext,ObjectContext
public interface JexlContextManages variables which can be referenced in a JEXL expression.JEXL variable names in their simplest form are 'java-like' identifiers. JEXL also considers 'ant' inspired variables expressions as valid. For instance, the expression 'x.y.z' is an 'antish' variable and will be resolved as a whole by the context, i.e. using the key "x.y.z". This proves to be useful to solve "fully qualified class names".
The interpreter variable resolution algorithm will try the different sequences of identifiers till it finds one that exists in the context; if "x" is an object known in the context (JexlContext.has("x") returns true), "x.y" will not be looked up in the context but will most likely refer to "x.getY()".
Note that JEXL may use '$jexl' and '$ujexl' variables for internal purpose; setting or getting those variables may lead to unexpected results unless specified otherwise.
- Since:
- 1.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceJexlContext.AnnotationProcessorA marker interface of the JexlContext that processes annotations.static interfaceJexlContext.CancellationHandleA marker interface of the JexlContext sharing a cancelling flag.static interfaceJexlContext.ClassNameResolverA marker interface that solves a simple class name into a fully-qualified one.static interfaceJexlContext.ModuleProcessorA marker interface of the JexlContext that processes module definitions.static interfaceJexlContext.NamespaceFunctorA marker interface of the JexlContext, NamespaceFunctor allows creating an instance to delegate namespace methods calls to.static interfaceJexlContext.NamespaceResolverA marker interface of the JexlContext that declares how to resolve a namespace from its name; it is used by the interpreter during evaluation.static interfaceJexlContext.OptionsHandleA marker interface of the JexlContext that exposes runtime evaluation options.static interfaceJexlContext.PragmaProcessorA marker interface of the JexlContext that processes pragmas.static interfaceJexlContext.ThreadLocalA marker interface of theJexlContextthat indicates the interpreter to put this context in theJexlEnginethread local context instance during evaluation.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.Objectget(java.lang.String name)Gets the value of a variable.booleanhas(java.lang.String name)Checks whether a variable is defined in this context.voidset(java.lang.String name, java.lang.Object value)Sets the value of a variable.
-
-
-
Method Detail
-
get
java.lang.Object get(java.lang.String name)
Gets the value of a variable.- Parameters:
name- the variable's name.- Returns:
- the value.
-
has
boolean has(java.lang.String name)
Checks whether a variable is defined in this context.A variable may be defined with a null value; this method checks whether the value is null or if the variable is undefined.
- Parameters:
name- the variable's name.- Returns:
- true if it exists, false otherwise.
-
set
void set(java.lang.String name, java.lang.Object value)Sets the value of a variable.- Parameters:
name- the variable's name.value- the variable's value.
-
-