|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--com.rubecula.jep.ExpressionParser
This class is the link from JQuantity to JEP - ExpressionParser depends on JEP, but depends only the com.rubecula.util package from the JQuantity project. There is no dependence on com.rubecula.jquantity, either compile-time or dynamic, in this class -- the only reference is in the main (testing) program (as an example of usage).
| Constructor Summary | |
ExpressionParser()
Constructor to create a new expression parser using both JEP and JQuantity. |
|
| Method Summary | |
java.lang.Double |
addVariable(java.lang.String string,
double value)
Method to add a predefined variable to the JEP expression parser. |
Presentable |
evaluate(java.lang.Object parseTree)
Method to evaluate the result of parsing an expression. |
java.lang.String |
getIdentifier()
Method to get the specific identifier for an object. |
static void |
main(java.lang.String[] args)
Main program for testing purposes only. |
java.lang.Object |
parse(java.lang.String expression)
Method to parse an expression and return a reference to the parse tree. |
void |
setDebug(boolean debug)
Method to set the debug flag for this instance to the value of debug. |
void |
setMillFactory(MillFactoryInterface millFactory)
Method to setup the mill factory for the evaluation of expressions, in particular monadic, dyadic operations, pushing and popping of values. |
void |
setVariables(Lookupable variables)
Method to setup the variables map for allowing variables to be dealt with in expressions. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public ExpressionParser()
JQuantityFactory.
| Method Detail |
public static void main(java.lang.String[] args)
MillFactory for its computation mill.
args - the command line arguments (each argument is an
an expression to be parsed and evaluated).public java.lang.String getIdentifier()
getIdentifier in interface Identifiablepublic void setMillFactory(MillFactoryInterface millFactory)
setMillFactory in interface ExpressionInterfacemillFactory - a factory for creating mills with which to evaluate
expressions.public void setVariables(Lookupable variables)
setVariables in interface ExpressionInterfacevariables - a map of variables, so that they can be looked up (may be null,
in which case undeclared variables are not enabled for this expression parser).
public java.lang.Double addVariable(java.lang.String string,
double value)
addVariable in interface ExpressionInterfacestring - the name of the variablevalue - the desired value of the variable.
public void setDebug(boolean debug)
setDebug in interface ExpressionInterfacedebug - true or false.public java.lang.Object parse(java.lang.String expression)
parse in interface ExpressionInterfaceexpression - a mathematical expression to parse.
public Presentable evaluate(java.lang.Object parseTree)
throws PresentableException
evaluate in interface ExpressionInterfaceparseTree - the result of previously calling parse(String).
PresentableException - if the result of parsing was an error.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||