laser.regularlanguage.fsa
Class AbstractFSA<L extends LabelInterface>

java.lang.Object
  extended by laser.regularlanguage.fsa.AbstractFSA<L>
Type Parameters:
L - The type of Label associated with this FSA.
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, ArtifactInterface, FSAInterface<L>, Annotatable, Persistent, Visualizable
Direct Known Subclasses:
AbstractMutableFSA, AbstractRunnableFSA

public abstract class AbstractFSA<L extends LabelInterface>
extends java.lang.Object
implements FSAInterface<L>

An abstract FSA class that provides common functionality for FSAs of type FSAInterface.

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

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

Field Summary
protected  AlphabetInterface<L> _alphabet
          The Alphabet of this FSA, Σ.
protected  AbstractFSAFactory<L> _factory
          A reference to the factory that creates FSAs of this type.
protected  int _nextStateID
          The ID for the next state to be added to this FSA.
protected  int _nextTransitionID
          The ID for the next transition to be added to this FSA.
protected  FSAStateInterface<L> _startState
          The start state of this FSA, q0.
protected  java.util.SortedSet<FSAStateInterface<L>> _states
          The set of states of this FSA, Q.
protected  java.util.Map<FSAStateInterface<L>,java.util.Map<FSAStateInterface<L>,java.util.SortedSet<FSATransitionInterface<L>>>> _transitionIndex
          The top level of a hierarchical structure of Maps that provides the functionality to efficiently retrieve transitions based on their source and target states.
protected  java.util.SortedSet<FSATransitionInterface<L>> _transitions
          The set of transitions of this FSA, T.
 
Fields inherited from interface laser.util.Persistent
PER_EXTENSION, READ_PERSISTENT_METHOD_NAME
 
Constructor Summary
protected AbstractFSA(AbstractFSA<L> fsa)
          Creates a new FSA with the same states, transitions, and Alphabet as the specified FSA (copy constructor).
protected AbstractFSA(AlphabetInterface<L> alphabet, AbstractFSAFactory<L> factory)
          Returns a new AbstractFSA with the specified Alphabet and factory.
 
Method Summary
protected  void _checkLabel(L label)
          Checks the specified Label, making sure it is not null and is contained in the Alphabet of this FSA.
protected  void _checkState(FSAStateInterface<L> state)
          Checks the specified state, making sure it is not null and is a part of this FSA.
protected  void _checkTransition(FSATransitionInterface<L> transition)
          Checks the specified transition, making sure it is not null and is a part of this FSA.
protected  void _internalAddTransition(FSATransitionInterface<L> transition)
          Adds the specified transition to the internal data structures of this FSA and indexes it properly.
protected  void _internalCopyFSAAttributes(FSAInterface<L> fsa)
          Copies the attributes from the given FSA into this FSA.
protected  void _internalRemoveState(FSAStateInterface<L> state)
          Removes the specified state from the internal data structures of this FSA.
protected  void _internalRemoveTransition(FSATransitionInterface<L> transition)
          Removes the specified transition from the internal data structures of this FSA.
 boolean addAnnotation(Annotation annotation)
          Associates the given Annotation with this Object.
 boolean addAnnotations(java.util.Collection<? extends Annotation> annotations)
          Associates all of the Annotations in the given Collection with this Object.
 java.util.List<java.lang.String> checkWellFormed()
          Checks that this FSA is well-formed and returns a List of any well-formedness violitions if they exist.
abstract  FSAInterface<L> clone()
          Returns a copy of this FSA.
 boolean copyAnnotations(Annotatable container)
          Copies all of the Annotations associated with this Object that pass the filters and associates them with the specified Object.
 java.util.SortedSet<? extends FSAStateInterface<L>> getAcceptStates()
          Returns an unmodifiable view of the set A, the accept states of this FSA.
 AlphabetInterface<L> getAlphabet()
          Returns an unmodifiable view of the Alphabet, Σ, of this FSA.
 java.util.Set<java.lang.Class<? extends Annotation>> getAnnotationClasses()
          Gets all of the Annotation Classes associated with this Object.
 java.util.Set<java.lang.Class<? extends Annotation>> getAnnotationClasses(java.lang.Class<? extends Annotation> query)
          Gets all of the Annotation Classes associated with this Object of the specified Annotation Class.
 java.util.Set<java.lang.Class<? extends Annotation>> getAnnotationFilters()
          Gets the filters to use when copying the Annotations.
 java.util.Collection<Annotation> getAnnotations()
          Gets all of the Annotations associated with this Object.
 java.util.Collection<Annotation> getAnnotations(java.lang.Class<? extends Annotation> query)
          Gets all of the Annotations associated with this Object that have an equal Class to or are a Subclass of the Class of the specified Annotation.
 java.lang.StringBuffer getDescription()
          Returns the description of this FSA or null if one has not been specified.
protected  FSADotWriter<L> getDotWriter()
          Gets the FSADotWriter to be used by this FSA.
 FSAEpsilonTransitionInterface<L> getEpsilonTransition(FSAStateInterface<L> source, FSAStateInterface<L> target)
          Returns the transition from the specified source state to the specified target state on epsilon (ε) if one exists in the FSA, otherwise null is returned (optional operation).
 AbstractFSAFactory<L> getFactory()
          Returns a reference to a factory that creates FSAs of this type.
 java.lang.String getName()
          Returns the name of this FSA.
 java.util.SortedSet<? extends FSAStateInterface<L>> getNonAcceptStates()
          Returns an unmodifiable view of the set QA, of this FSA.
 FSAStateInterface<L> getStartState()
          Returns the start state, q0, of the FSA.
 java.util.SortedSet<? extends FSAStateInterface<L>> getStates()
          Returns an unmodifiable view of the set Q, the states of the FSA.
 FSAStateInterface<L> getStateWithID(int id)
          Returns the state of this FSA with the specified id number.
 FSALabelTransitionInterface<L> getTransition(FSAStateInterface<L> source, L label, FSAStateInterface<L> target)
          Returns the transition from the specified source state to the specified target state on an equal Label to the given Label if one exists in the FSA, otherwise null is returned.
 java.util.SortedSet<? extends FSATransitionInterface<L>> getTransitions()
          Returns an unmodifiable view of the set T, the transitions of the FSA.
 java.util.SortedSet<? extends FSATransitionInterface<L>> getTransitions(FSAStateInterface<L> source, FSAStateInterface<L> target)
          Returns a non-null Set containing all the transitions from the specified source to the given target state.
 FSATransitionInterface<L> getTransitionWithID(int id)
          Returns the transition of this FSA with the specified id number.
 java.lang.String getVisExtension()
          Gets the file extension that will be used for the visual form of this artifact.
 boolean hasTransitionsOnEpsilon()
          Returns true if this FSA has any transitions on epsilon, false otherwise (optional operation).
 boolean isDeterministic()
          Returns true if this FSA is deterministic and false otherwise.
 boolean isTotal()
          Returns true if this FSA is total, false otherwise.
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 removeAnnotation(Annotation annotation)
          Removes the association of the given Annotation with this Object.
 void removeAnnotations()
          Removes all of the Annotations associated with this Object.
 boolean removeAnnotations(java.lang.Class<? extends Annotation> query)
          Removes the association of all of the Annotations of the specified Class or Subclasses of the specified Class with this Object, returning true if any Annotations were so associated, false otherwise.
 boolean removeAnnotations(java.util.Collection<? extends Annotation> annotations)
          Removes the association of all the Annotations in the given Collection with this Object.
 void setAnnotationFilters(java.util.Set<java.lang.Class<? extends Annotation>> filters)
          Sets the filters to use when copying the Annotations.
 void setDescription(java.lang.StringBuffer description)
          Sets the description of this FSA to a copy of the specified StringBuffer.
 void setName(java.lang.String name)
          Sets the name of this FSA to the specified String.
 void toDot(java.lang.String filename)
          Outputs this FSA in dot format to the file with the given name to use as output.
 void toDot(java.io.Writer out)
          Outputs this FSA in dot format to the given Writer to use as output.
 void visualize(java.lang.String filename)
          Outputs the visual form of this object to the given file.
 void visualize(java.io.Writer out)
          Outputs the visual form of this object 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
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface laser.regularlanguage.fsa.FSAInterface
supportsEpsilonTransitions, supportsNondeterminism
 

Field Detail

_states

protected final java.util.SortedSet<FSAStateInterface<L extends LabelInterface>> _states
The set of states of this FSA, Q.


_alphabet

protected final AlphabetInterface<L extends LabelInterface> _alphabet
The Alphabet of this FSA, Σ.


_startState

protected FSAStateInterface<L extends LabelInterface> _startState
The start state of this FSA, q0.


_transitions

protected final java.util.SortedSet<FSATransitionInterface<L extends LabelInterface>> _transitions
The set of transitions of this FSA, T. Two references are maintained to each transition: one in this SortedSet and another in the hierarchical structure of Maps in which the set of transitions from one state to another is indexed first by the source state then by the target state.

See Also:
_transitionIndex

_transitionIndex

protected final java.util.Map<FSAStateInterface<L extends LabelInterface>,java.util.Map<FSAStateInterface<L extends LabelInterface>,java.util.SortedSet<FSATransitionInterface<L extends LabelInterface>>>> _transitionIndex
The top level of a hierarchical structure of Maps that provides the functionality to efficiently retrieve transitions based on their source and target states. This Map maps the source states of the transitions to the second level of the hierarchy, a Map from the target state of the transitions to Sets containing the transitions from the given source to the given target states.


_nextStateID

protected int _nextStateID
The ID for the next state to be added to this FSA.


_nextTransitionID

protected int _nextTransitionID
The ID for the next transition to be added to this FSA.


_factory

protected final AbstractFSAFactory<L extends LabelInterface> _factory
A reference to the factory that creates FSAs of this type.

Constructor Detail

AbstractFSA

protected AbstractFSA(AlphabetInterface<L> alphabet,
                      AbstractFSAFactory<L> factory)
Returns a new AbstractFSA with the specified Alphabet and factory.

PRECONDITIONS:

Parameters:
alphabet - The Alphabet.
factory - The factory.

AbstractFSA

protected AbstractFSA(AbstractFSA<L> fsa)
Creates a new FSA with the same states, transitions, and Alphabet as the specified FSA (copy constructor). The annotations on the FSA, its states and transitions are also copied.

PRECONDITION: The fsa must be non-null.

Parameters:
fsa - The FSA.
Method Detail

_internalAddTransition

protected void _internalAddTransition(FSATransitionInterface<L> transition)
Adds the specified transition to the internal data structures of this FSA and indexes it properly.

Precondition: transition has been properly instantiated as a transition in this FSA with source and target states in this FSA, and as appropriate, a Label in the Alphabet of this FSA.

This method should not be called except by the appropriate transition adding methods of this class and its subclasses.

Parameters:
transition - The non-null transition.

_internalCopyFSAAttributes

protected void _internalCopyFSAAttributes(FSAInterface<L> fsa)
Copies the attributes from the given FSA into this FSA.

Parameters:
fsa - The FSA to be copied from

_internalRemoveState

protected void _internalRemoveState(FSAStateInterface<L> state)
Removes the specified state from the internal data structures of this FSA. Also removes all transitions with the state as its source or target.

This method should only be called by the AbstractMutableFSA.removeState(laser.regularlanguage.fsa.FSAStateInterface) method.

Parameters:
state - The non-null state.
See Also:
AbstractMutableFSA.removeState(laser.regularlanguage.fsa.FSAStateInterface)

_internalRemoveTransition

protected void _internalRemoveTransition(FSATransitionInterface<L> transition)
Removes the specified transition from the internal data structures of this FSA.

This method should only be called by the AbstractMutableFSA.removeTransition(laser.regularlanguage.fsa.FSATransitionInterface) method.

Parameters:
transition - The non-null transition.
See Also:
AbstractMutableFSA.removeTransition(laser.regularlanguage.fsa.FSATransitionInterface)

_checkLabel

protected void _checkLabel(L label)
Checks the specified Label, making sure it is not null and is contained in the Alphabet of this FSA.

Parameters:
label - The Label to check.
Throws:
java.lang.IllegalArgumentException - if label is null or is not contained in the alphabet of this FSA.

_checkState

protected void _checkState(FSAStateInterface<L> state)
Checks the specified state, making sure it is not null and is a part of this FSA.

Parameters:
state - The state to check.
Throws:
java.lang.IllegalArgumentException - if state is null or is not part of this FSA.

_checkTransition

protected void _checkTransition(FSATransitionInterface<L> transition)
Checks the specified transition, making sure it is not null and is a part of this FSA.

Parameters:
transition - The transition to check.
Throws:
java.lang.IllegalArgumentException - if transition is null or is not part of this FSA.

clone

public abstract FSAInterface<L> clone()
Returns a copy of this FSA.

Specified by:
clone in interface FSAInterface<L extends LabelInterface>
Overrides:
clone in class java.lang.Object
Returns:
A copy of this FSA.

getAcceptStates

public java.util.SortedSet<? extends FSAStateInterface<L>> getAcceptStates()
Returns an unmodifiable view of the set A, the accept states of this FSA.

NOTES: The returned set can not be modified and any attempt to do so will result in a UnsupportedOperationException being thrown.

Specified by:
getAcceptStates in interface FSAInterface<L extends LabelInterface>
Returns:
An unmodifiable view of the accept states of this FSA.

getAlphabet

public AlphabetInterface<L> getAlphabet()
Returns an unmodifiable view of the Alphabet, Σ, of this FSA.

NOTES: The returned Alphabet can not be modified and any attempt to do so will result in a UnsupportedOperationException being thrown.

Specified by:
getAlphabet in interface FSAInterface<L extends LabelInterface>
Returns:
An unmodifiable view of the Alphabet of this FSA.

getFactory

public AbstractFSAFactory<L> getFactory()
Returns a reference to a factory that creates FSAs of this type.

Specified by:
getFactory in interface FSAInterface<L extends LabelInterface>
Returns:
a reference to a factory that creates FSAs of this type.

getDescription

public java.lang.StringBuffer getDescription()
Returns the description of this FSA or null if one has not been specified.

NOTE: Modifying the returned StringBuffer will not affect the description of the FSA.

Specified by:
getDescription in interface FSAInterface<L extends LabelInterface>
Returns:
The description of this FSA or null if one has not been specified.

getEpsilonTransition

public FSAEpsilonTransitionInterface<L> getEpsilonTransition(FSAStateInterface<L> source,
                                                             FSAStateInterface<L> target)
Returns the transition from the specified source state to the specified target state on epsilon (ε) if one exists in the FSA, otherwise null is returned (optional operation). More formally, returns (tT : source(t) = sourcetarget(t) = targetlabel(t) = ε) or null if no such t exists.

If this FSA does not support epsilon (ε) transitions, this method should not be supported. An UnsupportedOperationException may be thrown depending on the implementation.

PRECONDITIONS:

Specified by:
getEpsilonTransition in interface FSAInterface<L extends LabelInterface>
Parameters:
source - The source state.
target - The target state.
Returns:
The epsilon transition if it exists, null otherwise.
Throws:
java.lang.IllegalArgumentException - if source/target is null or is not a part of this FSA.

getName

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

Specified by:
getName in interface FSAInterface<L extends LabelInterface>
Returns:
The name of this FSA.

getNonAcceptStates

public java.util.SortedSet<? extends FSAStateInterface<L>> getNonAcceptStates()
Returns an unmodifiable view of the set QA, of this FSA.

NOTES: The returned set can not be modified and any attempt to do so will result in a UnsupportedOperationException being thrown.

Specified by:
getNonAcceptStates in interface FSAInterface<L extends LabelInterface>
Returns:
An unmodifiable view of the non-accept states of this FSA.

getStartState

public FSAStateInterface<L> getStartState()
Returns the start state, q0, of the FSA.

Specified by:
getStartState in interface FSAInterface<L extends LabelInterface>
Returns:
The start state of this FSA

getStates

public java.util.SortedSet<? extends FSAStateInterface<L>> getStates()
Returns an unmodifiable view of the set Q, the states of the FSA.

NOTES: The returned SortedSet can not be modified and any attempt to do so will result in a UnsupportedOperationException being thrown.

Specified by:
getStates in interface FSAInterface<L extends LabelInterface>
Returns:
An unmodifiable view of the set Q, the states of the FSA.

getStateWithID

public FSAStateInterface<L> getStateWithID(int id)
Returns the state of this FSA with the specified id number. If no such state exists, null is returned.

Specified by:
getStateWithID in interface FSAInterface<L extends LabelInterface>
Parameters:
id - The id number of the state to be returned.
Returns:
The state with the specified id number.

getTransition

public FSALabelTransitionInterface<L> getTransition(FSAStateInterface<L> source,
                                                    L label,
                                                    FSAStateInterface<L> target)
Returns the transition from the specified source state to the specified target state on an equal Label to the given Label if one exists in the FSA, otherwise null is returned. More formally, returns (tT : source(t) = sourcetarget(t) = targetlabel(t) = label) or null if no such t exists.

Note this method is ignorant of LabelPatterns, and as such will not return true even if the FSA has a transition with the specified source and target states on a LabelPattern that matches the specified Label.

PRECONDITIONS:

Specified by:
getTransition in interface FSAInterface<L extends LabelInterface>
Parameters:
source - The source state.
label - The Label of the transition.
target - The target state.
Returns:
The transition if it exists, null otherwise.
Throws:
java.lang.IllegalArgumentException - if source/target is null or is not part of this FSA or label is null or is not contained in the alphabet of this FSA.

getTransitions

public java.util.SortedSet<? extends FSATransitionInterface<L>> getTransitions()
Returns an unmodifiable view of the set T, the transitions of the FSA.

NOTES: The returned Set can not be modified and any attempt to do so will result in a UnsupportedOperationException being thrown.

Specified by:
getTransitions in interface FSAInterface<L extends LabelInterface>
Returns:
An unmodifiable view of the set T, the transitions of the FSA.

getTransitions

public java.util.SortedSet<? extends FSATransitionInterface<L>> getTransitions(FSAStateInterface<L> source,
                                                                               FSAStateInterface<L> target)
Returns a non-null Set containing all the transitions from the specified source to the given target state. Formally, returns the set S where (∀ tT : tSsource(t) = sourcetarget(t) = target).

PRECONDITIONS:

Specified by:
getTransitions in interface FSAInterface<L extends LabelInterface>
Parameters:
source - The source state.
target - The target state.
Returns:
A non-null Set containing all the transitions from the specified source to the given target state.

Throws:
java.lang.IllegalArgumentException - if source/target is null or is not a part of this FSA.

getTransitionWithID

public FSATransitionInterface<L> getTransitionWithID(int id)
Returns the transition of this FSA with the specified id number. If no such transition exists, null is returned.

Specified by:
getTransitionWithID in interface FSAInterface<L extends LabelInterface>
Parameters:
id - The id number of the transition to be returned.
Returns:
The transition with the specified id number.

hasTransitionsOnEpsilon

public boolean hasTransitionsOnEpsilon()
Returns true if this FSA has any transitions on epsilon, false otherwise (optional operation). More formally, returns true iff (∃ t ∈ T : label(t) = ε).

NOTE: This FSA may support transitions on epsilon but not actually contain any transition on epsilon.

If this FSA does not support transitions on epsilon, calling this method may cause an UnsupportedOperationException to be thrown, depending on the implementation.

Specified by:
hasTransitionsOnEpsilon in interface FSAInterface<L extends LabelInterface>
Returns:
true if this FSA has any transitions on epsilon, false otherwise.
Throws:
java.lang.UnsupportedOperationException - this FSA does not support transitions on epsilon.

isDeterministic

public boolean isDeterministic()
                        throws FSAInterfaceException
Returns true if this FSA is deterministic and false otherwise. If this FSA does not support nondeterminism, true will always be returned. If this FSA supports nondeterminism, true is returned only if this FSA has no epsilon (ε) transitions and no two transitions have the same source state and label. More formally, true is returned iff (∀ tT : label(t) ≠ ε) ∧ (∄ x, yT : xysource(x) = source(y) ∧ label(x) = label(y)). This takes into account any transitions in T specified by transitions on LabelPatterns.

Specified by:
isDeterministic in interface FSAInterface<L extends LabelInterface>
Returns:
true if this FSA is deterministic and false otherwise.
Throws:
FSAInterfaceException - if the FSA is not well-formed.
See Also:
checkWellFormed()

isTotal

public boolean isTotal()
Returns true if this FSA is total, false otherwise. An FSA is total if all of its states have at least one outgoing transition on every Label in the FSA's Alphabet. Formally, an FSA is total iff (∀ l ∈ Σ, qQ : (∃ tT : source(t) = qlabel(t) = l)). This takes into account any transitions in T specified by transitions on LabelPatterns.

Specified by:
isTotal in interface FSAInterface<L extends LabelInterface>
Returns:
true if this FSA is total, false otherwise.

checkWellFormed

public java.util.List<java.lang.String> checkWellFormed()
Checks that this FSA is well-formed and returns a List of any well-formedness violitions if they exist.

Specified by:
checkWellFormed in interface FSAInterface<L extends LabelInterface>
Returns:
A List of the well-formedness violations if they exist and null otherwise

setDescription

public void setDescription(java.lang.StringBuffer description)
Sets the description of this FSA to a copy of the specified StringBuffer. No references are maintained between the given StringBuffer and the description of the FSA, thus modifying the given StringBuffer after the method returns has no effect on the description.

Specified by:
setDescription in interface FSAInterface<L extends LabelInterface>
Parameters:
description - The StringBuffer.

setName

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

Specified by:
setName in interface FSAInterface<L extends LabelInterface>
Parameters:
name - The String.

addAnnotation

public boolean addAnnotation(Annotation annotation)
Associates the given Annotation with this Object. If an equal Annotation was already so associated, false is returned, otherwise true is returned.

Specified by:
addAnnotation in interface Annotatable
Parameters:
annotation - The Annotation to associate with this Object.
Returns:
false if an equal Annotation was already associated with this Object and true otherwise.
Throws:
java.lang.IllegalArgumentException - if annotation is null.

addAnnotations

public boolean addAnnotations(java.util.Collection<? extends Annotation> annotations)
Associates all of the Annotations in the given Collection with this Object. If an equal Annotation to every Annotation in the Collection was already so associated, false is returned, otherwise true is returned.

Specified by:
addAnnotations in interface Annotatable
Parameters:
annotations - The Collection of Annotations to associate with this Object.
Returns:
false if an equal Annotation to every Annotation in the specified Collection was already associated with this Object and true otherwise.
Throws:
java.lang.IllegalArgumentException - if annotations or any annotation is null.

copyAnnotations

public boolean copyAnnotations(Annotatable container)
Copies all of the Annotations associated with this Object that pass the filters and associates them with the specified Object. If equal Annotations to every Annotation that was copied from this Object were already associated with the specified Object, false is returned, otherwise true is returned.

Specified by:
copyAnnotations in interface Annotatable
Parameters:
container - The Object to associate the copied Annotations with.
Returns:
false if the specified Object was already associated with equal Annotations to every Annotation that was copied from this Object, true otherwise.
Throws:
java.lang.IllegalArgumentException - if container is null.
See Also:
getAnnotationFilters()

getAnnotationClasses

public java.util.Set<java.lang.Class<? extends Annotation>> getAnnotationClasses(java.lang.Class<? extends Annotation> query)
Gets all of the Annotation Classes associated with this Object of the specified Annotation Class.

Specified by:
getAnnotationClasses in interface Annotatable
Parameters:
query - The Annotation Class of interest
Returns:
A Set of all of the Annotation Classes of the specified Annotation 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 associated with this Object.

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 associated with this Object that have an equal Class to or are a Subclass of the Class of the specified Annotation.

Specified by:
getAnnotations in interface Annotatable
Parameters:
query - The Class of which Annotations of equal Class or Subclasses of the Class are to be returned.
Returns:
A Collection containing all of the Annotations associated with this Object that have an equal Class or are Subclasses of the specified Class.
Throws:
java.lang.IllegalArgumentException - if query is null.

getAnnotations

public java.util.Collection<Annotation> getAnnotations()
Gets all of the Annotations associated with this Object.

Specified by:
getAnnotations in interface Annotatable
Returns:
A Collection containing the Annotations associated with this Object.

getAnnotationFilters

public java.util.Set<java.lang.Class<? extends Annotation>> getAnnotationFilters()
Gets the filters to use when copying the Annotations. The returned Set contains the Classes of Annotations that are not to be copied by the copyAnnotations(laser.util.Annotatable) method.

Specified by:
getAnnotationFilters in interface Annotatable
Returns:
The filters for the Annotations.
See Also:
copyAnnotations(laser.util.Annotatable)

setAnnotationFilters

public void setAnnotationFilters(java.util.Set<java.lang.Class<? extends Annotation>> filters)
Sets the filters to use when copying the Annotations. The Set contains the Classes of Annotations that are not to be copied by the copyAnnotations(laser.util.Annotatable) method.

Specified by:
setAnnotationFilters in interface Annotatable
Parameters:
filters - The filters for the Annotations
Throws:
java.lang.IllegalArgumentException - if the filters are null
See Also:
copyAnnotations(laser.util.Annotatable)

removeAnnotation

public boolean removeAnnotation(Annotation annotation)
Removes the association of the given Annotation with this Object. If an equal Annotation was so associated, true is returned, otherwise false is returned.

Specified by:
removeAnnotation in interface Annotatable
Parameters:
annotation - The Annotation of which the association with this Object is to be removed.
Returns:
true if an equal Annotation was associated with this Object and false otherwise.
Throws:
java.lang.IllegalArgumentException - if annotation is null.

removeAnnotations

public boolean removeAnnotations(java.util.Collection<? extends Annotation> annotations)
Removes the association of all the Annotations in the given Collection with this Object. If an equal Annotation to any Annotation in the Collection was so associated, true is returned, otherwise false is returned.

Specified by:
removeAnnotations in interface Annotatable
Parameters:
annotations - The Collection of Annotations of which the association with this Object is to be removed.
Returns:
true if an equal Annotation to any Annotation in the specified Collection was associated with this Object and false otherwise.
Throws:
java.lang.IllegalArgumentException - if annotations or any annotation is null.

removeAnnotations

public boolean removeAnnotations(java.lang.Class<? extends Annotation> query)
Removes the association of all of the Annotations of the specified Class or Subclasses of the specified Class with this Object, returning true if any Annotations were so associated, false otherwise.

Specified by:
removeAnnotations in interface Annotatable
Parameters:
query - The Class of Annotations that are to be removed.
Returns:
true if any associations with Annotations were removed, false otherwise.
Throws:
java.lang.IllegalArgumentException - if query is null.

removeAnnotations

public void removeAnnotations()
Removes all of the Annotations associated with this Object.

Specified by:
removeAnnotations in interface Annotatable

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
Throws:
java.io.IOException - if an I/O error occurs
PersistentException - if there is a problem with the persistent 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
Throws:
java.io.IOException - if an I/O error occurs
PersistentException - if there is a problem with the persistent process

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 occurs
PersistentException - if there is a problem with the persistent 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 occurs
PersistentException - if there is a problem with the persistence process

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

visualize

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

Specified by:
visualize in interface Visualizable
Parameters:
filename - The file to output the visual form to
Throws:
java.io.IOException - an IO error during the write
VisualizableException - an error occured 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 object 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 during the write
VisualizableException - an error occured while creating the visual form of the artifact

getDotWriter

protected FSADotWriter<L> getDotWriter()
Gets the FSADotWriter to be used by this FSA.

Returns:
The appropriate FSADotWriter

toDot

public void toDot(java.lang.String filename)
           throws java.io.IOException
Outputs this FSA in dot format to the file with the given name to use as output.

Parameters:
filename - The name of file to use as output
Throws:
java.io.IOException - if an I/O error occurs

toDot

public void toDot(java.io.Writer out)
           throws java.io.IOException
Outputs this FSA in dot format to the given Writer to use as output.

Parameters:
out - The Writer to use as output
Throws:
java.io.IOException - if an I/O error occurs