|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectchemaxon.nfunk.jep.JEP
chemaxon.jep.ChemJEP
public class ChemJEP
Expression parser and evaluator for chemical expressions.
| Field Summary | |
|---|---|
static int |
FALSE
Logical result value: FALSE. |
static int |
TRUE
Logical result value: TRUE. |
static int |
UNDECIDED
Logical result value: UNDECIDED. |
| Fields inherited from class chemaxon.nfunk.jep.JEP |
|---|
allowUndeclared, errorList, funTab, implicitMul, symTab |
| Constructor Summary | |
|---|---|
ChemJEP()
Constructor. |
|
ChemJEP(java.lang.Class contextClass)
Constructor. |
|
| Method Summary | |
|---|---|
void |
addFunction(java.lang.String name,
chemaxon.nfunk.jep.function.PostfixMathCommandI function)
Adds a new function to the parser. |
java.lang.Object |
callback(java.lang.String method,
java.lang.Object arg)
Delegates CallbackIface.callback(String, Object)
to the context. |
void |
compile(java.lang.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[]. |
java.lang.Object |
evaluate(ChemContext context)
Evaluates the expression. |
static int |
getLogicalValue(java.lang.Object result)
Returns the logical correspondent of the specified result object: TRUE, FALSE or UNDECIDED. |
static boolean |
isUndecided(java.lang.Object result)
Returns whether the result object is undecided. |
protected void |
setSymbolTable(chemaxon.nfunk.jep.SymbolTable symTab)
Sets the SymbolTable object. |
| Methods inherited from class chemaxon.nfunk.jep.JEP |
|---|
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, setTraverse |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int FALSE
public static final int TRUE
public static final int UNDECIDED
| Constructor Detail |
|---|
public ChemJEP()
throws chemaxon.nfunk.jep.ParseException
chemaxon.nfunk.jep.ParseException - on error
public ChemJEP(java.lang.Class contextClass)
throws chemaxon.nfunk.jep.ParseException
contextClass - is the context class
chemaxon.nfunk.jep.ParseException - on error| Method Detail |
|---|
public void addFunction(java.lang.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 function
chemaxon.nfunk.jep.ParseException - if there exists a function with the same nameprotected void setSymbolTable(chemaxon.nfunk.jep.SymbolTable symTab)
symTab - is the SymbolTable object
public void compile(java.lang.String expression)
throws chemaxon.nfunk.jep.ParseException
expression - is the expression string
chemaxon.nfunk.jep.ParseException - on compile error
public java.lang.Object callback(java.lang.String method,
java.lang.Object arg)
CallbackIface.callback(String, Object)
to the context.
callback in interface chemaxon.marvin.util.CallbackIfacemethod - is the method namearg - is the method argument
public java.lang.Object evaluate(ChemContext context)
throws chemaxon.nfunk.jep.ParseException
compile(String expression).
context - is the evaluation context
chemaxon.nfunk.jep.ParseException - on evaluation error
public 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 context
EvaluationException - on evaluation error
chemaxon.nfunk.jep.ParseException
public 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 context
EvaluationException - on evaluation error
chemaxon.nfunk.jep.ParseException
public 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 context
EvaluationException - on evaluation error
chemaxon.nfunk.jep.ParseException
public 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 context
EvaluationException - on evaluation error
chemaxon.nfunk.jep.ParseExceptionpublic static int getLogicalValue(java.lang.Object result)
TRUE, FALSE or UNDECIDED.
result - is the result object
public static boolean isUndecided(java.lang.Object result)
true if the result is undecided
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||