|
|||||||||
| Home >> All >> [ exptree overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
exptree
Class expressionTree

java.lang.Objectexptree.expressionTree
- All Implemented Interfaces:
- java.io.Serializable
- public class expressionTree
- extends java.lang.Object
- implements java.io.Serializable
- extends java.lang.Object
Handles mathematic expressions in a tree structure, including storage, evaluation, and display. Will eventually provide the functionality to manipulate the tree as well.
- Version:
- 1.1 08/19/2000
| Field Summary | |
(package private) boolean |
cacheable
|
(package private) double |
cachedValue
Holds the cached value for this branch. |
(package private) exptree.operators.operatorInterface |
operator
Holds the operator for this node of the tree. |
(package private) expressionTree[] |
params
Holds parameters to this node's operator. |
| Constructor Summary | |
expressionTree()
Creates a new expressionTree |
|
expressionTree(expressionTree[] prms,
exptree.operators.operatorInterface op)
Creates a new expressionTree with operator op and parameters prms[] |
|
| Method Summary | |
void |
buildCache()
Builds a cache for this branch. |
double |
evaluate()
Evaluate the expressionTree, returning the result as a double. |
expressionTree |
getClone(exptree.utilities.variablePackage v)
Convenience method to retrieve a clone of expressionTree as type expressionTree. |
java.lang.String |
getName()
Returns the name of this node's operator. |
int |
getNumParams()
Returns the number of parameters this node expects. |
exptree.operators.operatorInterface |
getOperator()
Returns the operator this node holds. |
int |
getParamLength()
Returns the number of parameter's this node's operator expects. |
expressionTree[] |
getParams()
Returns the parameters this node is holding. |
boolean |
isCacheable()
Determines if this branch of the tree is cacheable (ie, the value never changes). |
void |
setOperator(exptree.operators.operatorInterface o)
Sets this node's operator. |
void |
setParams(expressionTree[] p)
Set this node's parameters. |
java.lang.String |
toString()
Returns a (sort of) human readable string representation of the expression. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
params
expressionTree[] params
- Holds parameters to this node's operator.
operator
exptree.operators.operatorInterface operator
- Holds the operator for this node of the tree.
cachedValue
double cachedValue
- Holds the cached value for this branch.
cacheable
boolean cacheable
| Constructor Detail |
expressionTree
public expressionTree()
- Creates a new expressionTree
expressionTree
public expressionTree(expressionTree[] prms, exptree.operators.operatorInterface op)
- Creates a new expressionTree with operator op and parameters prms[]
| Method Detail |
getClone
public expressionTree getClone(exptree.utilities.variablePackage v)
- Convenience method to retrieve a clone of expressionTree as type expressionTree.
evaluate
public double evaluate()
- Evaluate the expressionTree, returning the result as a double.
toString
public java.lang.String toString()
- Returns a (sort of) human readable string representation of the expression.
The resulting string contains the expression written in prefix notation. For example,
The simple equation "1+1" would be written as "+(1, 1)". This notation is
somewhat unusual, but is the closest written notation to this class' internal representation
of the expression.
getName
public java.lang.String getName()
- Returns the name of this node's operator.
getParamLength
public int getParamLength()
- Returns the number of parameter's this node's operator expects.
setParams
public void setParams(expressionTree[] p)
- Set this node's parameters.
Note: Currently does not check that p[] has the correct number of
elements. If p[] has too many elements, the extras are simply thrown out.
If, however, there are too few, the results are unpredicatable.
This behavior should be modified in future versions to be more robust.
getNumParams
public int getNumParams()
- Returns the number of parameters this node expects.
getParams
public expressionTree[] getParams()
- Returns the parameters this node is holding.
getOperator
public exptree.operators.operatorInterface getOperator()
- Returns the operator this node holds.
setOperator
public void setOperator(exptree.operators.operatorInterface o)
- Sets this node's operator.
Note: If the new operator expects more parameters than
the current operator, results are unpredicatable.
This behaviour should be modified in future version to be more robust.
isCacheable
public boolean isCacheable()
- Determines if this branch of the tree is cacheable (ie, the value never changes).
A side effect of calling this function is that a cache is built.
buildCache
public void buildCache()
- Builds a cache for this branch. Simply calls the isCacheable() method, throwing away its
return value.
|
|||||||||
| Home >> All >> [ exptree overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
exptree.expressionTree