|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.rubecula.jep.TermEvaluator
This class is part of the link from JQuantity to JEP - TermEvaluator depends on JEP, but there is no dependence on the com.rubecula.jquantity package. Instead this class depends on the com.rubecula.util package.
Field Summary | |
private boolean |
_Debug
Debug flag. |
private java.util.Hashtable |
_DeclaredVariables
JEP's internal store of declared variables. |
private MillInterface |
_Mill
Mill to evaluate expressions. |
private org.nfunk.jep.type.NumberFactory |
_NumberFactory
Number Factory to create numbers from the doubles which are generated by JEP when a constant is encountered. |
private Lookupable |
_UndeclaredVariables
Store in which to lookup the current values of variables that arise in the terms of expressions. |
Constructor Summary | |
(package private) |
TermEvaluator(org.nfunk.jep.type.NumberFactory numberFactory,
MillInterface mill,
Lookupable variables)
Constructor to create a new TermEvaluator for the purpose of evaluating expressions using JQuantity objects rather than Doubles. |
Method Summary | |
Presentable |
getValue()
Mutating method to get the value of an expression (mutating because it pops the stack). |
private Presentable |
makePreciseNumber(java.lang.Object value)
|
private void |
push(Presentable value)
|
void |
setDebug(boolean debug)
|
void |
setDeclaredVariables(java.util.Hashtable variables)
|
java.lang.Object |
visit(org.nfunk.jep.ASTConstant node,
java.lang.Object data)
Method to visit a constant node. |
java.lang.Object |
visit(org.nfunk.jep.ASTFunNode node,
java.lang.Object data)
Method to visit a function node. |
java.lang.Object |
visit(org.nfunk.jep.ASTStart node,
java.lang.Object data)
Method to visit a start node. |
java.lang.Object |
visit(org.nfunk.jep.ASTVarNode node,
java.lang.Object data)
Method to visit a variable node. |
java.lang.Object |
visit(org.nfunk.jep.SimpleNode node,
java.lang.Object data)
Method to visit a simple node. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private boolean _Debug
private final org.nfunk.jep.type.NumberFactory _NumberFactory
private final MillInterface _Mill
private final Lookupable _UndeclaredVariables
private java.util.Hashtable _DeclaredVariables
Constructor Detail |
TermEvaluator(org.nfunk.jep.type.NumberFactory numberFactory, MillInterface mill, Lookupable variables) throws MillException
numberFactory
- a number factory which produces objects which are
Presentable and which are grist to the mill provided (basically this means
that they should also be BaseNumbers).mill
- a computation mill which can will operate on the kinds of
objects produced by the numberFactory (may be null, in which case an exception
will be thrown when the reference is dereferenced).variables
- a lookupable map of variables (may be null).
MillException
Method Detail |
public void setDebug(boolean debug)
public void setDeclaredVariables(java.util.Hashtable variables)
public Presentable getValue()
public java.lang.Object visit(org.nfunk.jep.SimpleNode node, java.lang.Object data)
visit
in interface org.nfunk.jep.ParserVisitor
node
- a simple node.data
- the (generic) data passed in.
public java.lang.Object visit(org.nfunk.jep.ASTStart node, java.lang.Object data)
visit
in interface org.nfunk.jep.ParserVisitor
node
- a start node.data
- the (generic) data passed in.
public java.lang.Object visit(org.nfunk.jep.ASTFunNode node, java.lang.Object data)
visit
in interface org.nfunk.jep.ParserVisitor
node
- a function node.data
- the (generic) data passed in.
public java.lang.Object visit(org.nfunk.jep.ASTVarNode node, java.lang.Object data)
_DeclaredVariables
instance field is set,
this method has the side effect of pushing the variable's value onto
the mill stack, where the key for the variable is the result of
calling getName() on the node.
visit
in interface org.nfunk.jep.ParserVisitor
node
- a variable node.data
- the (generic) data passed in.
public java.lang.Object visit(org.nfunk.jep.ASTConstant node, java.lang.Object data)
_NumberFactory
instance field is set,
this method has the side effect of pushing the constant's value onto
the mill stack, where the pushed value is a Presentable.
If _NumberFactory is unset, an exception will result, thus requiring
the JEP expression parser to evaluate the expression as it would
without JQuantity involvement.
visit
in interface org.nfunk.jep.ParserVisitor
node
- a constant node.data
- the (generic) data passed in.
private Presentable makePreciseNumber(java.lang.Object value)
private void push(Presentable value)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |