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

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

public abstract class AbstractRegularLanguages<L extends LabelInterface>
extends java.lang.Object

The AbstractRegularLanguages 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 is not well-formed.

Define the alphabet of RE R to be Σ(R) the set of all labels used by RE R.

Define the language of RE R to be L(R) the set of all input strings accepted by RE R.

Define the alphabet of FSA M to be Σ(M) the set of all labels used by FSA M.

Define the language of FSA M to be L(M) the set of all input strings accepted by FSA M.

Author:
Heather M. Conboy (laser-software@cs.umass.edu)
See Also:
RE, FSAInterface, MutableFSAInterface, RunnableFSAInterface

Field Summary
protected  FSAFactoryInterface<L> dfaFactory_
          The FSAFactoryInterface to be used to create new DFAs
protected  FSAFactoryInterface<L> fsaFactory_
          The FSAFactoryInterface to be used to create new FSAs
protected  REFactory<L> reFactory_
          The REFactory to be used to create new REs
protected  RLFactory<L> rlFactory_
          The RLFactory to be used to convert between REs and FSAs
 
Constructor Summary
protected AbstractRegularLanguages(REFactory<L> reFactory, FSAFactoryInterface<L> fsaFactory, FSAFactoryInterface<L> dfaFactory, RLFactory<L> rlFactory)
          Creates a new AbstractRegularLanguages class.
 
Method Summary
protected abstract  void checkClass(FSAInterface<L> theFSA)
          Checks that the FSA's class is supported.
protected abstract  void checkClass(RE<L> theRE)
          Checks that the RE's class is supported.
protected  void checkPreconditions(FSAInterface<L> theFSA)
          Checks the preconditions for the given FSA.
protected  void checkPreconditions(RE<L> theRE)
          Checks the preconditions for the given RE.
 RE<L> convertDFAtoRE(RunnableFSAInterface<L> theDFA)
          Converts from the given DFA to its corresponding RE.
abstract  RE<L> convertFSAtoRE(RunnableFSAInterface<L> theFSA)
          Converts from the given FSA to its corresponding RE.
 MutableFSAInterface<L> convertREtoDFA(java.io.File theREFile)
          Converts from the given RE to its corresponding DFA.
abstract  MutableFSAInterface<L> convertREtoDFA(RE<L> theRE)
          Converts from the given RE to its corresponding DFA.
 MutableFSAInterface<L> convertREtoDFA(java.io.Reader theREReader)
          Converts from the given RE to its corresponding DFA.
 MutableFSAInterface<L> convertREtoFSA(java.io.File theREFile)
          Converts from the given RE to its corresponding FSA.
abstract  MutableFSAInterface<L> convertREtoFSA(RE<L> theRE)
          Converts from the given RE to its corresponding FSA.
 MutableFSAInterface<L> convertREtoFSA(java.io.Reader theREReader)
          Converts from the given RE to its corresponding FSA.
 FSAFactoryInterface<L> getDFAFactory()
          Gets the FSAFactory to be used to create new DFAs.
 FSAFactoryInterface<L> getFSAFactory()
          Gets the FSAFactory to be used to create new FSAs.
 REFactory<L> getREFactory()
          Gets the REFactory to be used to create new REs.
 RLFactory<L> getRLFactory()
          Gets the RLFactory to be used to convert between REs and FSAs.
protected abstract  RE<L> readRE(java.io.Reader in)
          Reads in the RE from the given Reader.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

reFactory_

protected final REFactory<L extends LabelInterface> reFactory_
The REFactory to be used to create new REs


rlFactory_

protected final RLFactory<L extends LabelInterface> rlFactory_
The RLFactory to be used to convert between REs and FSAs


fsaFactory_

protected final FSAFactoryInterface<L extends LabelInterface> fsaFactory_
The FSAFactoryInterface to be used to create new FSAs


dfaFactory_

protected final FSAFactoryInterface<L extends LabelInterface> dfaFactory_
The FSAFactoryInterface to be used to create new DFAs

Constructor Detail

AbstractRegularLanguages

protected AbstractRegularLanguages(REFactory<L> reFactory,
                                   FSAFactoryInterface<L> fsaFactory,
                                   FSAFactoryInterface<L> dfaFactory,
                                   RLFactory<L> rlFactory)
Creates a new AbstractRegularLanguages 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

checkClass

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

Parameters:
theRE - The RE to be checked

checkClass

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

Parameters:
theFSA - The FSA to be checked

checkPreconditions

protected void checkPreconditions(RE<L> theRE)
Checks the preconditions for the given RE.

Parameters:
theRE - The RE to be checked

checkPreconditions

protected void checkPreconditions(FSAInterface<L> theFSA)
Checks the preconditions for the given FSA.

Parameters:
theFSA - The FSA to be checked

getREFactory

public REFactory<L> getREFactory()
Gets the REFactory to be used to create new REs.

Returns:
The REFactory

getFSAFactory

public FSAFactoryInterface<L> getFSAFactory()
Gets the FSAFactory to be used to create new FSAs.

Returns:
The FSAFactory

getDFAFactory

public FSAFactoryInterface<L> getDFAFactory()
Gets the FSAFactory to be used to create new DFAs.

Returns:
The FSAFactory

getRLFactory

public RLFactory<L> getRLFactory()
Gets the RLFactory to be used to convert between REs and FSAs.

Returns:
The RLFactory

convertREtoFSA

public MutableFSAInterface<L> convertREtoFSA(java.io.File theREFile)
                                                             throws FSAInterfaceException,
                                                                    java.io.IOException,
                                                                    REException
Converts from the given RE to its corresponding FSA.

Parameters:
theREFile - The File that contains the RE to be converted (non-null)
Returns:
The corresponding FSA
Throws:
FSAInterfaceException - if an FSA related exception occurs
java.io.IOException - if an I/O related error occurs
REException - if an RE related exception occurs

convertREtoFSA

public MutableFSAInterface<L> convertREtoFSA(java.io.Reader theREReader)
                                                             throws FSAInterfaceException,
                                                                    java.io.IOException,
                                                                    REException
Converts from the given RE to its corresponding FSA.

Parameters:
theREReader - The Reader that contains the RE to be converted (non-null)
Returns:
The corresponding FSA
Throws:
FSAInterfaceException - if an FSA related exception occurs
java.io.IOException - if an I/O related error occurs
REException - if an RE related exception occurs

convertREtoFSA

public abstract MutableFSAInterface<L> convertREtoFSA(RE<L> theRE)
                                                                      throws FSAInterfaceException,
                                                                             REException
Converts from the given RE to its corresponding FSA. Call the returned FSA theFSA. Formally, Σ(theFSA) is Σ(theRE) and L(theFSA) is L(theRE).

PRECONDITIONS:

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(java.io.File theREFile)
                                                             throws FSAInterfaceException,
                                                                    java.io.IOException,
                                                                    REException
Converts from the given RE to its corresponding DFA.

POSTCONDITION: The returned FSA will be deterministic.

Parameters:
theREFile - The File that contains the RE to be converted (non-null)
Returns:
The corresponding DFA
Throws:
FSAInterfaceException - if an FSA related exception occurs
java.io.IOException - if an I/O related error occurs
REException - if an RE related exception occurs

convertREtoDFA

public MutableFSAInterface<L> convertREtoDFA(java.io.Reader theREReader)
                                                             throws FSAInterfaceException,
                                                                    java.io.IOException,
                                                                    REException
Converts from the given RE to its corresponding DFA.

POSTCONDITION: The returned FSA will be deterministic.

Parameters:
theREReader - The Reader that contains the RE to be converted (non-null)
Returns:
The corresponding DFA
Throws:
FSAInterfaceException - if an FSA related exception occurs
java.io.IOException - if an I/O related error occurs
REException - if an RE related exception occurs

convertREtoDFA

public abstract MutableFSAInterface<L> convertREtoDFA(RE<L> theRE)
                                                                      throws FSAInterfaceException,
                                                                             REException
Converts from the given RE to its corresponding DFA. Call the returned DFA theDFA. Formally, Σ(theDFA) is Σ(theRE) and L(theDFA) is L(theRE).

PRECONDITIONS:

POSTCONDITION: The returned FSA will be deterministic.

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

convertDFAtoRE

public RE<L> convertDFAtoRE(RunnableFSAInterface<L> theDFA)
                                            throws FSAInterfaceException,
                                                   REException
Converts from the given DFA to its corresponding RE. Call the returned RE theRE. Formally, Σ(theRE) is Σ(theDFA) and L(theRE) is L(theDFA).

PRECONDITIONS:

Parameters:
theDFA - The DFA to be converted
Returns:
The corresponding RE
Throws:
FSAInterfaceException - if an FSA related exception occurs
REException - if an RE related exception occurs

convertFSAtoRE

public abstract RE<L> convertFSAtoRE(RunnableFSAInterface<L> theFSA)
                                                     throws FSAInterfaceException,
                                                            REException
Converts from the given FSA to its corresponding RE. Call the returned RE theRE. Formally, Σ(theRE) is Σ(theFSA) and L(theRE) is L(theFSA).

PRECONDITIONS:

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 abstract RE<L> readRE(java.io.Reader in)
                                                throws java.io.IOException,
                                                       REException
Reads in the RE from the given Reader.

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