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
Nested ClassesModifier and TypeClassDescriptionstatic classImplements 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdapts the parsed expression to a specific result type.evaluate(EvaluateImp evalImp) Evaluates the expression to a primitive wrapper object.booleanevaluateToBoolean(EvaluateImp evalImp) Evaluates the expression to a boolean value.byteevaluateToByte(EvaluateImp evalImp) Evaluates the expression to a byte value.doubleevaluateToDouble(EvaluateImp evalImp) Evaluates the expression to a double value.floatevaluateToFloat(EvaluateImp evalImp) Evaluates the expression to a float value.intevaluateToInt(EvaluateImp evalImp) Evaluates the expression to an int value.longevaluateToLong(EvaluateImp evalImp) Evaluates the expression to a long value.shortevaluateToShort(EvaluateImp evalImp) Evaluates the expression to a short value.Gets the result data type.Gets the list of variables used in the expression.getVariableType(String name) Gets the variable type used in the expression.voidInitializes this parser with the specified implementation.static voidTests this class.voidParses the specified expression.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface noaa.coastwatch.util.expression.ExpressionParser
getParseTree, isThreadSafe, translate
-
Constructor Details
-
JELParser
public JELParser()
-
-
Method Details
-
init
Description copied from interface:ExpressionParserInitializes this parser with the specified implementation.- Specified by:
initin interfaceExpressionParser- Parameters:
parseImp- the parser implementation to use for variable information during parsing.
-
parse
Description copied from interface:ExpressionParserParses the specified expression.- Specified by:
parsein interfaceExpressionParser- Parameters:
expr- the expression to parse.
-
adapt
Description copied from interface:ExpressionParserAdapts the parsed expression to a specific result type.- Specified by:
adaptin 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:ExpressionParserGets the result data type.- Specified by:
getResultTypein interfaceExpressionParser- Returns:
- the result data type.
-
getVariables
Description copied from interface:ExpressionParserGets the list of variables used in the expression.- Specified by:
getVariablesin interfaceExpressionParser- Returns:
- the list of variable names.
-
getVariableType
Description copied from interface:ExpressionParserGets the variable type used in the expression.- Specified by:
getVariableTypein interfaceExpressionParser- Parameters:
name- the variable name from the list returned byExpressionParser.getVariables().- Returns:
- the variable class name: Byte, Short, Integer, Long, Float, or Double. The returned value is null if the variable type is unknown.
-
evaluate
Description copied from interface:ExpressionParserEvaluates the expression to a primitive wrapper object.- Specified by:
evaluatein interfaceExpressionParser- Parameters:
evalImp- the evalutation implementation that provides variable values.- Returns:
- the result value in a wrapper.
-
evaluateToBoolean
Description copied from interface:ExpressionParserEvaluates the expression to a boolean value.- Specified by:
evaluateToBooleanin 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:ExpressionParserEvaluates the expression to a byte value.- Specified by:
evaluateToBytein 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:ExpressionParserEvaluates the expression to a short value.- Specified by:
evaluateToShortin 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:ExpressionParserEvaluates the expression to an int value.- Specified by:
evaluateToIntin 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:ExpressionParserEvaluates the expression to a long value.- Specified by:
evaluateToLongin 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:ExpressionParserEvaluates the expression to a float value.- Specified by:
evaluateToFloatin 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:ExpressionParserEvaluates the expression to a double value.- Specified by:
evaluateToDoublein 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
-