laser.regularlanguage.fsa
Interface FSAStateInterface<L extends LabelInterface>

Type Parameters:
L - The type of Label associated with the FSA that contains this state.
All Superinterfaces:
Annotatable, java.lang.Comparable<FSAStateInterface<L>>, java.io.Serializable
All Known Implementing Classes:
FSAState

public interface FSAStateInterface<L extends LabelInterface>
extends Annotatable, java.lang.Comparable<FSAStateInterface<L>>, java.io.Serializable

Classes implementing this interface represent states in FSAs of type FSAInterface. Instances of FSAStateInterface can not exist independently of FSAs; they should only be created by the appropriate factory methods, never by their constructors.

States may be part of either a mutable or runnable FSA. If a state is part of a runnable FSA, the state may not be modified (e.g. it may not be made accepting or non-accepting).

Each FSAStateInterface has an ID number, represented by an int. Among all the FSAStateInterfaces in a given FSAInterface the ID numbers are unique.

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

Method Summary
 FSAInterface<L> getFSA()
          Returns the FSA that contains this state.
 int getID()
          Returns the ID of this state.
 java.util.Set<? extends FSAEpsilonTransitionInterface<L>> getIncomingEpsilonTransitions()
          Returns a Set containing the transitions on epsilon of the FSA that contains this state where the target is this state (optional operation).
 java.util.Set<? extends FSATransitionInterface<L>> getIncomingTransitions()
          Returns a Set containing the transitions of the FSA that contains this state where the target is this state.
 java.util.Set<? extends FSALabelTransitionInterface<L>> getIncomingTransitions(L label)
          Returns a Set containing the transitions on the specified Label of the FSA that contains this state where the target is this state.
 java.util.Set<? extends FSALabelPatternTransitionInterface<L>> getIncomingTransitions(LabelPatternInterface<L> labelPattern)
          Returns a Set containing the transitions on the specified LabelPattern of the FSA that contains this state where the target is this state (optional operation).
 java.lang.String getName()
          Returns the name of this state, or null if one has not been specified.
 java.util.Set<? extends FSAEpsilonTransitionInterface<L>> getOutgoingEpsilonTransitions()
          Returns a Set containing the transitions on epsilon of the FSA that contains this state where the source is this state (optional operation).
 java.util.Set<? extends FSATransitionInterface<L>> getOutgoingTransitions()
          Returns a Set containing the transitions of the FSA that contains this state where the source is this state.
 java.util.Set<? extends FSALabelTransitionInterface<L>> getOutgoingTransitions(L label)
          Returns a Set containing the transitions on the specified Label of the FSA that contains this state where the source is this state.
 java.util.Set<? extends FSALabelPatternTransitionInterface<L>> getOutgoingTransitions(LabelPatternInterface<L> labelPattern)
          Returns a Set containing the transitions on the specified LabelPattern of the FSA that contains this state where the source is this state (optional operation).
 boolean isAccept()
          Returns true if this state is an accept state (i.e. this state is in A), false otherwise.
 boolean isDeterministic()
          Returns true if this state is deterministic and false otherwise.
 boolean isSink()
          Returns true if this state is a sink state, false otherwise.
 boolean isStart()
          Returns true if this state is the start state, q0, false otherwise.
 void setAccept(boolean accept)
          Sets whether or not this state is an accept state.
 void setName(java.lang.String name)
          Sets the name of this state to the specified String.
 
Methods inherited from interface laser.util.Annotatable
addAnnotation, addAnnotations, copyAnnotations, getAnnotationClasses, getAnnotationClasses, getAnnotationFilters, getAnnotations, getAnnotations, removeAnnotation, removeAnnotations, removeAnnotations, removeAnnotations, setAnnotationFilters
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Method Detail

getFSA

FSAInterface<L> getFSA()
Returns the FSA that contains this state.

Returns:
Returns the FSA that contains this state.

getID

int getID()
Returns the ID of this state.

Returns:
the ID of this state.

getIncomingTransitions

java.util.Set<? extends FSATransitionInterface<L>> getIncomingTransitions()
Returns a Set containing the transitions of the FSA that contains this state where the target is this state.

More formally, call the returned set S and call this state q.
(∀ tT : tStarget(t) = q)

Returns:
A Set containing the transitions of this FSA where the target is this state

getIncomingEpsilonTransitions

java.util.Set<? extends FSAEpsilonTransitionInterface<L>> getIncomingEpsilonTransitions()
Returns a Set containing the transitions on epsilon of the FSA that contains this state where the target is this state (optional operation).

More formally, call the returned set S and call this state q.
(∀ tT : tS ↔ (target(t) = qlabel(t) = epsilon (ε))

Returns:
A Set containing the transitions on epsilon of this FSA where the target is this state
Throws:
java.lang.UnsupportedOperationException - if this FSA does not support epsilon (ε) transitions

getIncomingTransitions

java.util.Set<? extends FSALabelTransitionInterface<L>> getIncomingTransitions(L label)
Returns a Set containing the transitions on the specified Label of the FSA that contains this state where the target is this state.

More formally, call the returned set S and call this state q.
(∀ tT : tS ↔ (target(t) = qlabel(t) = label))

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

PRECONDITION: The label must be non-null and contained in the alphabet of this FSA.

Parameters:
label - The Label.
Returns:
A Set containing the transitions on the specified Label of this FSA where the target is this state
Throws:
java.lang.IllegalArgumentException - the specified Label is null or is not contained in the alphabet of this FSA.

getIncomingTransitions

java.util.Set<? extends FSALabelPatternTransitionInterface<L>> getIncomingTransitions(LabelPatternInterface<L> labelPattern)
Returns a Set containing the transitions on the specified LabelPattern of the FSA that contains this state where the target is this state (optional operation).

More formally, call the returned set S and call this state q.
(∀ tT : tS ↔ (target(t) = qlabel(t) = labelPattern))

PRECONDITION: The labelPattern must be non-null.

Parameters:
labelPattern - The LabelPattern.
Returns:
A Set containing the transitions on the specified LabelPattern of the FSA that contains this state where the target is this state.
Throws:
java.lang.IllegalArgumentException - the specified LabelPattern is null.
java.lang.UnsupportedOperationException - if this FSA does not support label pattern transitions

getName

java.lang.String getName()
Returns the name of this state, or null if one has not been specified.

Returns:
The name of this state, or null if one has not been specified.

getOutgoingTransitions

java.util.Set<? extends FSATransitionInterface<L>> getOutgoingTransitions()
Returns a Set containing the transitions of the FSA that contains this state where the source is this state.

More formally, call the returned set S and call this state q.
(∀ tT : tSsource(t) = q)

Returns:
A Set containing the transitions of this FSA where the source is this state

getOutgoingEpsilonTransitions

java.util.Set<? extends FSAEpsilonTransitionInterface<L>> getOutgoingEpsilonTransitions()
Returns a Set containing the transitions on epsilon of the FSA that contains this state where the source is this state (optional operation).

More formally, call the returned set S and call this state q.
(∀ tT : tS ↔ (source(t) = qlabel(t) = epsilon (ε))

Returns:
A Set containing the transitions on epsilon of this FSA where the source is this state
Throws:
java.lang.UnsupportedOperationException - if this FSA does not support epsilon (ε) transitions

getOutgoingTransitions

java.util.Set<? extends FSALabelTransitionInterface<L>> getOutgoingTransitions(L label)
Returns a Set containing the transitions on the specified Label of the FSA that contains this state where the source is this state.

More formally, call the returned set S and call this state q.
(∀ tT : tS ↔ (source(t) = qlabel(t) = label))

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

PRECONDITION: The label must be non-null and contained in the alphabet of this FSA.

Parameters:
label - The Label.
Returns:
A Set containing the transitions on the specified Label of this FSA where the source state is this state
Throws:
java.lang.IllegalArgumentException - the specified Label is null or is not contained in the alphabet of this FSA.

getOutgoingTransitions

java.util.Set<? extends FSALabelPatternTransitionInterface<L>> getOutgoingTransitions(LabelPatternInterface<L> labelPattern)
Returns a Set containing the transitions on the specified LabelPattern of the FSA that contains this state where the source is this state (optional operation).

More formally, call the returned set S and call this state q.
(∀ tT : tS ↔ (source(t) = qlabel(t) = labelPattern))

PRECONDITION: The labelPattern must be non-null.

Parameters:
labelPattern - The LabelPattern.
Returns:
A Set containing the transitions on the specified Label of this FSA where the source is this state
Throws:
java.lang.IllegalArgumentException - the specified LabelPattern is null.
java.lang.UnsupportedOperationException - if this FSA does not support label pattern transitions

isAccept

boolean isAccept()
Returns true if this state is an accept state (i.e. this state is in A), false otherwise.

Returns:
true if this state is an accept state, false otherwise.

isDeterministic

boolean isDeterministic()
Returns true if this state is deterministic and false otherwise. If the FSA that contains this state does not support nondeterminism, true will always be returned.

If the FSA that contains this state supports nondeterminism, true is returned iff this state has no outgoing epsilon (ε) transitions and no two outgoing transitions have the same Label. More formally, call this state q. true is returned iff
(∀ tq.getOutgoingTransitions() : label(t) ≠ ε) ∧ (∀ x, yq.getOutgoingTransitions() : source(x) = source(y) ∧ label(x) = label(y) → x = y)

Returns:
true if this state is deterministic and false otherwise.

isSink

boolean isSink()
Returns true if this state is a sink state, false otherwise. A state is a sink state if it has no outgoing transitions targeting other states. More formally, call this state q. true is returned iff
(∀ tT : source(t) = q target(t) = q)

Returns:
true if this state is a sink state, false otherwise.

isStart

boolean isStart()
Returns true if this state is the start state, q0, false otherwise.

Returns:
true if this state is the start state, false otherwise.

setAccept

void setAccept(boolean accept)
Sets whether or not this state is an accept state. If true is given as the parameter, this state is an accept state (i.e. this state is in A). If false is given as the parameter, this state is a non-accept state (i.e. this state is not in A).

Parameters:
accept - The parameter determining whether or not this state will be an accept state.
Throws:
java.lang.UnsupportedOperationException - if the FSA that contains this state is not mutable.

setName

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

NOTE: Both mutable and runnable FSAs support this method.

Parameters:
name - The name.