edu.ksu.cis.viewer
Class Node

java.lang.Object
  extended byedu.ksu.cis.viewer.Node
All Implemented Interfaces:
Cloneable

public final class Node
extends Object
implements Cloneable

The objects used as the nodes of trees in the BinaryTree class. The contents of a Node are represented by a String. In addition, each Node has an int tag and a color. A Node is immutable.

Author:
Rod Howell (howell@cis.ksu.edu)
See Also:
BinaryTree

Constructor Summary
Node(String s)
          Constructs a black Node with the given contents and a tag of 0.
Node(String s, Color col)
          Constructs a Node of the given color with the given contents and a tag of 0.
Node(String s, int tag)
          Constructs a black Node with the given contents and tag.
Node(String s, int tag, Color col)
          Constructs a Node of the given color with the given contents and tag.
 
Method Summary
 Object clone()
          Because this structure is immutable, this method simply returns the node itself.
 Color getColor()
          Returns the color of the Node.
 String getContents()
          Returns the contents of the Node.
 int getTag()
          Returns the tag of the Node.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Node

public Node(String s)
     throws NullPointerException
Constructs a black Node with the given contents and a tag of 0.

Throws:
NullPointerException - if s is null

Node

public Node(String s,
            int tag)
     throws NullPointerException
Constructs a black Node with the given contents and tag.

Parameters:
s - the contents of the Node
tag - the tag
Throws:
NullPointerException - if s is null

Node

public Node(String s,
            Color col)
     throws NullPointerException
Constructs a Node of the given color with the given contents and a tag of 0.

Parameters:
s - the contents of the Node
col - the color of the Node
Throws:
NullPointerException - if either s or col is null

Node

public Node(String s,
            int tag,
            Color col)
     throws NullPointerException
Constructs a Node of the given color with the given contents and tag.

Parameters:
s - the contents of the Node
tag - the tag
col - the color of the Node
Throws:
NullPointerException - if either s or col is null
Method Detail

getContents

public String getContents()
Returns the contents of the Node.


getTag

public int getTag()
Returns the tag of the Node.


getColor

public Color getColor()
Returns the color of the Node.


clone

public Object clone()
Because this structure is immutable, this method simply returns the node itself.