public class ELEvaluator extends Object
It provides a more convenient way of using the JSP EL Evaluator.
Modifier and Type | Class and Description |
---|---|
static class |
ELEvaluator.Context
Provides functions and variables for the EL evaluator.
|
Constructor and Description |
---|
ELEvaluator()
Creates an ELEvaluator with no functions and no variables defined.
|
ELEvaluator(ELEvaluator.Context context)
Creates an ELEvaluator with the functions and variables defined in the given
ELEvaluator.Context . |
Modifier and Type | Method and Description |
---|---|
boolean |
checkForExistence(String expr,
String sequence)
Check if the input expression contains sequence statically.
|
<T> T |
evaluate(String expr,
Class<T> clazz)
Evaluate an EL expression.
|
ELEvaluator.Context |
getContext()
Return the context with the functions and variables of the EL evaluator.
|
static ELEvaluator |
getCurrent()
If within the scope of a EL evaluation call, it gives access to the ELEvaluator instance performing the EL
evaluation.
|
Object |
getVariable(String name)
Convenience method that returns a variable from the EL evaluator context.
|
void |
setVariable(String name,
Object value)
Convenience method that sets a variable in the EL evaluator context.
|
public ELEvaluator()
public ELEvaluator(ELEvaluator.Context context)
ELEvaluator.Context
. context
- the ELSupport with functions and variables to be available for EL evalution.public static ELEvaluator getCurrent()
This is useful for EL function methods to get access to the variables of the Evaluator. Because of this, ELEvaluator variables can be used to pass context to EL function methods (which must be static methods).
null
if none.public ELEvaluator.Context getContext()
public void setVariable(String name, Object value)
name
- variable name.value
- variable value.public Object getVariable(String name)
name
- variable name.null
if not defined.public <T> T evaluate(String expr, Class<T> clazz) throws Exception
T
- the return type of the expressionexpr
- EL expression to evaluate.clazz
- return type of the EL expression.Exception
- thrown if an EL function failed due to a transient error or EL expression could not be
evaluated.public boolean checkForExistence(String expr, String sequence) throws Exception
expr
- - Expression stringsequence
- - char sequence to check in the input expressionException
- Exception thrown if an EL function failed due to a
transient error or EL expression could not be parsedCopyright © 2018 Apache Software Foundation. All rights reserved.