Interface JexlScript
-
public interface JexlScript
A JEXL Script.A script is some valid JEXL syntax to be executed with a given set of
JexlContext
variables.A script is a group of statements, separated by semicolons.
The statements can be
blocks
(curly braces containing code), Control statements such asif
andwhile
as well as expressions and assignment statements.Do not create classes that implement this interface; delegate or compose instead.
- Since:
- 1.1
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.util.concurrent.Callable<java.lang.Object>
callable(JexlContext context)
Creates a Callable from this script.java.util.concurrent.Callable<java.lang.Object>
callable(JexlContext context, java.lang.Object... args)
Creates a Callable from this script.JexlScript
curry(java.lang.Object... args)
Curries this script, returning a script with bound arguments.java.lang.Object
execute(JexlContext context)
Executes the script with the variables contained in the suppliedJexlContext
.java.lang.Object
execute(JexlContext context, java.lang.Object... args)
Executes the script with the variables contained in the suppliedJexlContext
and a set of arguments corresponding to the parameters used during parsing.java.lang.String[]
getLocalVariables()
Gets this script local variables.java.lang.String[]
getParameters()
Gets this script parameters.java.lang.String
getParsedText()
Recreates the source text of this expression from the internal syntactic tree.java.lang.String
getParsedText(int indent)
Recreates the source text of this expression from the internal syntactic tree.java.util.Map<java.lang.String,java.lang.Object>
getPragmas()
Gets this script pragmas.java.lang.String
getSourceText()
Returns the source text of this expression.java.lang.String[]
getUnboundParameters()
Gets this script unbound parameters.java.util.Set<java.util.List<java.lang.String>>
getVariables()
Gets this script variables.
-
-
-
Method Detail
-
callable
java.util.concurrent.Callable<java.lang.Object> callable(JexlContext context)
Creates a Callable from this script.This allows to submit it to an executor pool and provides support for asynchronous calls.
The interpreter will handle interruption/cancellation gracefully if needed.
- Parameters:
context
- the context- Returns:
- the callable
- Since:
- 2.1
-
callable
java.util.concurrent.Callable<java.lang.Object> callable(JexlContext context, java.lang.Object... args)
Creates a Callable from this script.This allows to submit it to an executor pool and provides support for asynchronous calls.
The interpreter will handle interruption/cancellation gracefully if needed.
- Parameters:
context
- the contextargs
- the script arguments- Returns:
- the callable
- Since:
- 2.1
-
curry
JexlScript curry(java.lang.Object... args)
Curries this script, returning a script with bound arguments.If this script does not declare parameters or if all of them are already bound, no error is generated and this script is returned.
- Parameters:
args
- the arguments to bind- Returns:
- the curried script or this script if no binding can occur
-
execute
java.lang.Object execute(JexlContext context)
Executes the script with the variables contained in the suppliedJexlContext
.- Parameters:
context
- A JexlContext containing variables.- Returns:
- The result of this script, usually the result of the last statement.
-
execute
java.lang.Object execute(JexlContext context, java.lang.Object... args)
Executes the script with the variables contained in the suppliedJexlContext
and a set of arguments corresponding to the parameters used during parsing.- Parameters:
context
- A JexlContext containing variables.args
- the arguments- Returns:
- The result of this script, usually the result of the last statement.
- Since:
- 2.1
-
getLocalVariables
java.lang.String[] getLocalVariables()
Gets this script local variables.- Returns:
- the local variables or null
- Since:
- 2.1
-
getParameters
java.lang.String[] getParameters()
Gets this script parameters.- Returns:
- the parameters or null
- Since:
- 2.1
-
getParsedText
java.lang.String getParsedText()
Recreates the source text of this expression from the internal syntactic tree.- Returns:
- the source text
-
getParsedText
java.lang.String getParsedText(int indent)
Recreates the source text of this expression from the internal syntactic tree.- Parameters:
indent
- the number of spaces for indentation, 0 meaning no indentation- Returns:
- the source text
-
getPragmas
java.util.Map<java.lang.String,java.lang.Object> getPragmas()
Gets this script pragmas.- Returns:
- the (non null, may be empty) pragmas map
-
getSourceText
java.lang.String getSourceText()
Returns the source text of this expression.- Returns:
- the source text
-
getUnboundParameters
java.lang.String[] getUnboundParameters()
Gets this script unbound parameters.Parameters that haven't been bound by a previous call to curry().
- Returns:
- the parameters or null
- Since:
- 3.2
-
getVariables
java.util.Set<java.util.List<java.lang.String>> getVariables()
Gets this script variables.Note that since variables can be in an ant-ish form (ie foo.bar.quux), each variable is returned as a list of strings where each entry is a fragment of the variable ({"foo", "bar", "quux"} in the example.
- Returns:
- the variables or null
- Since:
- 2.1
-
-