laser.alphabet
Class Alphabet<L extends AbstractLabel>

java.lang.Object
  extended by laser.alphabet.Alphabet<L>
Type Parameters:
L - The type of Labels that this Alphabet contains.
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<L>, java.util.Collection<L>, java.util.Set<L>, AlphabetFactoryInterface<L>, AlphabetInterface<L>, ArtifactInterface, Annotatable, Persistent, Visualizable
Direct Known Subclasses:
IndexedAlphabet

public class Alphabet<L extends AbstractLabel>
extends java.lang.Object
implements AlphabetInterface<L>

An Alphabet containing Labels of type L. Alphabets of this Class are dynamically typesafe; attempting to insert an element not of type L will result in a ClassCastException being thrown.

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), Paula A. Wing
See Also:
AlphabetInterface, Serialized Form

Field Summary
protected  AlphabetFactoryInterface<L> factory
          A reference to the AlphabetFactory that creates Alphabets of this type and Labels of the type this Alphabet contains.
protected  java.util.Set<L> labels
          The underlying Set used to store the Labels in this Alphabet.
 
Fields inherited from interface laser.util.Persistent
PER_EXTENSION, READ_PERSISTENT_METHOD_NAME
 
Constructor Summary
protected Alphabet(Alphabet<L> alphabet)
          Creates an Alphabet that is an unmodifiable view of the specified Alphabet.
protected Alphabet(AlphabetFactoryInterface<L> factory, java.lang.Class<L> labelClass)
          Creates a new Alphabet.
 
Method Summary
 boolean add(L label)
          Adds the specified label to this alphabet and returns true if it is not already contained within the alphabet, otherwise false is returned and the alphabet remains unchanged.
 boolean addAll(java.util.Collection<? extends L> c)
          Adds all of the Labels, which must all be of the type of Label contained in this Alphabet, in the specified Collection to this Alphabet.
 boolean addAnnotation(Annotation annotation)
          Adds the given annotation to the AnnotationTable.
 boolean addAnnotations(java.util.Collection<? extends Annotation> annotations)
          Adds the given annotations to the AnnotationTable.
 void clear()
          Removes all of the Labels from this Alphabet.
 AlphabetInterface<L> clone()
          Returns a copy of this Alphabet.
protected  void collectionChecker(java.util.Collection<?> c)
          This method checks the contents of Label collections, and generates exceptions as needed.
 boolean contains(java.lang.Object label)
          Returns true if the specified Object is contained in this Alphabet, false otherwise.
 boolean containsAll(java.util.Collection<?> c)
          Returns true if this Alphabet contains all of the Objects in the specified Collection.
 boolean copyAnnotations(Annotatable container)
          Copies the annotations within the AnnotationTable that pass the filters into the given Annotatable object.
 AlphabetInterface<L> createAlphabetInterface(java.lang.Object... args)
          Creates an Alphabet of the same type as this one.
 L createLabelInterface(java.lang.String inputString)
          Gets a Label of the type that this Alphabet contains.
 boolean equals(java.lang.Object o)
          Tests the specified Object and this Alphabet for equivalence.
 java.util.Set<java.lang.Class<? extends Annotation>> getAnnotationClasses()
          Gets all of the annotation classes from the AnnotationTable.
 java.util.Set<java.lang.Class<? extends Annotation>> getAnnotationClasses(java.lang.Class<? extends Annotation> query)
          Gets all of the annotation classes from the AnnotationTable that are subclasses of the given one.
 java.util.Set<java.lang.Class<? extends Annotation>> getAnnotationFilters()
          Gets the filters that specify which annotations should be excluded when copying.
 java.util.Collection<Annotation> getAnnotations()
          Gets all of the annotations within the AnnotationTable.
 java.util.Collection<Annotation> getAnnotations(java.lang.Class<? extends Annotation> query)
          Gets all of the annotations of the given annotation class from the AnnotationTable.
 AlphabetChangeManager<L> getChangeManager()
          Returns the AlphabetChangeManager of this alphabet.
 java.lang.Object[] getCreateAlphabetArgs(AlphabetInterface<L> alphabet)
          Gets any required arguments for the create alphabet method from the given alphabet.
 java.lang.String getName()
          Returns the name of this Alphabet.
 java.lang.String getVisExtension()
          Gets the file extension that will be used for the visual form of this artifact.
 int hashCode()
          Returns a hash code value for this Alphabet.
 boolean isEmpty()
          Returns true if this Alphabet contains no Labels, false otherwise.
 boolean isValidLabel(java.lang.String s)
          Returns true if the specified String specifies a valid Label of the type this Alphabet contains, false otherwise.
 java.util.Iterator<L> iterator()
          Returns an Iterator over the Labels in this Alphabet.
static java.lang.Object readPersistent(java.io.InputStream in)
          Reads the Object that was saved by writePersistent from the given InputStream.
static java.lang.Object readPersistent(java.lang.String filename)
          Reads the Object that was saved by writePersistent from the given file.
 boolean remove(java.lang.Object label)
          Removes the specified Object from this Alphabet.
 boolean removeAll(java.util.Collection<?> c)
          Removes from this Alphabet any Object that it contains and that is also contained in the specified Collection.
 boolean removeAnnotation(Annotation annotation)
          Removes the given annotation from the AnnotationTable.
 void removeAnnotations()
          Removes all of the annotations from the AnnotationTable.
 boolean removeAnnotations(java.lang.Class<? extends Annotation> query)
          Removes all of the annotations of the given annotation class from the AnnotationTable.
 boolean removeAnnotations(java.util.Collection<? extends Annotation> annotations)
          Removes the given annotations from the AnnotationTable.
 boolean retainAll(java.util.Collection<?> c)
          Removes all Objects from this Alphabet that are not contained in the specified Collection.
 void setAnnotationFilters(java.util.Set<java.lang.Class<? extends Annotation>> filters)
          Sets the filters that specify which annotations should be excluded when copying.
 void setName(java.lang.String name)
          Sets the name of the Alphabet to the specified String.
 int size()
          Returns the number of Labels contained in this Alphabet.
 java.util.Iterator<L> sortedIterator()
          Returns an Iterator over the Labels in this Alphabet.
 java.lang.Object[] toArray()
          Returns the array representation of this Alphabet.
<T> T[]
toArray(T[] a)
          Returns the Labels contained in this alphabet in an array whose runtime type is that of the specified array, which must be a supertype of the labels.
 java.lang.String toString()
          Returns the String representation of this alphabet.
 AlphabetInterface<L> unmodifiableAlphabet(AlphabetInterface<L> alphabet)
          Returns an unmodifiable view of the specified Alphabet (optional operation).
 void visualize(java.lang.String filename)
          Outputs the visual form of this artifact to the given file.
 void visualize(java.io.Writer out)
          Outputs the visual form of this artifact to the given Writer.
 void writePersistent(java.io.OutputStream out)
          Takes this object and outputs the persistent form of it to the given OutputStream.
 void writePersistent(java.lang.String filename)
          Takes this Object and outputs the persistent form of it to the given file.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

labels

protected java.util.Set<L extends AbstractLabel> labels
The underlying Set used to store the Labels in this Alphabet.


factory

protected transient AlphabetFactoryInterface<L extends AbstractLabel> factory
A reference to the AlphabetFactory that creates Alphabets of this type and Labels of the type this Alphabet contains.

Constructor Detail

Alphabet

protected Alphabet(AlphabetFactoryInterface<L> factory,
                   java.lang.Class<L> labelClass)
Creates a new Alphabet.

Parameters:
factory - A reference to the AlphabetFactory that creates Alphabets of this type and Labels of the type this Alphabet contains.
labelClass - The Class of Label that this Alphabet contains (this should be the same as L).

Alphabet

protected Alphabet(Alphabet<L> alphabet)
Creates an Alphabet that is an unmodifiable view of the specified Alphabet.

Parameters:
alphabet - The Alphabet.
Method Detail

clone

public AlphabetInterface<L> clone()
Returns a copy of this Alphabet.

Specified by:
clone in interface AlphabetInterface<L extends AbstractLabel>
Overrides:
clone in class java.lang.Object
Returns:
The copy.
Throws:
InconsistentObjectError - if an error occurs while copying the Alphabet.
See Also:
Object.clone()

getName

public java.lang.String getName()
Returns the name of this Alphabet.

Specified by:
getName in interface AlphabetInterface<L extends AbstractLabel>
Returns:
the name of this Alphabet.

setName

public void setName(java.lang.String name)
Sets the name of the Alphabet to the specified String.

Fires an AlphabetChangeEvent.

Specified by:
setName in interface AlphabetInterface<L extends AbstractLabel>
Parameters:
name - the String.

toString

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

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

getChangeManager

public AlphabetChangeManager<L> getChangeManager()
Returns the AlphabetChangeManager of this alphabet.

Specified by:
getChangeManager in interface AlphabetInterface<L extends AbstractLabel>
Returns:
The AlphabetChangeManager of this alphabet

collectionChecker

protected void collectionChecker(java.util.Collection<?> c)
This method checks the contents of Label collections, and generates exceptions as needed.

Parameters:
c - the Collection to be checked.

createLabelInterface

public L createLabelInterface(java.lang.String inputString)
                                             throws AlphabetInterfaceException
Gets a Label of the type that this Alphabet contains. All Labels participate in flyweighting, (Design Patterns, Gamma, Helm, Johnson, and Vlissides, p195, 1995) thus all Alphabet Factories are responsible for maintaining a repository of Labels of the type they create. If the Label specified by the inputString already exists, a reference to it is returned. Otherwise, a new Label is constructed from the inputString, added to the repository, and returned.

Specified by:
createLabelInterface in interface AlphabetFactoryInterface<L extends AbstractLabel>
Parameters:
inputString - The String from which the Label is constructed.
Returns:
The Label.
Throws:
AlphabetInterfaceException - When the label for the specified inputSting cannot be retrieved or constructed.

createAlphabetInterface

public AlphabetInterface<L> createAlphabetInterface(java.lang.Object... args)
                                                                   throws AlphabetInterfaceException
Creates an Alphabet of the same type as this one.

Specified by:
createAlphabetInterface in interface AlphabetFactoryInterface<L extends AbstractLabel>
Parameters:
args - The input arguments used in the construction of the Alphabet.
Returns:
The Alphabet.
Throws:
AlphabetInterfaceException - When the Alphabet cannot be created from the specified input arguments.

getCreateAlphabetArgs

public java.lang.Object[] getCreateAlphabetArgs(AlphabetInterface<L> alphabet)
Gets any required arguments for the create alphabet method from the given alphabet. PRECONDITION: The alphabet must be non-null.

Specified by:
getCreateAlphabetArgs in interface AlphabetFactoryInterface<L extends AbstractLabel>
Parameters:
alphabet - The alphabet to use as a prototype
Returns:
Any required arguments for the create alphabet method

isValidLabel

public boolean isValidLabel(java.lang.String s)
Returns true if the specified String specifies a valid Label of the type this Alphabet contains, false otherwise.

Specified by:
isValidLabel in interface AlphabetFactoryInterface<L extends AbstractLabel>
Parameters:
s - The String.
Returns:
true if the specified String specifies a valid Label of the type this Alphabet contains, false otherwise.
Throws:
java.lang.NullPointerException - The specified String is null.
See Also:
createLabelInterface(String)

unmodifiableAlphabet

public AlphabetInterface<L> unmodifiableAlphabet(AlphabetInterface<L> alphabet)
Returns an unmodifiable view of the specified Alphabet (optional operation). Any attempt to modify the returned Alphabet will result in an UnsupportedOperationException being thrown.

Specified by:
unmodifiableAlphabet in interface AlphabetFactoryInterface<L extends AbstractLabel>
Parameters:
alphabet - The Alphabet.
Returns:
An unmodifiable view of the specified Alphabet.
Throws:
java.lang.NullPointerException - the specified Alphabet is null.
java.lang.UnsupportedOperationException - this method is not supported.

add

public boolean add(L label)
Adds the specified label to this alphabet and returns true if it is not already contained within the alphabet, otherwise false is returned and the alphabet remains unchanged.

Fires an AlphabetChangeEvent.

Specified by:
add in interface java.util.Collection<L extends AbstractLabel>
Specified by:
add in interface java.util.Set<L extends AbstractLabel>
Parameters:
label - Label to be added to this alphabet.
Returns:
true if the alphabet did not already contain the specified Label, false otherwise.
Throws:
java.lang.ClassCastException - if the specified Object is not of type L.
java.lang.NullPointerException - if the specified Label is null.
See Also:
Set.add(E)

addAll

public boolean addAll(java.util.Collection<? extends L> c)
Adds all of the Labels, which must all be of the type of Label contained in this Alphabet, in the specified Collection to this Alphabet. If all of the Labels in the specified Collection are already contained within this Alphabet, the Alphabet remains unchanged and false is returned. If any of the Labels are not so contained, they are added and true is returned.

* Fires one AlphabetChangeEvent for each Label added.

Specified by:
addAll in interface java.util.Collection<L extends AbstractLabel>
Specified by:
addAll in interface java.util.Set<L extends AbstractLabel>
Parameters:
c - The Collection containing the Labels to be added.
Returns:
true if any Labels were actually added to this Alphabet.
Throws:
java.lang.ClassCastException - if any element of the specified Collection is not of type L.
java.lang.NullPointerException - if the specified Collection or any Label contained in it is null. No labels are added if any Label is null.
See Also:
Set.addAll(java.util.Collection)

clear

public void clear()
Removes all of the Labels from this Alphabet.

Fires one AlphabetChangeEvent for each Label removed.

Specified by:
clear in interface java.util.Collection<L extends AbstractLabel>
Specified by:
clear in interface java.util.Set<L extends AbstractLabel>
See Also:
Set.clear()

contains

public boolean contains(java.lang.Object label)
Returns true if the specified Object is contained in this Alphabet, false otherwise.

Specified by:
contains in interface java.util.Collection<L extends AbstractLabel>
Specified by:
contains in interface java.util.Set<L extends AbstractLabel>
Parameters:
label - the Object to be checked for containment in this Alphabet.
Returns:
true if this Alphabet contains the specified Object, false otherwise.
Throws:
java.lang.ClassCastException - if the specified Object cannot be compared with the elements currently in the Alphabet.
java.lang.NullPointerException - When the specified Object is null.
See Also:
Set.contains(java.lang.Object)

containsAll

public boolean containsAll(java.util.Collection<?> c)
Returns true if this Alphabet contains all of the Objects in the specified Collection. If any Objects in the specified Collection are not contained in this Alphabet, false is returned.

Specified by:
containsAll in interface java.util.Collection<L extends AbstractLabel>
Specified by:
containsAll in interface java.util.Set<L extends AbstractLabel>
Parameters:
c - Collection containing Objects to be checked for containment in this Alphabet.
Returns:
true if this Alphabet contains all of the Objects in the specified Collection.
Throws:
java.lang.ClassCastException - if any element of the specified Collection is not of type L.
java.lang.NullPointerException - if the specified Collection or any of its elements are null.
See Also:
contains(java.lang.Object), Set.containsAll(java.util.Collection)

equals

public boolean equals(java.lang.Object o)
Tests the specified Object and this Alphabet for equivalence. Returns true if the given Object is also an Alphabet of the same type as this one, the two Alphabets have the same size, and every Label in the specified Alphabet is contained in this Alphabet.

Specified by:
equals in interface java.util.Collection<L extends AbstractLabel>
Specified by:
equals in interface java.util.Set<L extends AbstractLabel>
Overrides:
equals in class java.lang.Object
Parameters:
o - Object to be tested for equality with this Alphabet.
Returns:
true if the specified object and this alphabet are equivalent, false otherwise.
See Also:
Set.equals(java.lang.Object)

hashCode

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

Specified by:
hashCode in interface java.util.Collection<L extends AbstractLabel>
Specified by:
hashCode in interface java.util.Set<L extends AbstractLabel>
Overrides:
hashCode in class java.lang.Object
Returns:
the hash code value for this Alphabet.
See Also:
Set.hashCode()

isEmpty

public boolean isEmpty()
Returns true if this Alphabet contains no Labels, false otherwise.

Specified by:
isEmpty in interface java.util.Collection<L extends AbstractLabel>
Specified by:
isEmpty in interface java.util.Set<L extends AbstractLabel>
Returns:
true if this Alphabet contains no Labels, false otherwise.
See Also:
Set.isEmpty()

iterator

public java.util.Iterator<L> iterator()
Returns an Iterator over the Labels in this Alphabet. No guarantee is made as to the ordering of the Labels.

Specified by:
iterator in interface java.lang.Iterable<L extends AbstractLabel>
Specified by:
iterator in interface java.util.Collection<L extends AbstractLabel>
Specified by:
iterator in interface java.util.Set<L extends AbstractLabel>
Returns:
an Iterator over the Labels in this Alphabet.
See Also:
Set.iterator()

sortedIterator

public java.util.Iterator<L> sortedIterator()
Returns an Iterator over the Labels in this Alphabet. The Labels are returned in ascending order according to their natural ordering (using their compareTo() method).

Specified by:
sortedIterator in interface AlphabetInterface<L extends AbstractLabel>
Returns:
an Iterator over the Labels in this Alphabet.

remove

public boolean remove(java.lang.Object label)
Removes the specified Object from this Alphabet. If the Object is present, it is removed and true is returned. If it is not present, the Alphabet remains unchanged and false is returned.

Fires an AlphabetChangeEvent if the Object is removed.

Specified by:
remove in interface java.util.Collection<L extends AbstractLabel>
Specified by:
remove in interface java.util.Set<L extends AbstractLabel>
Parameters:
label - Object to be removed from this Alphabet.
Returns:
true if the Alphabet contained the specified Label, false otherwise.
Throws:
java.lang.ClassCastException - if the specified Object cannot be compared with the elements currently in the Alphabet.
java.lang.NullPointerException - When the specified Object is null.
See Also:
Set.remove(java.lang.Object)

removeAll

public boolean removeAll(java.util.Collection<?> c)
Removes from this Alphabet any Object that it contains and that is also contained in the specified Collection. If any Objects are so removed, true is returned, otherwise false is returned.

Fires an AlphabetChangeEvent for each Object removed.

Specified by:
removeAll in interface java.util.Collection<L extends AbstractLabel>
Specified by:
removeAll in interface java.util.Set<L extends AbstractLabel>
Parameters:
c - Collection containing Objects to be removed from this Alphabet.
Returns:
true if any Object was actually removed from this Alphabet.
Throws:
java.lang.ClassCastException - if any element of the specified Collection is not of type L.
java.lang.NullPointerException - if the specified Collection or any of its elements are null. No labels are removed if any Label is null.
See Also:
remove(java.lang.Object), Set.removeAll(java.util.Collection)

retainAll

public boolean retainAll(java.util.Collection<?> c)
Removes all Objects from this Alphabet that are not contained in the specified Collection. If any Objects are so removed, true is returned, otherwise false is returned.

Fires an AlphabetChangeEvent for each Object removed.

Specified by:
retainAll in interface java.util.Collection<L extends AbstractLabel>
Specified by:
retainAll in interface java.util.Set<L extends AbstractLabel>
Parameters:
c - Collection containing Objects to be retained in this Alphabet.
Returns:
true if any Object was actually removed from this Alphabet.
Throws:
java.lang.ClassCastException - if any element of the specified Collection is not of type L.
java.lang.NullPointerException - if the specified Collection or any of its elements are null. No labels are removed if any Label is null.
See Also:
remove(java.lang.Object), contains(java.lang.Object), Set.retainAll(java.util.Collection)

size

public int size()
Returns the number of Labels contained in this Alphabet.

Specified by:
size in interface java.util.Collection<L extends AbstractLabel>
Specified by:
size in interface java.util.Set<L extends AbstractLabel>
Returns:
the number of Labels contained in this Alphabet.
See Also:
Set.size()

toArray

public java.lang.Object[] toArray()
Returns the array representation of this Alphabet. A new array of Labels of the appropriate type for this Alphabet is allocated, and the Labels contained within this Alphabet are placed in the array starting at location 0 in ascending order according to their natural ordering (using their compareTo method). No references to the Alphabet are maintained by the array, so changing the array will not affect the alphabet and vice versa.

Specified by:
toArray in interface java.util.Collection<L extends AbstractLabel>
Specified by:
toArray in interface java.util.Set<L extends AbstractLabel>
Returns:
an array containing all of the Labels in this Alphabet.
See Also:
Set.toArray()

toArray

public <T> T[] toArray(T[] a)
Returns the Labels contained in this alphabet in an array whose runtime type is that of the specified array, which must be a supertype of the labels. If the specified array is large enough to hold all of the labels, then they are placed in the array and a reference to it is returned, otherwise a new array of the correct type is allocated.

The labels contained within this alphabet are placed in the array starting at location 0 in ascending order according to their natural ordering (using their compareTo method). No references to the alphabet are maintained by the array, so changing the array will not affect the alphabet and vice versa.

If the labels were actually placed in the specified array, and its capacity is larger than the size of this alphabet, the element of the array immediately after the one containing the last label is set to null.

Specified by:
toArray in interface java.util.Collection<L extends AbstractLabel>
Specified by:
toArray in interface java.util.Set<L extends AbstractLabel>
Parameters:
a - An array specifying the runtime type of the array in which the labels contained in this alphabet will be placed; this array itself will actually be used if it is large enough
Returns:
an array containing the Labels in the Alphabet.
Throws:
java.lang.NullPointerException - if the specified array is null.
java.lang.ArrayStoreException - if the runtime type of the specified array is not a supertype of the Labels of this Alphabet
See Also:
Set.toArray(Object[])

getVisExtension

public java.lang.String getVisExtension()
Gets the file extension that will be used for the visual form of this artifact.

Specified by:
getVisExtension in interface Visualizable
Returns:
The visual file extension.

writePersistent

public void writePersistent(java.lang.String filename)
                     throws java.io.IOException,
                            PersistentException
Takes this Object and outputs the persistent form of it to the given file.

Specified by:
writePersistent in interface Persistent
Parameters:
filename - The name of the file to use.
Throws:
java.io.IOException - if an I/O error occurrs.
PersistentException - if there is a problem with the persistence process.

writePersistent

public void writePersistent(java.io.OutputStream out)
                     throws java.io.IOException,
                            PersistentException
Takes this object and outputs the persistent form of it to the given OutputStream.

Specified by:
writePersistent in interface Persistent
Parameters:
out - The OutputStream to use.
Throws:
java.io.IOException - if an I/O error occurrs.
PersistentException - if there is a problem with the persistence process.

readPersistent

public static java.lang.Object readPersistent(java.io.InputStream in)
                                       throws java.io.IOException,
                                              PersistentException
Reads the Object that was saved by writePersistent from the given InputStream.

Parameters:
in - The InputStream to use
Returns:
The Object.
Throws:
java.io.IOException - if an I/O error occurs.
PersistentException - if there is a problem with the persistence process.

readPersistent

public static java.lang.Object readPersistent(java.lang.String filename)
                                       throws java.io.IOException,
                                              PersistentException
Reads the Object that was saved by writePersistent from the given file.

Parameters:
filename - The name of the file to use.
Returns:
The Object that was saved by writePersistent.
Throws:
java.io.IOException - if an I/O error occurs.
PersistentException - if there is a problem with the persistence process.

visualize

public void visualize(java.lang.String filename)
               throws java.io.IOException,
                      VisualizableException
Outputs the visual form of this artifact to the given file.

NOTE: If the file name does not already end with the visual file extension, then it will be added.

Specified by:
visualize in interface Visualizable
Parameters:
filename - The name of the file to output the visual form to.
Throws:
java.io.IOException - an IO error occurred during the write.
VisualizableException - an error occurred while creating the visual form of the artifact.

visualize

public void visualize(java.io.Writer out)
               throws java.io.IOException,
                      VisualizableException
Outputs the visual form of this artifact to the given Writer.

Specified by:
visualize in interface Visualizable
Parameters:
out - a Writer to output the visual form to.
Throws:
java.io.IOException - an IO error occurred during the write.
VisualizableException - an error occurred while creating the visual form of the artifact.

addAnnotation

public boolean addAnnotation(Annotation annotation)
Adds the given annotation to the AnnotationTable.

Fires an AlphabetChangedEvent.

Specified by:
addAnnotation in interface Annotatable
Parameters:
annotation - The Annotation to be added
Returns:
True if it was added and false otherwise
Throws:
java.lang.IllegalArgumentException - if the annotation is null

addAnnotations

public boolean addAnnotations(java.util.Collection<? extends Annotation> annotations)
Adds the given annotations to the AnnotationTable.

Fires an AlphabetChangedEvent for each Annotation added.

Specified by:
addAnnotations in interface Annotatable
Parameters:
annotations - The Set of Annotations to be added
Returns:
True if any annotation was added and false otherwise
Throws:
java.lang.IllegalArgumentException - if annotations is null or any annotation is null

copyAnnotations

public boolean copyAnnotations(Annotatable container)
Copies the annotations within the AnnotationTable that pass the filters into the given Annotatable object.

Specified by:
copyAnnotations in interface Annotatable
Parameters:
container - The Annotatable that the copied Annotations will be associated with
Returns:
True if any annotation was copied and false otherwise
See Also:
Annotatable.getAnnotationFilters()

getAnnotationClasses

public java.util.Set<java.lang.Class<? extends Annotation>> getAnnotationClasses(java.lang.Class<? extends Annotation> query)
Gets all of the annotation classes from the AnnotationTable that are subclasses of the given one.

Specified by:
getAnnotationClasses in interface Annotatable
Parameters:
query - The Annotation Class to obtain the subclasses of
Returns:
A Set of all of the Annotation Classes that are subclasses of the given class
Throws:
java.lang.IllegalArgumentException - if query is null

getAnnotationClasses

public java.util.Set<java.lang.Class<? extends Annotation>> getAnnotationClasses()
Gets all of the annotation classes from the AnnotationTable.

Specified by:
getAnnotationClasses in interface Annotatable
Returns:
A Set of all of the Annotation Classes

getAnnotations

public java.util.Collection<Annotation> getAnnotations(java.lang.Class<? extends Annotation> query)
Gets all of the annotations of the given annotation class from the AnnotationTable.

Specified by:
getAnnotations in interface Annotatable
Parameters:
query - The Annotation Class of interest
Returns:
A Collection of all of the Annotations of the specified Annotation Class
Throws:
java.lang.IllegalArgumentException - if query is null

getAnnotations

public java.util.Collection<Annotation> getAnnotations()
Gets all of the annotations within the AnnotationTable.

Specified by:
getAnnotations in interface Annotatable
Returns:
A Collection of all of the Annotations

getAnnotationFilters

public java.util.Set<java.lang.Class<? extends Annotation>> getAnnotationFilters()
Gets the filters that specify which annotations should be excluded when copying.

Specified by:
getAnnotationFilters in interface Annotatable
Returns:
A Set of all the filters
See Also:
#copy, copyAnnotations(laser.util.Annotatable)

setAnnotationFilters

public void setAnnotationFilters(java.util.Set<java.lang.Class<? extends Annotation>> filters)
Sets the filters that specify which annotations should be excluded when copying.

Specified by:
setAnnotationFilters in interface Annotatable
Parameters:
filters - The Set of all the filters
See Also:
#copy, copyAnnotations(laser.util.Annotatable)

removeAnnotation

public boolean removeAnnotation(Annotation annotation)
Removes the given annotation from the AnnotationTable.

Fires an AlphabetChangedEvent.

Specified by:
removeAnnotation in interface Annotatable
Parameters:
annotation - The Annotation to remove
Returns:
True if it was removed and false otherwise
Throws:
java.lang.IllegalArgumentException - if annotation is null

removeAnnotations

public boolean removeAnnotations(java.util.Collection<? extends Annotation> annotations)
Removes the given annotations from the AnnotationTable.

Fires an AlphabetChangedEvent for each Annotation removed.

Specified by:
removeAnnotations in interface Annotatable
Parameters:
annotations - The Set of Annotations to be removed
Returns:
True if any annotation was removed and false otherwise
Throws:
java.lang.IllegalArgumentException - if annotations is null or any annotation is null

removeAnnotations

public boolean removeAnnotations(java.lang.Class<? extends Annotation> query)
Removes all of the annotations of the given annotation class from the AnnotationTable.

Fires an AlphabetChangedEvent for each Annotation removed.

*

Specified by:
removeAnnotations in interface Annotatable
Parameters:
query - The Annotation Class to be removed
Returns:
True if any annotation was removed and false otherwise
Throws:
java.lang.IllegalArgumentException - if query is null

removeAnnotations

public void removeAnnotations()
Removes all of the annotations from the AnnotationTable.

Fires an AlphabetChangedEvent for each Annotation removed.

Specified by:
removeAnnotations in interface Annotatable