laser.regularlanguage.fsa.util
Class UnionComposer<L extends LabelInterface>

java.lang.Object
  extended by laser.regularlanguage.fsa.util.AbstractComposer<L>
      extended by laser.regularlanguage.fsa.util.UnionComposer<L>
Type Parameters:
L - The type of labels used by the FSAs

public class UnionComposer<L extends LabelInterface>
extends AbstractComposer<L>

The UnionComposer class computes the union FSA from the given FSAs.

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

Constructor Summary
UnionComposer(FSAFactoryInterface<L> fsaFactory)
          Creates a new UnionComposer.
 
Method Summary
 java.util.Set<L> getLabels(RunnableFSAInterface<L> fsa1, RunnableFSAInterface<L> fsa2)
          Gets the Set of labels for which transitions should be added.
 boolean isAccept(CompositeState<L> composite)
          Determines whether or not the given composite state should be accepting.
 FSAPair<L> preprocess(RunnableFSAInterface<L> fsa1, RunnableFSAInterface<L> fsa2)
          Performs any necessary preprocessing before composing the given FSAs.
protected  RunnableFSAInterface<L> preprocess(RunnableFSAInterface<L> fsa, java.util.Set<L> labels)
          Preprocesses the given FSA.
 
Methods inherited from class laser.regularlanguage.fsa.util.AbstractComposer
getCreateArgs
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UnionComposer

public UnionComposer(FSAFactoryInterface<L> fsaFactory)
Creates a new UnionComposer.

Parameters:
fsaFactory - The FSAFactoryInterface to be used to create the new FSA (non-null)
Method Detail

getLabels

public java.util.Set<L> getLabels(RunnableFSAInterface<L> fsa1,
                                  RunnableFSAInterface<L> fsa2)
Gets the Set of labels for which transitions should be added.

NOTE: If an FSA's alphabet does not contain any of the returned labels, then for each FSA's state it is assumed that a self-loop transition exists on each such label.

Specified by:
getLabels in class AbstractComposer<L extends LabelInterface>
Parameters:
fsa1 - The first FSA
fsa2 - The second FSA
Returns:
The Set of labels for which transitions should be added

isAccept

public boolean isAccept(CompositeState<L> composite)
Determines whether or not the given composite state should be accepting.

Specified by:
isAccept in class AbstractComposer<L extends LabelInterface>
Parameters:
composite - the composite state
Returns:
true if it should be accepting, false otherwise

preprocess

public FSAPair<L> preprocess(RunnableFSAInterface<L> fsa1,
                             RunnableFSAInterface<L> fsa2)
Performs any necessary preprocessing before composing the given FSAs.

Specified by:
preprocess in class AbstractComposer<L extends LabelInterface>
Parameters:
fsa1 - The first FSA
fsa2 - The second FSA
Returns:
A List that contains the first FSA and second FSA after being preprocessed

preprocess

protected RunnableFSAInterface<L> preprocess(RunnableFSAInterface<L> fsa,
                                             java.util.Set<L> labels)
Preprocesses the given FSA.

Parameters:
fsa - The FSA to be preprocessed
labels - The Set of labels for which to add transitions
Returns:
The preprocessed FSA