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

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

public class ClassSetLabelPattern<L extends LabelInterface>
extends AbstractClassSetLabelPattern<L>
implements ClassSetLabelPatternInterface<L>

This class represents a "class set" LabelPattern. The LabelPattern "class set," with respect to an Alphabet of the correct type, specifies the subset, S, of Labels in the Alphabet that have been explicitly specified as being included in S.

LabelPatterns should only be instantiated by LabelPattern factories.

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:
laser.alphabetinterface.labelpatterninterface.ClassSetLabelPatternInterface, laser.alphabetinterface.labelpatterninterface.LabelPatternFactoryInterface, Serialized Form

Field Summary
 
Fields inherited from class laser.alphabet.labelpattern.AbstractClassSetLabelPattern
labelClass, labelPatterns, labels
 
Constructor Summary
protected ClassSetLabelPattern(java.lang.Class<L> labelClass)
          Creates a new "class set" LabelPattern.
 
Method Summary
 boolean addIncludedLabel(L label)
          Specifies the given Label as being included in the subset this LabelPattern specifies.
 boolean addIncludedLabelPattern(LabelPatternInterface<L> labelPattern)
          Specifies the given LabelPattern as participating in determining the subset this LabelPattern specifies.
 boolean addIncludedLabelPatterns(java.util.Set<? extends LabelPatternInterface<L>> labelPatterns)
          Specifies each LabelPattern in the given Set as participating in determining the subset this LabelPattern specifies.
 boolean addIncludedLabels(java.util.Set<? extends L> labels)
          Specifies each Label in the given Set as being included in the subset this LabelPattern specifies.
 ClassSetLabelPatternInterface<L> clone()
          Returns a copy of this ClassSetLabelPattern.
 java.util.Set<LabelPatternInterface<L>> getIncludedLabelPatterns()
          Returns a Set containing all of the LabelPatterns specified as participating in determining the subset this ClassSetLabelPattern specifies.
 java.util.Set<L> getIncludedLabels()
          Returns a Set containing all of the Labels specified as being included in the subset this ClassSetLabelPattern specifies.
 boolean removeIncludedLabel(L label)
          Removes the specification that the given Label is to be included in the subset this LabelPattern specifies.
 boolean removeIncludedLabelPattern(LabelPatternInterface<L> labelPattern)
          Removes the specification that the given LabelPattern is to participate in determining the subset this LabelPattern specifies.
 boolean removeIncludedLabelPatterns(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.
 boolean removeIncludedLabels(java.util.Set<? extends L> labels)
          Removes the specification that each Label in the given Set is to be included in the subset this LabelPattern specifies.
 
Methods inherited from class laser.alphabet.labelpattern.AbstractClassSetLabelPattern
addLabel, addLabelPattern, addLabelPatterns, addLabels, compareTo, equals, getLabelPatterns, getLabels, getMatchingLabels, hashCode, removeLabel, removeLabelPattern, removeLabelPatterns, removeLabels, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface laser.alphabet.labelpattern.LabelPatternInterface
equals, getMatchingLabels, hashCode
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Constructor Detail

ClassSetLabelPattern

protected ClassSetLabelPattern(java.lang.Class<L> labelClass)
Creates a new "class set" LabelPattern. This constructor should not be used to instantiate ClassSetLabelPatterns; they should only be instantiated by the appropriate factory methods of a LabelPatternFactoryInterface.

Parameters:
labelClass - The Class of Label with respect to which this LabelPattern has meaning.
See Also:
laser.alphabetinterface.labelpatterninterface.LabelPatternFactoryInterface
Method Detail

clone

public ClassSetLabelPatternInterface<L> clone()
Returns a copy of this ClassSetLabelPattern.

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

addIncludedLabel

public boolean addIncludedLabel(L label)
Specifies the given Label as being included in the subset this LabelPattern specifies. If an equal Label (according to its equals method) is already specified as being so included, false is returned and this ClassSetLabelPattern 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.

Specified by:
addIncludedLabel in interface ClassSetLabelPatternInterface<L extends LabelInterface>
Parameters:
label - Label to be included.
Returns:
false if an equal Label is already specified as being included, true otherwise.
Throws:
java.lang.ClassCastException - the specified Label is not of type L.
java.lang.NullPointerException - if the specified Label is null.

addIncludedLabels

public boolean addIncludedLabels(java.util.Set<? extends L> labels)
Specifies each Label in the given Set as being included in 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, 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.

Specified by:
addIncludedLabels in interface ClassSetLabelPatternInterface<L extends LabelInterface>
Parameters:
labels - Labels to be included.
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 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.

addIncludedLabelPattern

public boolean addIncludedLabelPattern(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 ClassSetLabelPattern 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.

Specified by:
addIncludedLabelPattern in interface ClassSetLabelPatternInterface<L extends LabelInterface>
Parameters:
labelPattern - LabelPattern to be included.
Returns:
false if an equal LabelPattern is already specified as participating, true otherwise.
Throws:
java.lang.NullPointerException - if the specified LabelPattern is null.

addIncludedLabelPatterns

public boolean addIncludedLabelPatterns(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.

Specified by:
addIncludedLabelPatterns in interface ClassSetLabelPatternInterface<L extends LabelInterface>
Parameters:
labelPatterns - LabelPatterns to be included.
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.

getIncludedLabels

public java.util.Set<L> getIncludedLabels()
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.

Specified by:
getIncludedLabels in interface ClassSetLabelPatternInterface<L extends LabelInterface>
Returns:
a Set containing all of the Labels specified as being included in the subset this ClassSetLabelPattern specifies.

getIncludedLabelPatterns

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

Specified by:
getIncludedLabelPatterns in interface ClassSetLabelPatternInterface<L extends LabelInterface>
Returns:
a Set containing all of the LabelPatterns specified as participating in determining the subset this ClassSetLabelPattern specifies.

removeIncludedLabel

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

Specified by:
removeIncludedLabel in interface ClassSetLabelPatternInterface<L extends LabelInterface>
Parameters:
label - Label no longer to be included.
Returns:
true if a Label equal to the given Label was specified as being included, false otherwise.
Throws:
java.lang.NullPointerException - if the specified Label is null.

removeIncludedLabels

public boolean removeIncludedLabels(java.util.Set<? extends L> labels)
Removes the specification that each Label in the given Set is to be included in 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, true is returned, otherwise false is returned and this LabelPattern is unchanged.

Specified by:
removeIncludedLabels in interface ClassSetLabelPatternInterface<L extends LabelInterface>
Parameters:
labels - Labels no longer to be included.
Returns:
true If an equal Label (according to its equals method) to any Label in the given Set was specified as being included in the subset this LabelPattern specifies, false otherwise.
Throws:
java.lang.NullPointerException - if the specified Set or any Label it contains is null.

removeIncludedLabelPattern

public boolean removeIncludedLabelPattern(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.

Specified by:
removeIncludedLabelPattern in interface ClassSetLabelPatternInterface<L extends LabelInterface>
Parameters:
labelPattern - LabelPattern no longer to be included.
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.

removeIncludedLabelPatterns

public boolean removeIncludedLabelPatterns(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.

Specified by:
removeIncludedLabelPatterns in interface ClassSetLabelPatternInterface<L extends LabelInterface>
Parameters:
labelPatterns - LabelPatterns no longer to be included.
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, false otherwise.
Throws:
java.lang.NullPointerException - if the specified Set or any LabelPattern it contains is null.