Class Node

java.lang.Object
edu.ksu.cis.viewer.Node
All Implemented Interfaces:
Serializable, Cloneable

public final class Node extends Object implements Cloneable, Serializable
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 (rhowell@ksu.edu)
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a black Node 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.
    Node(String s, Color col)
    Constructs a Node of the given color with the given contents and a tag of 0.
  • Method Summary

    Modifier and Type
    Method
    Description
    Because this structure is immutable, this method simply returns the node itself.
    Returns the color of the Node.
    Returns the contents of the Node.
    int
    Returns the tag of the Node.

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Node

      public Node(String s) throws NullPointerException
      Constructs a black Node with the given contents and a tag of 0.
      Parameters:
      s - the contents of the node
      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 Details

    • getContents

      public String getContents()
      Returns the contents of the Node.
      Returns:
      the contents of this node
    • getTag

      public int getTag()
      Returns the tag of the Node.
      Returns:
      the tag for this node
    • getColor

      public Color getColor()
      Returns the color of the Node.
      Returns:
      the color of this node
    • clone

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