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

java.lang.Object
  extended by laser.regularlanguage.fsa.TotalFSATransformer<L>
Type Parameters:
L - The type of labels used by the FSA

public class TotalFSATransformer<L extends LabelInterface>
extends java.lang.Object

The TotalFSATransformer class transforms the given FSA into a total FSA.

Author:
Nathan Jokel (laser-software@cs.umass.edu), Heather M. Conboy

Constructor Summary
TotalFSATransformer()
          Creates a new TotalFSATransformer.
 
Method Summary
protected  java.util.Set<L> getLabels(AlphabetInterface<L> alphabet, FSATransitionInterface<L> transition)
          Gets the set of labels used by the given transition.
 FSAStateInterface<L> makeTotal(MutableFSAInterface<L> fsa, java.lang.Object[] trapStateArgs, java.lang.Object[] trapTransitionArgs)
          Makes the given FSA total if it is not already.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TotalFSATransformer

public TotalFSATransformer()
Creates a new TotalFSATransformer.

Method Detail

makeTotal

public FSAStateInterface<L> makeTotal(MutableFSAInterface<L> fsa,
                                      java.lang.Object[] trapStateArgs,
                                      java.lang.Object[] trapTransitionArgs)
Makes the given FSA total if it is not already. Making an FSA total does not change the set of input strings that it accepts.

A non-accepting state is added to the FSA and a reference to it is returned. Transitions on Labels are added as necessary from every state in the FSA to target this new state to make the FSA total. Call the added state qtrap. (∀ l ∈ Σ, qQ : (∄ tT : source(t) = qlabel(t) = l) → add a transition t' to T such that source(t') = qlabel(t') = ltarget(t') = qtrap). This takes into account any transitions in T specified by transitions on LabelPatterns.

If this FSA was already total, no state is added, and instead null is returned. PRECONDITIONS: The given FSA must be non-null.

Parameters:
fsa - The given FSA to be made total
trapStateArgs - Any required arguments for the new trap state
trapTransitionArgs - Any required arguments for the new trap transitions
Returns:
A reference to the non-accepting state that was added, or null if no state was added.
See Also:
FSAInterface.isTotal()

getLabels

protected java.util.Set<L> getLabels(AlphabetInterface<L> alphabet,
                                     FSATransitionInterface<L> transition)
Gets the set of labels used by the given transition.

Parameters:
alphabet - The alphabet of the FSA
transition - The transition to be considered
Returns:
The set of labels used by the given transition
Throws:
java.lang.UnsupportedOperationException - if the transition is not supported