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

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

public class RunnableDFA<L extends LabelInterface>
extends RunnableFSA<L>
implements RunnableDFAInterface<L>

This class represents DFAs that are runnable.

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:
RunnableDFAInterface, Serialized Form

Field Summary
 
Fields inherited from class laser.regularlanguage.fsa.AbstractRunnableFSA
table
 
Fields inherited from class laser.regularlanguage.fsa.AbstractFSA
_alphabet, _factory, _nextStateID, _nextTransitionID, _startState, _states, _transitionIndex, _transitions
 
Fields inherited from interface laser.util.Persistent
PER_EXTENSION, READ_PERSISTENT_METHOD_NAME
 
Fields inherited from interface laser.util.Persistent
PER_EXTENSION, READ_PERSISTENT_METHOD_NAME
 
Constructor Summary
protected RunnableDFA(MutableDFA<L> dfa, java.lang.Class<? extends AbstractFSATransitionTable> tableClass)
          Returns the runnable DFA corresponding to the specified mutable DFA that uses an AbstractFSATransitionTable of the specified Class.
protected RunnableDFA(RunnableDFA<L> dfa, java.lang.Class<? extends AbstractFSATransitionTable> tableClass)
          Creates a new RunnableDFA with the same states, transitions, and Alphabet as the specified RunnableDFA that uses an AbstractFSATransitionTable of the specified Class (copy constructor).
 
Method Summary
protected  void _checkForwardsConfiguration(java.util.SortedSet<? extends FSAStateInterface<L>> states)
          Checks the given set of states.
 RunnableDFA<L> clone()
          Returns a copy of this runnable DFA.
 FSAEpsilonTransitionInterface<L> getEpsilonTransition(FSAStateInterface<L> source, FSAStateInterface<L> target)
          DFAs do not support epsilon (ε) transitions.
 java.util.SortedSet<? extends FSAStateInterface<L>> getInitialConfigurationForwards()
          Returns a SortedSet containing the initial states of this FSA.
 MutableDFAInterface<L> getMutableFSA()
          Returns the mutable FSA corresponding to this runnable FSA.
 boolean hasTransitionsOnEpsilon()
          DFAs do not support epsilon (ε) transitions.
 boolean isDeterministic()
          Returns true, since DFAs are always deterministic.
 boolean supportsEpsilonTransitions()
          Returns true if this FSA supports epsilon transitions and false otherwise.
 boolean supportsNondeterminism()
          Returns true if this FSA supports nondeterminism and false otherwise.
 
Methods inherited from class laser.regularlanguage.fsa.AbstractRunnableFSA
_checkBackwardsConfiguration, _checkConfiguration, checkWellFormed, getAcceptStates, getNonAcceptStates, initializeFields, isAcceptedStringBackwards, isAcceptedStringForwards, isFinalConfigurationBackwards, isFinalConfigurationForwards, isTotal, runBackwards, runBackwards, runForwards, runForwards, supportsLabelPatterns, supportsRunningBackwards
 
Methods inherited from class laser.regularlanguage.fsa.AbstractFSA
_checkLabel, _checkState, _checkTransition, _internalAddTransition, _internalCopyFSAAttributes, _internalRemoveState, _internalRemoveTransition, addAnnotation, addAnnotations, copyAnnotations, getAlphabet, getAnnotationClasses, getAnnotationClasses, getAnnotationFilters, getAnnotations, getAnnotations, getDescription, getDotWriter, getFactory, getName, getStartState, getStates, getStateWithID, getTransition, getTransitions, getTransitions, getTransitionWithID, getVisExtension, readPersistent, readPersistent, removeAnnotation, removeAnnotations, removeAnnotations, removeAnnotations, setAnnotationFilters, setDescription, setName, toDot, toDot, visualize, visualize, writePersistent, writePersistent
 
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
checkWellFormed, getAcceptStates, getAlphabet, getDescription, getFactory, getName, getNonAcceptStates, getStartState, getStates, getStateWithID, getTransition, getTransitions, getTransitions, getTransitionWithID, isTotal, setDescription, setName
 
Methods inherited from interface laser.util.Annotatable
addAnnotation, addAnnotations, copyAnnotations, getAnnotationClasses, getAnnotationClasses, getAnnotationFilters, getAnnotations, getAnnotations, removeAnnotation, removeAnnotations, removeAnnotations, removeAnnotations, setAnnotationFilters
 
Methods inherited from interface laser.util.Persistent
writePersistent, writePersistent
 
Methods inherited from interface laser.util.Visualizable
getVisExtension, visualize, visualize
 
Methods inherited from interface laser.regularlanguage.fsa.RunnableFSAInterface
isAcceptedStringBackwards, isAcceptedStringForwards, isFinalConfigurationBackwards, isFinalConfigurationForwards, runBackwards, runBackwards, runForwards, runForwards, supportsRunningBackwards
 
Methods inherited from interface laser.regularlanguage.fsa.FSAInterface
checkWellFormed, getAcceptStates, getAlphabet, getDescription, getFactory, getName, getNonAcceptStates, getStartState, getStates, getStateWithID, getTransition, getTransitions, getTransitions, getTransitionWithID, isTotal, setDescription, setName
 
Methods inherited from interface laser.util.Annotatable
addAnnotation, addAnnotations, copyAnnotations, getAnnotationClasses, getAnnotationClasses, getAnnotationFilters, getAnnotations, getAnnotations, removeAnnotation, removeAnnotations, removeAnnotations, removeAnnotations, setAnnotationFilters
 
Methods inherited from interface laser.util.Persistent
writePersistent, writePersistent
 
Methods inherited from interface laser.util.Visualizable
getVisExtension, visualize, visualize
 

Constructor Detail

RunnableDFA

protected RunnableDFA(MutableDFA<L> dfa,
                      java.lang.Class<? extends AbstractFSATransitionTable> tableClass)
Returns the runnable DFA corresponding to the specified mutable DFA that uses an AbstractFSATransitionTable of the specified Class.

PRECONDITIONS: dfa and tableClass are not null. AbstractFSATransitionTables of tableClass have a constructor that takes a single RunnableFSA parameter.

Note this constructor should only be called by the AbstractFSAFactory._internalGetRunnableDFA(laser.regularlanguage.fsa.MutableDFA) method.

Parameters:
dfa - The mutable DFA.
tableClass - The class of AbstractFSATransitionTable to use.
Throws:
InconsistentObjectError - if there is a problem instantiating the transition table.
See Also:
AbstractFSAFactory._internalGetRunnableDFA(laser.regularlanguage.fsa.MutableDFA)

RunnableDFA

protected RunnableDFA(RunnableDFA<L> dfa,
                      java.lang.Class<? extends AbstractFSATransitionTable> tableClass)
Creates a new RunnableDFA with the same states, transitions, and Alphabet as the specified RunnableDFA that uses an AbstractFSATransitionTable of the specified Class (copy constructor).

PRECONDITIONS: dfa and tableClass are not null. AbstractFSATransitionTables of tableClass have a constructor that takes a single RunnableFSA parameter.

Note this constructor should only be called by the clone() method.

Parameters:
dfa - The runnable DFA.
tableClass - The class of AbstractFSATransitionTable to use.
Throws:
InconsistentObjectError - if there is a problem instantiating the transition table.
See Also:
clone()
Method Detail

_checkForwardsConfiguration

protected void _checkForwardsConfiguration(java.util.SortedSet<? extends FSAStateInterface<L>> states)
Checks the given set of states.

Overrides:
_checkForwardsConfiguration in class AbstractRunnableFSA<L extends LabelInterface>
Parameters:
states - The set of states to be checked
Throws:
java.lang.IllegalArgumentException - if the set of states is null or not a singleton set

clone

public RunnableDFA<L> clone()
Returns a copy of this runnable DFA.

Specified by:
clone in interface FSAInterface<L extends LabelInterface>
Overrides:
clone in class RunnableFSA<L extends LabelInterface>
Returns:
A copy of this runnable DFA.

getEpsilonTransition

public FSAEpsilonTransitionInterface<L> getEpsilonTransition(FSAStateInterface<L> source,
                                                             FSAStateInterface<L> target)
DFAs do not support epsilon (ε) transitions. This method is not supported. Calling this method will cause an UnsupportedOperationException to be thrown.

Specified by:
getEpsilonTransition in interface FSAInterface<L extends LabelInterface>
Overrides:
getEpsilonTransition in class AbstractFSA<L extends LabelInterface>
Parameters:
source - The source state.
target - The target state.
Returns:
The epsilon transition if it exists, null otherwise.
Throws:
java.lang.UnsupportedOperationException - this FSA does not support epsilon (ε) transitions.

getInitialConfigurationForwards

public java.util.SortedSet<? extends FSAStateInterface<L>> getInitialConfigurationForwards()
Returns a SortedSet containing the initial states of this FSA.

Formally, call the returned set of states S. S = q0 ∪ E where E =

empty if this FSA does not support epsilon transitions

epsilonClosureForwards(q0) otherwise

Specified by:
getInitialConfigurationForwards in interface RunnableFSAInterface<L extends LabelInterface>
Overrides:
getInitialConfigurationForwards in class RunnableFSA<L extends LabelInterface>
Returns:
a SortedSet containing the initial states of this FSA.
See Also:
RunnableFSAInterface

getMutableFSA

public MutableDFAInterface<L> getMutableFSA()
Returns the mutable FSA corresponding to this runnable FSA. No references are maintained between the FSAs, thus modifying the mutable FSA has no effect on the runnable FSA.

Specified by:
getMutableFSA in interface RunnableFSAInterface<L extends LabelInterface>
Overrides:
getMutableFSA in class AbstractRunnableFSA<L extends LabelInterface>
Returns:
The mutable FSA corresponding to this runnable FSA.

hasTransitionsOnEpsilon

public boolean hasTransitionsOnEpsilon()
DFAs do not support epsilon (ε) transitions. This method is not supported. Calling this method will cause an UnsupportedOperationException to be thrown.

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

isDeterministic

public boolean isDeterministic()
                        throws FSAInterfaceException
Returns true, since DFAs are always deterministic.

Specified by:
isDeterministic in interface FSAInterface<L extends LabelInterface>
Overrides:
isDeterministic in class AbstractRunnableFSA<L extends LabelInterface>
Returns:
true
Throws:
WellFormednessException - if the FSA is not well formed.
FSAInterfaceException - if the FSA is not well-formed.
See Also:
AbstractRunnableFSA.checkWellFormed()

supportsEpsilonTransitions

public boolean supportsEpsilonTransitions()
Returns true if this FSA supports epsilon transitions and false otherwise.

NOTE: By the DFA definition, this method always returns false.

Specified by:
supportsEpsilonTransitions in interface FSAInterface<L extends LabelInterface>
Overrides:
supportsEpsilonTransitions in class RunnableFSA<L extends LabelInterface>
Returns:
True if epsilon transitions are supported and false otherwise

supportsNondeterminism

public boolean supportsNondeterminism()
Returns true if this FSA supports nondeterminism and false otherwise.

NOTE: By the DFA definition, this method always returns false.

Specified by:
supportsNondeterminism in interface FSAInterface<L extends LabelInterface>
Overrides:
supportsNondeterminism in class RunnableFSA<L extends LabelInterface>
Returns:
True if nondeterminism is supported and false otherwise