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

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

public class NotClassSetLabelPattern<L extends LabelInterface>
extends AbstractClassSetLabelPattern<L>
implements NotClassSetLabelPatternInterface<L>

This class represents a "not class set" LabelPattern. The LabelPattern ~ or "not class set," with respect to an Alphabet of the correct type, specifies the subset, S, of all Labels in the Alphabet except for certain Labels that have been explicitly specified as being excluded from the subset, N. 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.NotClassSetLabelPatternInterface, laser.alphabetinterface.labelpatterninterface.LabelPatternFactoryInterface, Serialized Form

Field Summary
 
Fields inherited from class laser.alphabet.labelpattern.AbstractClassSetLabelPattern
labelClass, labelPatterns, labels
 
Constructor Summary
protected NotClassSetLabelPattern(java.lang.Class<L> labelClass)
          Creates a new "not class set" LabelPattern.
 
Method Summary
 boolean addExcludedLabel(L label)
          Specifies the given Label as being excluded from the subset this LabelPattern specifies.
 boolean addExcludedLabelPattern(LabelPatternInterface<L> labelPattern)
          Specifies the given LabelPattern as participating in determining the subset this LabelPattern specifies.
 boolean addExcludedLabelPatterns(java.util.Set<? extends LabelPatternInterface<L>> labelPatterns)
          Specifies each LabelPattern in the given Set as participating in determining the subset this LabelPattern specifies.
 boolean addExcludedLabels(java.util.Set<? extends L> labels)
          Specifies each Label in the given Set as being excluded from the subset this LabelPattern specifies.
 NotClassSetLabelPatternInterface<L> clone()
          Returns a copy of this NotClassSetLabelPattern.
 java.util.Set<LabelPatternInterface<L>> getExcludedLabelPatterns()
          Returns a Set containing all of the LabelPatterns specified as participating in determining the the subset this NotClassSetLabelPattern specifies.
 java.util.Set<L> getExcludedLabels()
          Returns a Set containing all of the Labels specified as being excluded from the subset this NotClassSetLabelPattern 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 NotClassSetLabelPattern.
 boolean removeExcludedLabel(L label)
          Removes the specification that the given Label is to be excluded from the subset this LabelPattern specifies.
 boolean removeExcludedLabelPattern(LabelPatternInterface<L> labelPattern)
          Removes the specification that the given LabelPattern is to participate in determining the subset this LabelPattern specifies.
 boolean removeExcludedLabelPatterns(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 removeExcludedLabels(java.util.Set<? extends L> labels)
          Removes the specification that each Label in the given Set is to be excluded from the subset this LabelPattern specifies.
 java.lang.String toString()
          Returns the String representation of this NotClassSetLabelPattern.
 
Methods inherited from class laser.alphabet.labelpattern.AbstractClassSetLabelPattern
addLabel, addLabelPattern, addLabelPatterns, addLabels, compareTo, equals, getLabelPatterns, getLabels, removeLabel, removeLabelPattern, removeLabelPatterns, removeLabels
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface laser.alphabet.labelpattern.LabelPatternInterface
equals
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Constructor Detail

NotClassSetLabelPattern

protected NotClassSetLabelPattern(java.lang.Class<L> labelClass)
Creates a new "not 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 NotClassSetLabelPatternInterface<L> clone()
Returns a copy of this NotClassSetLabelPattern.

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()

hashCode

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

Specified by:
hashCode in interface LabelPatternInterface<L extends LabelInterface>
Overrides:
hashCode in class AbstractClassSetLabelPattern<L extends LabelInterface>
Returns:
A hash code value for this NotClassSetLabelPattern.

toString

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

Overrides:
toString in class AbstractClassSetLabelPattern<L extends LabelInterface>
Returns:
The String representation of this NotClassSetLabelPattern.
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>
Overrides:
getMatchingLabels in class AbstractClassSetLabelPattern<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.
See Also:
laser.alphabetinterface.labelpatterninterface.NotClassSetLabelPatternInterface

addExcludedLabel

public boolean addExcludedLabel(L label)
Specifies the given Label as being excluded from the subset this LabelPattern specifies. If an equal Label (according to its equals method) is already specified as being so excluded, false is returned and this NotClassSetLabelPattern 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:
addExcludedLabel in interface NotClassSetLabelPatternInterface<L extends LabelInterface>
Parameters:
label - Label to be excluded.
Returns:
false if an equal Label is already specified as being excluded, true otherwise.
Throws:
java.lang.ClassCastException - the specified Label is not of type L.
java.lang.NullPointerException - if the specified Label is null.

addExcludedLabels

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

Specified by:
addExcludedLabels in interface NotClassSetLabelPatternInterface<L extends LabelInterface>
Parameters:
labels - Labels to be excluded.
Returns:
false if an equal Label (according to its equals method) to every Label in the given Set is already specified as being 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.

addExcludedLabelPattern

public boolean addExcludedLabelPattern(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 NotClassSetLabelPattern 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:
addExcludedLabelPattern in interface NotClassSetLabelPatternInterface<L extends LabelInterface>
Parameters:
labelPattern - LabelPattern to be excluded.
Returns:
false if an equal LabelPattern is already specified as participating, true otherwise.
Throws:
java.lang.NullPointerException - if the specified LabelPattern is null.

addExcludedLabelPatterns

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

The specified LabelPatterns may not be ClassSet or NotClassSetLabelPatterns.

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:
addExcludedLabelPatterns in interface NotClassSetLabelPatternInterface<L extends LabelInterface>
Parameters:
labelPatterns - LabelPatterns to be 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.

getExcludedLabels

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

Specified by:
getExcludedLabels in interface NotClassSetLabelPatternInterface<L extends LabelInterface>
Returns:
a Set containing all of the Labels specified as being excluded from the subset this NotClassSetLabelPattern specifies.

getExcludedLabelPatterns

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

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

removeExcludedLabel

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

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

removeExcludedLabels

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

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

removeExcludedLabelPattern

public boolean removeExcludedLabelPattern(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 NotClassSetLabelPattern is unchanged.

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

removeExcludedLabelPatterns

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