Class FunctionNode
java.lang.Object
math.parser.FunctionNode
- All Implemented Interfaces:
Cloneable, ExpressionNode
Name: FunctionNode
Description: This node is used to evaluate every kind of function with a single parameter, like abs(...) or sin(...)
Date: 08/dic/06 Time: 16:31:14
- Version:
- 1.0
- Author:
- Bertoli Marco
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ExpressionNodeChild nodeprotected ExpressionNode[]An array with childrenprotected intFunction of this nodestatic final String[]List of supported functionsFields inherited from interface ExpressionNode
CONSTANT_NODE, FUNCTION_NODE, OPERATOR_NODE, VARIABLE_NODE -
Constructor Summary
ConstructorsConstructorDescriptionFunctionNode(ExpressionNode child, int function) Creates a function node.FunctionNode(ExpressionNode child, String function) Creates a function node. -
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 nodevoidvoidsetVariable(String name, double value) Sets the value for a variabletoString()Returns a string describing the entire tree
-
Field Details
-
FUNCTIONS
List of supported functions -
child
Child node -
function
protected int functionFunction of this node -
children
An array with children
-
-
Constructor Details
-
FunctionNode
Creates a function node.- Parameters:
child- child node of this nodefunction- function to be evaluated. This is the index inFUNCTIONSarray- See Also:
-
FunctionNode
Creates a function node.- Parameters:
child- child node of this nodefunction- name of function to be evaluated.- Throws:
IllegalArgumentException- if function is unsupported
-
-
Method Details
-
count
public int count()Description copied from interface:ExpressionNodeCounts number of nodes in current subtree- Specified by:
countin interfaceExpressionNode- Returns:
- number of nodes (included root)
-
getDepth
public int getDepth()Description copied from interface:ExpressionNodeReturns depth of current subtree- Specified by:
getDepthin interfaceExpressionNode- Returns:
- depth of the tree
-
getSubtype
Description copied from interface:ExpressionNodeReturns more information on node type- Specified by:
getSubtypein interfaceExpressionNode- Returns:
- name of node function or operator symbol
-
getType
public int getType()Description copied from interface:ExpressionNodeReturns type of node- Specified by:
getTypein interfaceExpressionNode- Returns:
- CONSTANT_NODE, VARIABLE_NODE, OPERATOR_NODE, FUNCTION_NODE
-
getValue
public double getValue()Description copied from interface:ExpressionNodeReturns value of target node- Specified by:
getValuein interfaceExpressionNode- Returns:
- value of node
-
setVariable
Description copied from interface:ExpressionNodeSets the value for a variable- Specified by:
setVariablein interfaceExpressionNode- Parameters:
name- name of the variable to be setvalue- value for the variable
-
getChildrenNodes
Description copied from interface:ExpressionNodeReturns children nodes of this node, ordered from leftmost to rightmost.- Specified by:
getChildrenNodesin interfaceExpressionNode- Returns:
- an array of children nodes. If node has no child, destination array has zero size.
-
clone
Description copied from interface:ExpressionNodeClones current node- Specified by:
clonein interfaceExpressionNode- Overrides:
clonein classObject- Returns:
- deep copy of current node
-
toString
Description copied from interface:ExpressionNodeReturns a string describing the entire tree- Specified by:
toStringin interfaceExpressionNode- Overrides:
toStringin classObject- Returns:
- string describing the entire tree
-
setParser
-