laser.regularlanguage.util
Class RegularLanguages<L extends LabelInterface>

java.lang.Object
  extended by laser.regularlanguage.util.AbstractRegularLanguages<L>
      extended by laser.regularlanguage.util.RegularLanguages<L>
Type Parameters:
L - The type of labels used by the REs and FSAs.

public class RegularLanguages<L extends LabelInterface>
extends AbstractRegularLanguages<L>

The RegularLanguages class contains various methods for manipulating regular languages (RLs) represented as REs and FSAs.

The methods in this class all throw an IllegalArgumentException if the specified RE or FSA reference is null or not well-formed.

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

Field Summary
 
Fields inherited from class laser.regularlanguage.util.AbstractRegularLanguages
dfaFactory_, fsaFactory_, reFactory_, rlFactory_
 
Constructor Summary
RegularLanguages(REFactory<L> reFactory, FSAFactoryInterface<L> fsaFactory, FSAFactoryInterface<L> dfaFactory, RLFactory<L> rlFactory)
          Creates a new RegularLanguages class.
RegularLanguages(REFactory<L> reFactory, FSAFactoryInterface<L> fsaFactory, RLFactory<L> rlFactory)
          Creates a new RegularLanguages class.
 
Method Summary
protected  void checkClass(FSAInterface<L> theFSA)
          Checks that the FSA's class is supported.
protected  void checkClass(RE<L> theRE)
          Checks that the RE's class is supported.
 RE<L> convertFSAtoRE(RunnableFSAInterface<L> theFSA)
          Converts from the given FSA to its corresponding RE.
 MutableFSAInterface<L> convertREtoDFA(RE<L> theRE)
          Converts from the given RE to its corresponding DFA.
 MutableFSAInterface<L> convertREtoFSA(RE<L> theRE)
          Converts from the given RE to its corresponding FSA.
protected  FSAtoREConverter<L> createFSAtoREConverter()
          Creates the appropriate FSAtoREConverter.
protected  REReader<L> createREReader()
          Creates the appropriate REReader.
protected  REtoDFAConverter<L> createREtoDFAConverter()
          Creates the appropriate REtoDFAConverter.
protected  REtoFSAConverter<L> createREtoFSAConverter()
          Creates the appropriate REtoFSAConverter.
protected  RE<L> readRE(java.io.Reader in)
          Reads in the RE from the given Reader.
 
Methods inherited from class laser.regularlanguage.util.AbstractRegularLanguages
checkPreconditions, checkPreconditions, convertDFAtoRE, convertREtoDFA, convertREtoDFA, convertREtoFSA, convertREtoFSA, getDFAFactory, getFSAFactory, getREFactory, getRLFactory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RegularLanguages

public RegularLanguages(REFactory<L> reFactory,
                        FSAFactoryInterface<L> fsaFactory,
                        RLFactory<L> rlFactory)
Creates a new RegularLanguages class.

Parameters:
reFactory - The REFactory to be used to create new REs (non-null)
fsaFactory - The FSAFactoryInterface to be used to create new FSAs (non-null)
rlFactory - The RLFactory to be used to convert between REs and FSAs (non-null)

RegularLanguages

public RegularLanguages(REFactory<L> reFactory,
                        FSAFactoryInterface<L> fsaFactory,
                        FSAFactoryInterface<L> dfaFactory,
                        RLFactory<L> rlFactory)
Creates a new RegularLanguages class.

Parameters:
reFactory - The REFactory to be used to create new REs (non-null)
fsaFactory - The FSAFactoryInterface to be used to create new FSAs (non-null)
dfaFactory - The FSAFactoryInterface to be used to create new DFAs (non-null)
rlFactory - The RLFactory to be used to convert between REs and FSAs (non-null)
Method Detail

createREReader

protected REReader<L> createREReader()
Creates the appropriate REReader.

Returns:
The appropriate REReader

createREtoFSAConverter

protected REtoFSAConverter<L> createREtoFSAConverter()
Creates the appropriate REtoFSAConverter.

Returns:
The appropriate REtoFSAConverter

createREtoDFAConverter

protected REtoDFAConverter<L> createREtoDFAConverter()
Creates the appropriate REtoDFAConverter.

Returns:
The appropriate REtoDFAConverter

createFSAtoREConverter

protected FSAtoREConverter<L> createFSAtoREConverter()
Creates the appropriate FSAtoREConverter.

Returns:
The appropriate FSAtoREConverter

checkClass

protected void checkClass(RE<L> theRE)
Checks that the RE's class is supported.

Specified by:
checkClass in class AbstractRegularLanguages<L extends LabelInterface>
Parameters:
theRE - The RE to be checked

checkClass

protected void checkClass(FSAInterface<L> theFSA)
Checks that the FSA's class is supported.

Specified by:
checkClass in class AbstractRegularLanguages<L extends LabelInterface>
Parameters:
theFSA - The FSA to be checked

convertREtoFSA

public MutableFSAInterface<L> convertREtoFSA(RE<L> theRE)
                                                             throws FSAInterfaceException,
                                                                    REException
Converts from the given RE to its corresponding FSA.

PRECONDITIONS:

Specified by:
convertREtoFSA in class AbstractRegularLanguages<L extends LabelInterface>
Parameters:
theRE - The RE to be converted
Returns:
The corresponding FSA
Throws:
FSAInterfaceException - if an FSA related exception occurs
REException - if an RE related exception occurs

convertREtoDFA

public MutableFSAInterface<L> convertREtoDFA(RE<L> theRE)
                                                             throws FSAInterfaceException,
                                                                    REException
Converts from the given RE to its corresponding DFA.

PRECONDITIONS:

POSTCONDITION: The returned FSA will be deterministic.

Specified by:
convertREtoDFA in class AbstractRegularLanguages<L extends LabelInterface>
Parameters:
theRE - The RE to be converted
Returns:
The corresponding DFA
Throws:
FSAInterfaceException - if an FSA related exception occurs
REException - if an RE related exception occurs

convertFSAtoRE

public RE<L> convertFSAtoRE(RunnableFSAInterface<L> theFSA)
                                            throws FSAInterfaceException,
                                                   REException
Converts from the given FSA to its corresponding RE.

PRECONDITIONS:

Specified by:
convertFSAtoRE in class AbstractRegularLanguages<L extends LabelInterface>
Parameters:
theFSA - The FSA to be converted
Returns:
The corresponding RE
Throws:
FSAInterfaceException - if an FSA related exception occurs
REException - if an RE related exception occurs

readRE

protected RE<L> readRE(java.io.Reader in)
                                       throws java.io.IOException,
                                              REException
Reads in the RE from the given Reader.

Specified by:
readRE in class AbstractRegularLanguages<L extends LabelInterface>
Parameters:
in - The Reader to use as input (non-null)
Returns:
The RE read in
Throws:
java.io.IOException - if an I/O related error occurs
REException - if an RE related exception occurs