laser.alphabet.labelpattern
Class AbstractClassSetLabelPattern<L extends LabelInterface>

java.lang.Object
  extended by laser.alphabet.labelpattern.AbstractClassSetLabelPattern<L>
Type Parameters:
L - The type of Label with respect to which this LabelPattern has meaning.
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<LabelPatternInterface<? extends L>>, LabelPatternInterface<L>
Direct Known Subclasses:
ClassSetLabelPattern, NotClassSetLabelPattern

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

An abstract class providing common functionality for both ClassSetLabelPatterns and NotClassSetLabelPatterns.

Note that this class is not synchronized, and attempts to use it with non-sequential code may result in unexpected behavior.

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

Field Summary
protected  java.lang.Class<L> labelClass
          The Class of Label with respect to which this LabelPattern has meaning.
protected  java.util.SortedSet<LabelPatternInterface<L>> labelPatterns
          The set of LabelPatterns that have been specified as participating in determining S.
protected  java.util.SortedSet<L> labels
          The set of Labels that have been specified as being included in/excluded from S.
 
Constructor Summary
protected AbstractClassSetLabelPattern(java.lang.Class<L> labelClass)
          Creates a new AbstractClassSetLabelPattern.
 
Method Summary
protected  boolean addLabel(L label)
          Specifies the given Label as being included in/excluded from the subset this LabelPattern specifies.
protected  boolean addLabelPattern(LabelPatternInterface<L> labelPattern)
          Specifies the given LabelPattern as participating in determining the subset this LabelPattern specifies.
protected  boolean addLabelPatterns(java.util.Set<? extends LabelPatternInterface<L>> labelPatterns)
          Specifies each LabelPattern in the given Set as participating in determining the subset this LabelPattern specifies.
protected  boolean addLabels(java.util.Set<? extends L> labels)
          Specifies each Label in the given Set as being included in/excluded from the subset this LabelPattern specifies.
abstract  LabelPatternInterface<L> clone()
          Returns a copy of this LabelPattern.
 int compareTo(LabelPatternInterface<? extends L> pattern)
          Compares this LabelPattern with the specified LabelPattern for order.
 boolean equals(java.lang.Object obj)
          Compares this LabelPattern with the specified Object for equality.
protected  java.util.Set<LabelPatternInterface<L>> getLabelPatterns()
          Returns a Set containing all of the LabelPatterns specified as participating in determining the subset this LabelPattern specifies.
protected  java.util.Set<L> getLabels()
          Returns a Set containing all of the Labels specified as being included in the subset this ClassSetLabelPattern specifies.
 java.util.Set<L> getMatchingLabels(AlphabetInterface<? extends L> alphabet)
          Returns a Set containing the subset of Labels of the specified Alphabet that this LabelPattern specifies.
 int hashCode()
          Returns a hash code value for this LabelPattern.
protected  boolean removeLabel(L label)
          Removes the specification that the given Label is to be included in/excluded from the subset this LabelPattern specifies.
protected  boolean removeLabelPattern(LabelPatternInterface<L> labelPattern)
          Removes the specification that the given LabelPattern is to participate in determining the subset this LabelPattern specifies.
protected  boolean removeLabelPatterns(java.util.Set<? extends LabelPatternInterface<L>> labelPatterns)
          Removes the specification that each LabelPattern in the given Set is to participate in determining the subset this LabelPattern specifies.
protected  boolean removeLabels(java.util.Set<? extends L> labels)
          Removes the specification that each Label in the given Set is to be included in/excluded from the subset this LabelPattern specifies.
 java.lang.String toString()
          Returns the String representation of this LabelPattern.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

labelClass

protected java.lang.Class<L extends LabelInterface> labelClass
The Class of Label with respect to which this LabelPattern has meaning.


labels

protected java.util.SortedSet<L extends LabelInterface> labels
The set of Labels that have been specified as being included in/excluded from S.


labelPatterns

protected java.util.SortedSet<LabelPatternInterface<L extends LabelInterface>> labelPatterns
The set of LabelPatterns that have been specified as participating in determining S.

Constructor Detail

AbstractClassSetLabelPattern

protected AbstractClassSetLabelPattern(java.lang.Class<L> labelClass)
Creates a new AbstractClassSetLabelPattern.

Parameters:
labelClass - The Class of Label with respect to which this LabelPattern has meaning.
Method Detail

clone

public abstract LabelPatternInterface<L> clone()
Returns a copy of this LabelPattern.

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

compareTo

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

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

Specified by:
compareTo in interface java.lang.Comparable<LabelPatternInterface<? extends L extends LabelInterface>>
Parameters:
pattern - The LabelPatternInterface to compare with this LabelPattern.
Returns:
a negative integer when this LabelPattern is less than the specified LabelPattern, zero when this LabelPattern is equal to the specified LabelPattern, and a positive integer when this LabelPattern 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 LabelPattern with the specified Object for equality. Returns true if the specified Object is also a LabelPattern, it has meaning with respect to the same types of Alphabets and Labels, the same set of Labels has been specified as being included in/excluded from S for both LabelPatterns, and the same set of LabelPatterns has been specified as participating in determining S for both LabelPatterns, false otherwise.

Specified by:
equals in interface LabelPatternInterface<L extends LabelInterface>
Overrides:
equals in class java.lang.Object
Parameters:
obj - The Object to test for equality.
Returns:
true if the specified Object is also a LabelPattern, it has meaning with respect to the same types of Alphabets and Labels, the same set of Labels has been specified as being included in/excluded from S for both LabelPatterns, and the same set of LabelPatterns has been specified as participating in determining S for both LabelPatterns, false otherwise.

hashCode

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

Specified by:
hashCode in interface LabelPatternInterface<L extends LabelInterface>
Overrides:
hashCode in class java.lang.Object
Returns:
A hash code value for this LabelPattern.

toString

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

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

getMatchingLabels

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

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

addLabel

protected boolean addLabel(L label)
Specifies the given Label as being included in/excluded from the subset this LabelPattern specifies. If an equal Label (according to its equals method) is already specified as being so included/excluded, false is returned and this LabelPattern is unchanged, otherwise true is returned.

Note that no references are maintained between the specified Label and this LabelPattern, thus changing the specified Label has no effect on this LabelPattern and vice versa.

Parameters:
label - Label to be included/excluded.
Returns:
false if an equal Label is already specified as being included/excluded, true otherwise.
Throws:
java.lang.ClassCastException - the specified Label is not of type L.
java.lang.NullPointerException - the specified Label is null.

addLabels

protected boolean addLabels(java.util.Set<? extends L> labels)
Specifies each Label in the given Set as being included in/excluded from the subset this LabelPattern specifies. If an equal Label (according to its equals method) to every Label in the given Set is already specified as being so included/excluded, false is returned and this LabelPattern is unchanged, otherwise true is returned.

Note that no references are maintained between any of the specified Labels and this LabelPattern, thus changing any of the specified Labels has no effect on this LabelPattern and vice versa.

Parameters:
labels - Labels to be included/excluded.
Returns:
false if an equal Label (according to its equals method) to every Label in the given Set is already specified as being included in/excluded from the subset this LabelPattern specifies, true otherwise.
Throws:
java.lang.ClassCastException - a Label in the specified Set is not of type L.
java.lang.NullPointerException - if the specified Set or any Label it contains is null.

addLabelPattern

protected boolean addLabelPattern(LabelPatternInterface<L> labelPattern)
Specifies the given LabelPattern as participating in determining the subset this LabelPattern specifies. If an equal LabelPattern (according to its equals method) is already so specified, false is returned and this LabelPattern is unchanged, otherwise true is returned.

Note that no references are maintained between the specified LabelPattern and this LabelPattern, thus changing the specified LabelPattern has no effect on this LabelPattern and vice versa.

Parameters:
labelPattern - LabelPattern to be included/excluded.
Returns:
false if an equal LabelPattern is already specified as participating, true otherwise.
Throws:
java.lang.NullPointerException - the specified LabelPattern is null.

addLabelPatterns

protected boolean addLabelPatterns(java.util.Set<? extends LabelPatternInterface<L>> labelPatterns)
Specifies each LabelPattern in the given Set as participating in determining the subset this LabelPattern specifies. If an equal LabelPattern (according to its equals method) to every Label in the given Set is already so specified, false is returned and this LabelPattern is unchanged, otherwise true is returned.

Note that no references are maintained between any of the specified LabelPatterns and this LabelPattern, thus changing any of the specified LabelPatterns has no effect on this LabelPattern and vice versa.

Parameters:
labelPatterns - LabelPatterns to be included/excluded.
Returns:
false if an equal LabelPattern (according to its equals method) to every Label in the given Set is already specified as participating in determining the subset this LabelPattern specifies, true otherwise.
Throws:
java.lang.NullPointerException - if the specified Set or any LabelPattern it contains is null.

getLabels

protected java.util.Set<L> getLabels()
Returns a Set containing all of the Labels specified as being included in the subset this ClassSetLabelPattern specifies. This Set is a copy, thus modifying it or any of the Labels it contains has no effect on the ClassSetLabelPattern, nor does modifying the ClassSetLabelPattern have any effect on the returned Set or any of the Labels it contains.

Returns:
a Set containing all of the Labels specified as being included in the subset this ClassSetLabelPattern specifies.

getLabelPatterns

protected java.util.Set<LabelPatternInterface<L>> getLabelPatterns()
Returns a Set containing all of the LabelPatterns specified as participating in determining the subset this LabelPattern specifies. This Set is a copy, thus modifying it or any of the LabelPatterns it contains has no effect on the LabelPattern, nor does modifying the LabelPattern have any effect on the returned Set or any of the LabelPatterns it contains.

Returns:
a Set containing all of the LabelPatterns specified as participating in determining the subset this LabelPattern specifies.

removeLabel

protected boolean removeLabel(L label)
Removes the specification that the given Label is to be included in/excluded from the subset this LabelPattern specifies. If an equal Label (according to its equals method) was specified as being so included/excluded, true is returned, otherwise false is returned and this LabelPattern is unchanged.

Parameters:
label - Label no longer to be included/excluded.
Returns:
true if a Label equal to the given Label was specified as being included/excluded, false otherwise.
Throws:
java.lang.NullPointerException - if the specified Label is null.

removeLabels

protected boolean removeLabels(java.util.Set<? extends L> labels)
Removes the specification that each Label in the given Set is to be included in/excluded from the subset this LabelPattern specifies. If an equal Label (according to its equals method) to any Label in the given Set was specified as being so included/excluded, true is returned, otherwise false is returned and this LabelPattern is unchanged.

Parameters:
labels - Labels no longer to be included/excluded.
Returns:
true If an equal Label (according to its equals method) to any Label in the given Set was specified as being included in/excluded from the subset this LabelPattern specifies, false otherwise.
Throws:
java.lang.NullPointerException - if the specified Set or any Label it contains is null.

removeLabelPattern

protected boolean removeLabelPattern(LabelPatternInterface<L> labelPattern)
Removes the specification that the given LabelPattern is to participate in determining the subset this LabelPattern specifies. If an equal LabelPattern (according to its equals method) was so specified, true is returned, otherwise false is returned and this ClassSetLabelPattern is unchanged.

Parameters:
labelPattern - LabelPattern no longer to be included/excluded.
Returns:
true if a LabelPattern equal to the given Label was specified as participating, false otherwise.
Throws:
java.lang.NullPointerException - if the specified LabelPattern is null.

removeLabelPatterns

protected boolean removeLabelPatterns(java.util.Set<? extends LabelPatternInterface<L>> labelPatterns)
Removes the specification that each LabelPattern in the given Set is to participate in determining the subset this LabelPattern specifies. If an equal LabelPattern (according to its equals method) to any of the LabelPatterns in the given Set was so specified, true is returned, otherwise false is returned and this ClassSetLabelPattern is unchanged.

Parameters:
labelPatterns - LabelPatterns no longer to be included/excluded.
Returns:
true if an equal LabelPattern (according to its equals method) to any of the LabelPatterns in the given Set was specified as participating in determining the subset this LabelPattern specifies, falseotherwise.
Throws:
java.lang.NullPointerException - if the specified Set or any LabelPattern it contains is null.