public class JELParser extends java.lang.Object implements ExpressionParser
JELParser
class parses expressions using the Java
Expressions Library (JEL) by Konstantin L. Metlov available from
https://www.gnu.org/software/jel. The syntax follows the
Java Language Specification and includes the full set of java.lang.Math
static methods and other useful constants and methods.Modifier and Type | Class and Description |
---|---|
static class |
JELParser.ExtrasLibrary
Implements a number of additional constants and methods for
JEL expressions to use.
|
ExpressionParser.ResultType
Constructor and Description |
---|
JELParser() |
Modifier and Type | Method and Description |
---|---|
void |
adapt(ExpressionParser.ResultType type)
Adapts the parsed expression to a specific result type.
|
java.lang.Object |
evaluate(EvaluateImp evalImp)
Evaluates the expression to a primitive wrapper object.
|
boolean |
evaluateToBoolean(EvaluateImp evalImp)
Evaluates the expression to a boolean value.
|
byte |
evaluateToByte(EvaluateImp evalImp)
Evaluates the expression to a byte value.
|
double |
evaluateToDouble(EvaluateImp evalImp)
Evaluates the expression to a double value.
|
float |
evaluateToFloat(EvaluateImp evalImp)
Evaluates the expression to a float value.
|
int |
evaluateToInt(EvaluateImp evalImp)
Evaluates the expression to an int value.
|
long |
evaluateToLong(EvaluateImp evalImp)
Evaluates the expression to a long value.
|
short |
evaluateToShort(EvaluateImp evalImp)
Evaluates the expression to a short value.
|
ExpressionParser.ResultType |
getResultType()
Gets the result data type.
|
java.util.List<java.lang.String> |
getVariables()
Gets the list of variables used in the expression.
|
void |
init(ParseImp parseImp)
Initializes this parser with the specified implementation.
|
static void |
main(java.lang.String[] argv)
Tests this class.
|
void |
parse(java.lang.String expr)
Parses the specified expression.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getParseTree, isThreadSafe, translate
public void init(ParseImp parseImp)
ExpressionParser
init
in interface ExpressionParser
parseImp
- the parser implementation to use for variable information
during parsing.public void parse(java.lang.String expr)
ExpressionParser
parse
in interface ExpressionParser
expr
- the expression to parse.public void adapt(ExpressionParser.ResultType type)
ExpressionParser
adapt
in interface ExpressionParser
type
- the result type to adapt the expression. The result
type of the parser is set to the specified type.public ExpressionParser.ResultType getResultType()
ExpressionParser
getResultType
in interface ExpressionParser
public java.util.List<java.lang.String> getVariables()
ExpressionParser
getVariables
in interface ExpressionParser
public java.lang.Object evaluate(EvaluateImp evalImp)
ExpressionParser
evaluate
in interface ExpressionParser
evalImp
- the evalutation implementation that provides variable
values.public boolean evaluateToBoolean(EvaluateImp evalImp)
ExpressionParser
evaluateToBoolean
in interface ExpressionParser
evalImp
- the evalutation implementation that provides variable
values.public byte evaluateToByte(EvaluateImp evalImp)
ExpressionParser
evaluateToByte
in interface ExpressionParser
evalImp
- the evalutation implementation that provides variable
values.public short evaluateToShort(EvaluateImp evalImp)
ExpressionParser
evaluateToShort
in interface ExpressionParser
evalImp
- the evalutation implementation that provides variable
values.public int evaluateToInt(EvaluateImp evalImp)
ExpressionParser
evaluateToInt
in interface ExpressionParser
evalImp
- the evalutation implementation that provides variable
values.public long evaluateToLong(EvaluateImp evalImp)
ExpressionParser
evaluateToLong
in interface ExpressionParser
evalImp
- the evalutation implementation that provides variable
values.public float evaluateToFloat(EvaluateImp evalImp)
ExpressionParser
evaluateToFloat
in interface ExpressionParser
evalImp
- the evalutation implementation that provides variable
values.public double evaluateToDouble(EvaluateImp evalImp)
ExpressionParser
evaluateToDouble
in interface ExpressionParser
evalImp
- the evalutation implementation that provides variable
values.public static void main(java.lang.String[] argv) throws java.lang.Exception
argv
- the array of command line parameters.java.lang.Exception