Class SetElement

java.lang.Object
  |
  +--SetElement

public class SetElement
extends java.lang.Object
implements java.lang.Cloneable

This class allows the user to create set elements in the form of ordered pairs (K,I). K is a unique key and I is some information portion that need not be unique. A dictionary, for example, may be viewed as a set of ordered pairs. The first element of each pair is a unique key made up of a series of symbols (or,word). The second part of each pair is the definition or collection of definitions. The definition part need not be unique. The class SetElement holds two private data members that are both Strings. It provides routines that allow the client to manipulate objects that represent the ordered pairs (K,I).


Constructor Summary
SetElement(java.lang.String k, java.lang.String i)
          Create a pair with two Strings.
 
Method Summary
 java.lang.Object clone()
          The clone() method, in this case, is not strictly needed (String is an immutable type and K and I are private) but is provided for easy expansion.
 int compareTo(java.lang.Object o)
          This method allows us to compare two (K,I) objects.
 java.lang.String getData()
          Return the Information portion I of the (K,I) pair.
 java.lang.String getUniqueID()
          Return the unique part K of the (K,I) pair.
static void main(java.lang.String[] a)
           
 void setData(java.lang.String d)
          Set the Information portion I of the (K,I) pair.
 void setUniqueID(java.lang.String value)
          Set the unique part K of the (K,I) pair.
 java.lang.String toString()
          The method toString converts the pair (K,I) to a String.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SetElement

public SetElement(java.lang.String k,
                  java.lang.String i)
Create a pair with two Strings.
Method Detail

getUniqueID

public java.lang.String getUniqueID()
Return the unique part K of the (K,I) pair.

getData

public java.lang.String getData()
Return the Information portion I of the (K,I) pair.

setUniqueID

public void setUniqueID(java.lang.String value)
Set the unique part K of the (K,I) pair.

setData

public void setData(java.lang.String d)
Set the Information portion I of the (K,I) pair.

clone

public java.lang.Object clone()
The clone() method, in this case, is not strictly needed (String is an immutable type and K and I are private) but is provided for easy expansion.
Overrides:
clone in class java.lang.Object

compareTo

public int compareTo(java.lang.Object o)
              throws java.lang.IllegalArgumentException
This method allows us to compare two (K,I) objects. It makes the comparison based on the K component. The method returns an integer less than 0 if the implied object is less than the passed object. It returns a value equal to 0 if the implied object and passed object are equal. It returns a value greater than 0 if the implied object is greater than the passed object. If the passed object is not a SetElement an IllegalArgumentException exception is thrown.

toString

public java.lang.String toString()
The method toString converts the pair (K,I) to a String.
Overrides:
toString in class java.lang.Object

main

public static void main(java.lang.String[] a)