laser.alphabet
Class StringLabel

java.lang.Object
  extended by laser.alphabet.AbstractLabel<StringLabel>
      extended by laser.alphabet.StringLabel
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<StringLabel>, LabelInterface<StringLabel>

public class StringLabel
extends AbstractLabel<StringLabel>

StringLabels are Labels that represent Strings.

Like all types of Labels, StringLabels participate in flyweighting, thus there is only one instance of each unique StringLabel. For this reason, StringLabels should only be instantiated through a StringAlphabetFactory, which maintains a repository of all StringLabels.

Author:
Nathan A. Jokel (laser-software@cs.umass.edu)
See Also:
LabelInterface, StringAlphabetFactory, Serialized Form

Constructor Summary
protected StringLabel(java.lang.String inputString)
          Creates a new StringLabel.
 
Method Summary
 StringLabel clone()
          Returns a reference to this StringLabel.
 int compareTo(StringLabel label)
          Compares this StringLabel with the specified StringLabel for order.
 int hashCode()
          Returns the hash code of this StringLabel.
 java.lang.String toString()
          Returns the String representation of this StringLabel.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StringLabel

protected StringLabel(java.lang.String inputString)
Creates a new StringLabel. Initializes the String to the specified input String.

Parameters:
inputString - The input String.
Throws:
java.lang.NullPointerException - When the input String is null.
Method Detail

clone

public StringLabel clone()
Returns a reference to this StringLabel. Since Labels participate in flyweighting, there should be only one instance of each unique StringLabel.

Specified by:
clone in interface LabelInterface<StringLabel>
Specified by:
clone in class AbstractLabel<StringLabel>
Returns:
The reference.
See Also:
Object.clone()

compareTo

public int compareTo(StringLabel label)
Compares this StringLabel with the specified StringLabel for order.

The order is determined by comparing the String representations of the StringLabels alphabetically.

If this StringLabel is less than the specified StringLabel, a negative integer is returned. If this StringLabel is equal to the specified StringLabel, zero is returned. If this StringLabel is greater than the specified StringLabel, a positive integer is returned.

Specified by:
compareTo in interface java.lang.Comparable<StringLabel>
Specified by:
compareTo in class AbstractLabel<StringLabel>
Parameters:
label - the StringLabel to compare with this one.
Returns:
a negative integer when this StringLabel is less than the specified StringLabel, zero when this StringLabel is equal to the specified StringLabel, and a positive integer when this StringLabel is greater than the specified StringLabel.
Throws:
java.lang.NullPointerException - if the specified StringLabel is null.

toString

public java.lang.String toString()
Returns the String representation of this StringLabel.

Specified by:
toString in class AbstractLabel<StringLabel>
Returns:
The String representation of this StringLabel.
See Also:
Object.toString()

hashCode

public int hashCode()
Returns the hash code of this StringLabel.

Specified by:
hashCode in class AbstractLabel<StringLabel>
Returns:
The hash code value for this StringLabel.
See Also:
Object.hashCode()