Package com.graphbuilder.math
Class Expression
java.lang.Object
com.graphbuilder.math.Expression
The class from which all nodes of an expression tree are descendents. Expressions can be evaluated
using the eval method. Expressions that are or have FuncNodes or VarNodes as descendents must provide
a VarMap or FuncMap respectively. Expressions that consist entirely of OpNodes and ValNodes do not
require a VarMap or FuncMap. For Expressions that support children (OpNodes, FuncNodes), a child can
only be accepted provided it currently has no parent, a cyclic reference is not formed, and it is
non-null.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidProtected method used to verify that the specified expression can be included as a child expression of this node.abstract doubleReturns the result of evaluating the expression tree rooted at this node.String[]Returns an array of exact length of the function names contained in the expression tree rooted at this node.Returns the parent of this node.String[]Returns an array of exact length of the variable names contained in the expression tree rooted at this node.booleanReturns true if this node is a descendent of the specified node, false otherwise.toString()Returns a string that represents the expression tree rooted at this node.
-
Field Details
-
parent
-
-
Constructor Details
-
Expression
public Expression()
-
-
Method Details
-
eval
Returns the result of evaluating the expression tree rooted at this node. -
isDescendent
Returns true if this node is a descendent of the specified node, false otherwise. By this methods definition, a node is a descendent of itself. -
getParent
Returns the parent of this node. Returns null if this node is the root node of an expression-tree. -
checkBeforeAccept
Protected method used to verify that the specified expression can be included as a child expression of this node. An expression cannot be included as a child if it is null, it currently has a parent, or a cyclic reference would be formed.- Throws:
IllegalArgumentException- If the specified expression is not accepted.
-
getVariableNames
Returns an array of exact length of the variable names contained in the expression tree rooted at this node. -
getFunctionNames
Returns an array of exact length of the function names contained in the expression tree rooted at this node. -
toString
Returns a string that represents the expression tree rooted at this node.
-