laser.alphabet
Class AbstractLabel<L extends AbstractLabel>

java.lang.Object
  extended by laser.alphabet.AbstractLabel<L>
Type Parameters:
L - The type of this Label.
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<L>, LabelInterface<L>
Direct Known Subclasses:
IndexedLabel, StringLabel

public abstract class AbstractLabel<L extends AbstractLabel>
extends java.lang.Object
implements LabelInterface<L>

This is an abstract class which all types of Labels extend.

All types of Labels participate in flyweighting, thus there is only one instance of each unique Label. For this reason, Labels should only be instantiated by an AlphabetFactory of the appropriate type, which maintains a repository of all Labels the labels of that type.

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

Constructor Summary
AbstractLabel()
           
 
Method Summary
abstract  L clone()
          Returns a reference to this Label.
abstract  int compareTo(L label)
          Compares this Label with the specified Label, which must be of the same type, for order.
abstract  int hashCode()
          Returns a hash code for this Label.
abstract  java.lang.String toString()
          Returns the String representation of this label.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractLabel

public AbstractLabel()
Method Detail

clone

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

Specified by:
clone in interface LabelInterface<L extends AbstractLabel>
Overrides:
clone in class java.lang.Object
Returns:
The reference.
See Also:
Object.clone()

compareTo

public abstract int compareTo(L label)
Compares this Label with the specified Label, which must be of the same type, for order.

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

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

hashCode

public abstract int hashCode()
Returns a hash code for this Label.

Overrides:
hashCode in class java.lang.Object
Returns:
The hash code value for this Label.
See Also:
Object.hashCode()

toString

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

Overrides:
toString in class java.lang.Object
Returns:
The String representation of this label.
See Also:
Object.toString()