public class JEPParser extends java.lang.Object implements ExpressionParser
JEPParser
class parses expressions using the syntax of the
Java Math Expression Parser (JEP) from http://singularsys.com/jep (we use
version 2.24 which is no longer supported since the product is now commercial).
This is the syntax that has been used by the CoastWatch Utilities
since 2003 and documented in the cwmath
tool.
Previous to this class existing, code would create a JEP instance and
use it directly for expression parsing.Note that this class is not thread-safe.
ExpressionParser.ResultType
Constructor and Description |
---|
JEPParser() |
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
evaluate(EvaluateImp evalImp)
Evaluates the expression to a primitive wrapper object.
|
double |
evaluateToDouble(EvaluateImp evalImp)
Evaluates the expression to a double value.
|
org.nfunk.jep.JEP |
getJEPObject()
Gets the JEP object used for parsing.
|
org.w3c.dom.Document |
getParseTree()
Gets a document tree corresponding to the parsed expression.
|
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.
|
boolean |
isThreadSafe()
Determines if this parser instance is thread-safe.
|
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
adapt, evaluateToBoolean, evaluateToByte, evaluateToFloat, evaluateToInt, evaluateToLong, evaluateToShort, translate
public org.nfunk.jep.JEP getJEPObject()
init(noaa.coastwatch.util.expression.ParseImp)
.public boolean isThreadSafe()
ExpressionParser
isThreadSafe
in interface ExpressionParser
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 org.w3c.dom.Document getParseTree()
ExpressionParser
getParseTree
in interface ExpressionParser
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 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