learn
Class Node
java.lang.Object
|
+--learn.Node
- public class Node
- extends java.lang.Object
- implements java.io.Serializable
The Node
class contains the label or name and the links for
a node in a DecisionTree
.
- See Also:
- Serialized Form
Constructor Summary |
Node()
Creates a node. |
Node(Node parent,
java.lang.String label)
Creates a node with the given name and parent. |
Node(java.lang.String label)
Creates a node with the given name. |
Method Summary |
void |
addChild(Node child,
java.lang.String linkLabel)
Adds a child node and the link name for the link to that child. |
static void |
displayTree(Node root,
java.lang.String offset)
Displays the tree, starting with the given root node. |
boolean |
hasChildren()
Checks if the node has children nodes linked to it. |
void |
setLabel(java.lang.String label)
Sets the name of the node. |
Methods inherited from class java.lang.Object |
,
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
label
protected java.lang.String label
linkLabels
protected java.util.Vector linkLabels
parent
protected Node parent
children
protected java.util.Vector children
Node
public Node()
- Creates a node.
Node
public Node(java.lang.String label)
- Creates a node with the given name.
- Parameters:
label
- the String that contains the name of the node
Node
public Node(Node parent,
java.lang.String label)
- Creates a node with the given name and parent.
- Parameters:
parent
- the Node that is the parent of the node being createdlabel
- the String that contains the name of the node
addChild
public void addChild(Node child,
java.lang.String linkLabel)
- Adds a child node and the link name for the link to that child.
- Parameters:
child
- the Node that is added as a childlinkLabel
- the String that contains the name of the link
hasChildren
public boolean hasChildren()
- Checks if the node has children nodes linked to it.
- Returns:
true
if the node has children. Otherwise, returns
false
.
setLabel
public void setLabel(java.lang.String label)
- Sets the name of the node.
- Parameters:
label
- the String that contains the name of the node
displayTree
public static void displayTree(Node root,
java.lang.String offset)
- Displays the tree, starting with the given root node.
- Parameters:
root
- the Node that is the root of the tree to be displayedoffset
- the String