Interface ExpressionNode
- All Superinterfaces:
Cloneable
- All Known Implementing Classes:
ConstantNode, FunctionNode, OperatorNode, VariableNode
Name: ExpressionNode
Description: Common interface implemented by different nodes of an expression tree
Date: 08/dic/06 Time: 14:28:56
- Version:
- 1.0
- Author:
- Bertoli Marco
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final int -
Method Summary
Modifier and TypeMethodDescriptionclone()Clones current nodeintcount()Counts number of nodes in current subtreeReturns children nodes of this node, ordered from leftmost to rightmost.intgetDepth()Returns depth of current subtreeReturns more information on node typeintgetType()Returns type of nodedoublegetValue()Returns value of target nodevoidsetVariable(String name, double value) Sets the value for a variabletoString()Returns a string describing the entire tree
-
Field Details
-
CONSTANT_NODE
static final int CONSTANT_NODE- See Also:
-
VARIABLE_NODE
static final int VARIABLE_NODE- See Also:
-
OPERATOR_NODE
static final int OPERATOR_NODE- See Also:
-
FUNCTION_NODE
static final int FUNCTION_NODE- See Also:
-
-
Method Details
-
getValue
double getValue()Returns value of target node- Returns:
- value of node
-
setVariable
Sets the value for a variable- Parameters:
name- name of the variable to be setvalue- value for the variable
-
getType
int getType()Returns type of node- Returns:
- CONSTANT_NODE, VARIABLE_NODE, OPERATOR_NODE, FUNCTION_NODE
-
getSubtype
String getSubtype()Returns more information on node type- Returns:
- name of node function or operator symbol
-
getDepth
int getDepth()Returns depth of current subtree- Returns:
- depth of the tree
-
count
int count()Counts number of nodes in current subtree- Returns:
- number of nodes (included root)
-
getChildrenNodes
ExpressionNode[] getChildrenNodes()Returns children nodes of this node, ordered from leftmost to rightmost.- Returns:
- an array of children nodes. If node has no child, destination array has zero size.
-
toString
-
clone
-