laser.alphabet.labelpattern
Class IndexedLabelPattern

java.lang.Object
  extended by laser.alphabet.labelpattern.IndexedLabelPattern
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<LabelPatternInterface<? extends IndexedLabel>>, LabelPatternInterface<IndexedLabel>

public class IndexedLabelPattern
extends java.lang.Object
implements LabelPatternInterface<IndexedLabel>

A LabelPattern that specifies subsets of Alphabets of IndexedLabels.

An IndexedLabelPattern defines an integer range, delimited by a lower and an upper bound, which are included in the range. The subset of a given Alphabet of IndexedLabels that the IndexedLabelPattern specifies is all IndexedLabels in the Alphabet of whose indices fall within the range defined by the IndexedLabelPattern.

IndexedLabelPattens should only be instantiated by IndexedLabelPatternFactories.

Author:
Nathan A. Jokel (laser-software@cs.umass.edu)
See Also:
laser.alphabetinterface.labelpatterninterface.LabelPatternInterface, IndexedLabelPatternFactory, IndexedLabel, IndexedAlphabet, Serialized Form

Constructor Summary
protected IndexedLabelPattern(int lowerBound, int upperBound)
          Creates an instance of IndexedLabelPattern.
 
Method Summary
 LabelPatternInterface<IndexedLabel> clone()
          Returns a copy of this IndexedLabelPattern.
 int compareTo(LabelPatternInterface<? extends IndexedLabel> pattern)
          Compares this IndexedLabelPattern with the specified LabelPatternInterface for order.
 boolean equals(java.lang.Object obj)
          Compares this IndexedLabelPattern with the specified Object for equality.
 java.util.Set<IndexedLabel> getMatchingLabels(AlphabetInterface<? extends IndexedLabel> alphabet)
          Returns a Set containing the subset of IndexedLabels of the specified Alphabet that this IndexedLabelPattern specifies.
 int hashCode()
          Returns a hash code value for this IndexedLabelPattern.
 java.lang.String toString()
          Returns the String representation of this IndexedLabelPattern.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IndexedLabelPattern

protected IndexedLabelPattern(int lowerBound,
                              int upperBound)
Creates an instance of IndexedLabelPattern.

Precondition: lowerBound and upperBound are >= 0. lowerBound <= upperBound.

Parameters:
lowerBound - The lower bound of this IndexedLabelPattern.
upperBound - The upper bound of this IndexedLabelPattern.
Method Detail

clone

public LabelPatternInterface<IndexedLabel> clone()
Returns a copy of this IndexedLabelPattern.

Specified by:
clone in interface LabelPatternInterface<IndexedLabel>
Overrides:
clone in class java.lang.Object
Returns:
The copy.

compareTo

public int compareTo(LabelPatternInterface<? extends IndexedLabel> pattern)
Compares this IndexedLabelPattern with the specified LabelPatternInterface for order. The order is determined by comparing the String representations of the LabelPatterns.

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

Specified by:
compareTo in interface java.lang.Comparable<LabelPatternInterface<? extends IndexedLabel>>
Parameters:
pattern - The LabelPatternInterface to compare with this IndexedLabelPattern.
Returns:
a negative integer when this IndexedLabelPattern is less than the specified LabelPattern, zero when this IndexedLabelPattern is equal to the specified LabelPattern, and a positive integer when this IndexedLabelPattern is greater than the specified LabelPattern.
Throws:
java.lang.NullPointerException - if the specified LabelPattern is null.

equals

public boolean equals(java.lang.Object obj)
Compares this IndexedLabelPattern with the specified Object for equality. Returns true if the specified Object is also an IndexedLabelPattern and it has the same lower and upper bounds as this one, false otherwise.

Specified by:
equals in interface LabelPatternInterface<IndexedLabel>
Overrides:
equals in class java.lang.Object
Parameters:
obj - The Object to test for equality.
Returns:
true if the specified Object is also an IndexedLabelPattern and it has the same lower and upper bounds as this one, false otherwise.

hashCode

public int hashCode()
Returns a hash code value for this IndexedLabelPattern.

Specified by:
hashCode in interface LabelPatternInterface<IndexedLabel>
Overrides:
hashCode in class java.lang.Object
Returns:
A hash code value for this IndexedLabelPattern.

toString

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

Overrides:
toString in class java.lang.Object
Returns:
The String representation of this IndexedLabelPattern.

getMatchingLabels

public java.util.Set<IndexedLabel> getMatchingLabels(AlphabetInterface<? extends IndexedLabel> alphabet)
Returns a Set containing the subset of IndexedLabels of the specified Alphabet that this IndexedLabelPattern specifies.

Specified by:
getMatchingLabels in interface LabelPatternInterface<IndexedLabel>
Parameters:
alphabet - The Alphabet of which this IndexedLabelPattern is to specify a subset.
Returns:
The subset.
Throws:
java.lang.NullPointerException - When the specified Alphabet is null.