Package noaa.coastwatch.util.expression
Class JELParser
java.lang.Object
noaa.coastwatch.util.expression.JELParser
- All Implemented Interfaces:
ExpressionParser
The
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.- Since:
- 3.4.0
- Author:
- Peter Hollemans
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Implements a number of additional constants and methods for JEL expressions to use.Nested classes/interfaces inherited from interface noaa.coastwatch.util.expression.ExpressionParser
ExpressionParser.ResultType
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adapts the parsed expression to a specific result type.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.Gets the result data type.Gets the list of variables used in the expression.void
Initializes this parser with the specified implementation.static void
Tests this class.void
Parses the specified expression.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface noaa.coastwatch.util.expression.ExpressionParser
getParseTree, isThreadSafe, translate
-
Constructor Details
-
JELParser
public JELParser()
-
-
Method Details
-
init
Description copied from interface:ExpressionParser
Initializes this parser with the specified implementation.- Specified by:
init
in interfaceExpressionParser
- Parameters:
parseImp
- the parser implementation to use for variable information during parsing.
-
parse
Description copied from interface:ExpressionParser
Parses the specified expression.- Specified by:
parse
in interfaceExpressionParser
- Parameters:
expr
- the expression to parse.
-
adapt
Description copied from interface:ExpressionParser
Adapts the parsed expression to a specific result type.- Specified by:
adapt
in interfaceExpressionParser
- Parameters:
type
- the result type to adapt the expression. The result type of the parser is set to the specified type.
-
getResultType
Description copied from interface:ExpressionParser
Gets the result data type.- Specified by:
getResultType
in interfaceExpressionParser
- Returns:
- the result data type.
-
getVariables
Description copied from interface:ExpressionParser
Gets the list of variables used in the expression.- Specified by:
getVariables
in interfaceExpressionParser
- Returns:
- the list of variable names.
-
evaluate
Description copied from interface:ExpressionParser
Evaluates the expression to a primitive wrapper object.- Specified by:
evaluate
in interfaceExpressionParser
- Parameters:
evalImp
- the evalutation implementation that provides variable values.- Returns:
- the result value in a wrapper.
-
evaluateToBoolean
Description copied from interface:ExpressionParser
Evaluates the expression to a boolean value.- Specified by:
evaluateToBoolean
in interfaceExpressionParser
- Parameters:
evalImp
- the evalutation implementation that provides variable values.- Returns:
- the boolean valued result, or false if the result type is not a boolean.
-
evaluateToByte
Description copied from interface:ExpressionParser
Evaluates the expression to a byte value.- Specified by:
evaluateToByte
in interfaceExpressionParser
- Parameters:
evalImp
- the evalutation implementation that provides variable values.- Returns:
- the byte valued result, or zero if the result is not a byte.
-
evaluateToShort
Description copied from interface:ExpressionParser
Evaluates the expression to a short value.- Specified by:
evaluateToShort
in interfaceExpressionParser
- Parameters:
evalImp
- the evalutation implementation that provides variable values.- Returns:
- the short valued result, or zero if the result is not a short.
-
evaluateToInt
Description copied from interface:ExpressionParser
Evaluates the expression to an int value.- Specified by:
evaluateToInt
in interfaceExpressionParser
- Parameters:
evalImp
- the evalutation implementation that provides variable values.- Returns:
- the int valued result, or zero if the result is not an int.
-
evaluateToLong
Description copied from interface:ExpressionParser
Evaluates the expression to a long value.- Specified by:
evaluateToLong
in interfaceExpressionParser
- Parameters:
evalImp
- the evalutation implementation that provides variable values.- Returns:
- the long valued result, or zero if the result is not a long.
-
evaluateToFloat
Description copied from interface:ExpressionParser
Evaluates the expression to a float value.- Specified by:
evaluateToFloat
in interfaceExpressionParser
- Parameters:
evalImp
- the evalutation implementation that provides variable values.- Returns:
- the float valued result, or zero if the result is not a float.
-
evaluateToDouble
Description copied from interface:ExpressionParser
Evaluates the expression to a double value.- Specified by:
evaluateToDouble
in interfaceExpressionParser
- Parameters:
evalImp
- the evalutation implementation that provides variable values.- Returns:
- the double valued result, or zero if the result is not a double.
-
main
Tests this class.- Parameters:
argv
- the array of command line parameters.- Throws:
Exception
-