public class ChemJEP
extends chemaxon.nfunk.jep.JEP
implements chemaxon.marvin.util.CallbackIface
| Modifier and Type | Field and Description |
|---|---|
static int |
FALSE
Logical result value: FALSE.
|
static int |
TRUE
Logical result value: TRUE.
|
static int |
UNDECIDED
Logical result value: UNDECIDED.
|
| Constructor and Description |
|---|
ChemJEP()
Constructor.
|
ChemJEP(Class contextClass)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addFunction(String name,
chemaxon.nfunk.jep.function.PostfixMathCommandI function)
Adds a new function to the parser.
|
Object |
callback(String method,
Object arg)
Delegates
CallbackIface.callback(String, Object)
to the context. |
void |
compile(String expression)
Compiles the expression string to an inner structure.
|
boolean |
evaluate_boolean(ChemContext context)
Evaluates the expression and converts the result
boolean. |
boolean[] |
evaluate_booleans(ChemContext context)
Evaluates the expression and converts the result to
boolean[]. |
double |
evaluate_double(ChemContext context)
Evaluates the expression and converts the result to
double. |
double[] |
evaluate_doubles(ChemContext context)
Evaluates the expression and converts the result to
double[]. |
Object |
evaluate(ChemContext context)
Evaluates the expression.
|
static int |
getLogicalValue(Object result)
|
static boolean |
isUndecided(Object result)
Returns whether the result object is undecided.
|
protected void |
setSymbolTable(chemaxon.nfunk.jep.SymbolTable symTab)
Sets the SymbolTable object.
|
addComplex, addComplexVariable, addError, addStandardConstants, addStandardFunctions, addVariable, addVariableAsObject, getComplexValue, getError, getErrorCount, getErrorInfo, getErrors, getFunction, getNumberFactory, getSymbolTable, getTopNode, getValue, getValueAsObject, hasError, initFunTab, initSymTab, parseExpression, removeFunction, removeVariable, setAllowUndeclared, setImplicitMul, setTraversepublic static final int FALSE
public static final int TRUE
public static final int UNDECIDED
public ChemJEP()
throws chemaxon.nfunk.jep.ParseException
chemaxon.nfunk.jep.ParseException - on errorpublic ChemJEP(Class contextClass) throws chemaxon.nfunk.jep.ParseException
contextClass - is the context classchemaxon.nfunk.jep.ParseException - on errorpublic void addFunction(String name, chemaxon.nfunk.jep.function.PostfixMathCommandI function) throws chemaxon.nfunk.jep.ParseException
addFunction in class chemaxon.nfunk.jep.JEPname - is the name of the functionfunction - is the function object that is used for evaluating the functionchemaxon.nfunk.jep.ParseException - if there exists a function with the same nameprotected void setSymbolTable(chemaxon.nfunk.jep.SymbolTable symTab)
symTab - is the SymbolTable objectpublic void compile(String expression) throws chemaxon.nfunk.jep.ParseException
expression - is the expression stringchemaxon.nfunk.jep.ParseException - on compile errorpublic Object callback(String method, Object arg)
CallbackIface.callback(String, Object)
to the context.callback in interface chemaxon.marvin.util.CallbackIfacemethod - is the method namearg - is the method argumentpublic Object evaluate(ChemContext context) throws chemaxon.nfunk.jep.ParseException
compile(String expression).context - is the evaluation contextchemaxon.nfunk.jep.ParseException - on evaluation errorpublic double evaluate_double(ChemContext context) throws chemaxon.nfunk.jep.ParseException
double.
The expression string must have been given
and compiled beforehand by compile(String expression).context - is the evaluation contextEvaluationException - on evaluation errorchemaxon.nfunk.jep.ParseExceptionpublic double[] evaluate_doubles(ChemContext context) throws chemaxon.nfunk.jep.ParseException
double[].
This is useful if the result is an object array in which case each element
is converted to double.
The expression string must have been given
and compiled beforehand by compile(String expression).context - is the evaluation contextEvaluationException - on evaluation errorchemaxon.nfunk.jep.ParseExceptionpublic boolean evaluate_boolean(ChemContext context) throws chemaxon.nfunk.jep.ParseException
boolean.
Boolean return values are returned as double: 1.0 for true
and 0.0 for false. This function returns true for a value
greater than 0.5, false otherwise. This means that for
boolean expressions the return value will be OK (and we also
eliminated floating-point comparison inaccuracy :-).
The expression string must have been given
and compiled beforehand by compile(String expression).context - is the evaluation contextEvaluationException - on evaluation errorchemaxon.nfunk.jep.ParseExceptionpublic boolean[] evaluate_booleans(ChemContext context) throws chemaxon.nfunk.jep.ParseException
boolean[].
This is useful if the result is an object array in which case each element
is converted to boolean.
The expression string must have been given
and compiled beforehand by compile(String expression).context - is the evaluation contextEvaluationException - on evaluation errorchemaxon.nfunk.jep.ParseExceptionpublic static int getLogicalValue(Object result)
result - is the result objectpublic static boolean isUndecided(Object result)
true if the result is undecided