openlist
Class Symbol

java.lang.Object
  extended by openlist.Symbol
All Implemented Interfaces:
java.lang.Comparable

public class Symbol
extends java.lang.Object
implements java.lang.Comparable

The Symbol class represents interned Strings. Each is guarnteed to be stored uniquely if the function intern is applied to return the reference to the symbol.


Field Summary
(package private)  java.lang.String printName
          The printable name for this symbol.
private static java.util.Hashtable<java.lang.String,Symbol> theHashtable
           
 
Constructor Summary
private Symbol(java.lang.String printName)
          Create a Symbol with the given name.
 
Method Summary
 int compareTo(java.lang.Object other)
          Compare this Symbol to another, based on String comparision of printNames.
 boolean equals(java.lang.Object ob)
          Two Symbols are equal iff they are the same Symbol.
static Symbol intern(java.lang.String name)
          Intern a String as a symbol.
 java.lang.String toString()
          the printable name of this Symbol
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

theHashtable

private static java.util.Hashtable<java.lang.String,Symbol> theHashtable

printName

java.lang.String printName
The printable name for this symbol.

Constructor Detail

Symbol

private Symbol(java.lang.String printName)
Create a Symbol with the given name. This is private. Use intern for the public version.

Parameters:
printName -
Method Detail

intern

public static Symbol intern(java.lang.String name)
Intern a String as a symbol. If the Symbol named by the string already exists, that symbol is returned. Otherwise a new symbol is created with the name, and that is returned.

Parameters:
name -
Returns:
the Symbol that interns the named String

toString

public java.lang.String toString()
the printable name of this Symbol

Overrides:
toString in class java.lang.Object
Returns:
the name of this Symbol

equals

public boolean equals(java.lang.Object ob)
Two Symbols are equal iff they are the same Symbol.

Overrides:
equals in class java.lang.Object
Parameters:
ob - the Object to which this Symbol is compared for equality
Returns:
true if this Symbol is the same as the argument

compareTo

public int compareTo(java.lang.Object other)
Compare this Symbol to another, based on String comparision of printNames.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
other - the Object to which this Symbol is compared
Returns:
a negative number if this compares less than the argument, 0 if it compares equal to the argument, and a positive number otherwise