laser.regularlanguage.regularexpression.util
Class AbstractREConverter<L extends LabelInterface>

java.lang.Object
  extended by laser.regularlanguage.regularexpression.AbstractREVisitor<L>
      extended by laser.regularlanguage.regularexpression.util.AbstractREConverter<L>
Type Parameters:
L - The type of labels associated with the REs.
All Implemented Interfaces:
REVisitor<L>
Direct Known Subclasses:
ExtendedREToREConverter, RESimplifier

public abstract class AbstractREConverter<L extends LabelInterface>
extends AbstractREVisitor<L>

The AbstractREConverter class allows the given old RE to be converted to the corresponding new RE.

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

Field Summary
protected  REFactory<L> reFactory_
          The REFactory to be used to create new REs
 
Fields inherited from class laser.regularlanguage.regularexpression.AbstractREVisitor
result
 
Constructor Summary
protected AbstractREConverter(REFactory<L> reFactory)
          Creates a new AbstractREConverter.
 
Method Summary
protected  RE<L> convert(RE<L> oldRE)
          Converts from the old RE to the corresponding new RE.
protected  TreeNode<L> convert(TreeNode<L> oldTreeNode)
          Converts from the old TreeNode into the corresponding new TreeNode.
protected  java.lang.Object[] getCreateREArgs(RE<L> oldRE)
          Gets the appropriate REFactory createRE arguments from the given old RE.
 TreeNode<L> getResult()
          Gets the result as a TreeNode.
 void setResult(TreeNode<L> newTreeNode)
          Sets the result as a TreeNode.
protected  void setUp(RE<L> oldRE)
          Sets up this AbstractREConverter before converting.
protected  void tearDown()
          Tears down this AbstractREFactory after converting.
 
Methods inherited from class laser.regularlanguage.regularexpression.AbstractREVisitor
caseChoiceNode, caseClassSetNode, caseConcatenationNode, caseDotNode, caseEmptyNode, caseEpsilonNode, caseExponentNode, caseKleenePlusNode, caseKleeneStarNode, caseLabelNode, caseNotClassSetNode, caseOptionNode, defaultCase, setResult
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

reFactory_

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

Constructor Detail

AbstractREConverter

protected AbstractREConverter(REFactory<L> reFactory)
Creates a new AbstractREConverter.

PRECONDITION: The REFactory must be non-null.

Parameters:
reFactory - The REFactory to be used to create new REs
Method Detail

convert

protected RE<L> convert(RE<L> oldRE)
                                        throws REException
Converts from the old RE to the corresponding new RE.

PRECONDITIONS:

Parameters:
oldRE - The old RE to be converted
Returns:
The new RE
Throws:
REException - if the old RE cannot be converted

setUp

protected void setUp(RE<L> oldRE)
              throws REException
Sets up this AbstractREConverter before converting.

Parameters:
oldRE - The old RE to be used as context
Throws:
REException - if the set up cannot be completed successfully

convert

protected TreeNode<L> convert(TreeNode<L> oldTreeNode)
                                              throws REVisitorException
Converts from the old TreeNode into the corresponding new TreeNode.

Parameters:
oldTreeNode - The old TreeNode to be converted
Returns:
The corresponding new TreeNode
Throws:
REVisitorException - if the old TreeNode cannot be converted successfully

getCreateREArgs

protected java.lang.Object[] getCreateREArgs(RE<L> oldRE)
Gets the appropriate REFactory createRE arguments from the given old RE.

Parameters:
oldRE - The old RE to be used as context
Returns:
The appropriate REFactory createRE arguments

tearDown

protected void tearDown()
Tears down this AbstractREFactory after converting.


getResult

public TreeNode<L> getResult()
Gets the result as a TreeNode.

Overrides:
getResult in class AbstractREVisitor<L extends LabelInterface>
Returns:
The result as a TreeNode

setResult

public void setResult(TreeNode<L> newTreeNode)
Sets the result as a TreeNode.

Parameters:
newTreeNode - The result as a TreeNode