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

java.lang.Object
  extended by laser.regularlanguage.regularexpression.AbstractREVisitor<StringLabel>
      extended by laser.regularlanguage.regularexpression.util.StringREtoREConverter<L>
Type Parameters:
L - The type of labels used by the output REs.
All Implemented Interfaces:
REVisitor<StringLabel>

public class StringREtoREConverter<L extends LabelInterface>
extends AbstractREVisitor<StringLabel>

The StringREtoREConverter class converts from an input RE that uses StringLabels to the corresponding output RE that uses the specified Labels.

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

Field Summary
 
Fields inherited from class laser.regularlanguage.regularexpression.AbstractREVisitor
result
 
Constructor Summary
StringREtoREConverter()
          Creates a new StringREtoREConverter.
 
Method Summary
 void caseChoiceNode(ChoiceNode<StringLabel> node, java.lang.Object context)
          Allows this REVisitor to process the given ChoiceNode.
 void caseClassSetNode(ClassSetNode<StringLabel> node, java.lang.Object context)
          Allows this Visitor to process the given ClassSetNode.
 void caseConcatenationNode(ConcatenationNode<StringLabel> node, java.lang.Object context)
          Allows this REVisitor to process the given ConcatenationNode.
 void caseDotNode(DotNode<StringLabel> node, java.lang.Object context)
          Allows this REVisitor to process the given DotNode.
 void caseEmptyNode(EmptyNode<StringLabel> node, java.lang.Object context)
          Allows this REVisitor to process the given EmptyNode.
 void caseEpsilonNode(EpsilonNode<StringLabel> node, java.lang.Object context)
          Allows this REVisitor to process the given EpsilonNode.
 void caseExponentNode(ExponentNode<StringLabel> node, java.lang.Object context)
          Allows this Visitor to process the given ExponentNode.
 void caseKleenePlusNode(KleenePlusNode<StringLabel> node, java.lang.Object context)
          Allows this REVisitor to process the given KleenePlusNode.
 void caseKleeneStarNode(KleeneStarNode<StringLabel> node, java.lang.Object context)
          Allows this REVisitor to process the given KleeneStarNode.
 void caseLabelNode(LabelNode<StringLabel> node, java.lang.Object context)
          Allows this REVisitor to process the given LabelNode.
 void caseNotClassSetNode(NotClassSetNode<StringLabel> node, java.lang.Object context)
          Allows this Visitor to process the given NotClassSetNode.
 void caseOptionNode(OptionNode<StringLabel> node, java.lang.Object context)
          Allows this Visitor to process the given OptionNode
protected  L convert(StringLabel inLabel)
          Converts from the given input StringLabel to the corresponding output Label.
protected  TreeNode<L> convert(TreeNode<StringLabel> inNode)
          Converts from the given input TreeNode that uses StringLabels to the corresponding output TreeNode that uses the specified Labels.
 TreeNode<L> convert(TreeNode<StringLabel> inRE, AlphabetInterface<L> theAlphabet)
          Converts from the given input RE that uses StringLabels to the corresponding output RE that uses the specified Labels.
 TreeNode<L> getResult()
          Gets the result as a TreeNode.
 void setResult(TreeNode<L> node)
          Sets the result as a TreeNode.
 
Methods inherited from class laser.regularlanguage.regularexpression.AbstractREVisitor
defaultCase, setResult
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringREtoREConverter

public StringREtoREConverter()
Creates a new StringREtoREConverter.

Method Detail

convert

public TreeNode<L> convert(TreeNode<StringLabel> inRE,
                           AlphabetInterface<L> theAlphabet)
Converts from the given input RE that uses StringLabels to the corresponding output RE that uses the specified Labels.

PRECONDITIONS:

Parameters:
inRE - The input regular expression
theAlphabet - The output alphabet
Returns:
The corresponding output regular expression

convert

protected TreeNode<L> convert(TreeNode<StringLabel> inNode)
Converts from the given input TreeNode that uses StringLabels to the corresponding output TreeNode that uses the specified Labels.

Parameters:
inNode - The input TreeNode
Returns:
The corresponding output TreeNode

convert

protected L convert(StringLabel inLabel)
Converts from the given input StringLabel to the corresponding output Label.

Parameters:
inLabel - The input label
Returns:
The corresponding output label

getResult

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

Overrides:
getResult in class AbstractREVisitor<StringLabel>
Returns:
The result as a TreeNode

setResult

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

Parameters:
node - The result as a TreeNode

caseChoiceNode

public void caseChoiceNode(ChoiceNode<StringLabel> node,
                           java.lang.Object context)
Allows this REVisitor to process the given ChoiceNode.

Specified by:
caseChoiceNode in interface REVisitor<StringLabel>
Overrides:
caseChoiceNode in class AbstractREVisitor<StringLabel>
Parameters:
node - The ChoiceNode to be processed
context - The calling context
Throws:
REVisitorException - if an error occurs

caseClassSetNode

public void caseClassSetNode(ClassSetNode<StringLabel> node,
                             java.lang.Object context)
Allows this Visitor to process the given ClassSetNode.

Specified by:
caseClassSetNode in interface REVisitor<StringLabel>
Overrides:
caseClassSetNode in class AbstractREVisitor<StringLabel>
Parameters:
node - The ClassSetNode to be processed
context - The calling context
Throws:
REVisitorException - if an error occurs

caseConcatenationNode

public void caseConcatenationNode(ConcatenationNode<StringLabel> node,
                                  java.lang.Object context)
Allows this REVisitor to process the given ConcatenationNode.

Specified by:
caseConcatenationNode in interface REVisitor<StringLabel>
Overrides:
caseConcatenationNode in class AbstractREVisitor<StringLabel>
Parameters:
node - The ConcatenationNode to be processed
context - The calling context
Throws:
REVisitorException - if an error occurs

caseDotNode

public void caseDotNode(DotNode<StringLabel> node,
                        java.lang.Object context)
Allows this REVisitor to process the given DotNode.

Specified by:
caseDotNode in interface REVisitor<StringLabel>
Overrides:
caseDotNode in class AbstractREVisitor<StringLabel>
Parameters:
node - The DotNode to be processed
context - The calling context
Throws:
REVisitorException - if an error occurs

caseEmptyNode

public void caseEmptyNode(EmptyNode<StringLabel> node,
                          java.lang.Object context)
Allows this REVisitor to process the given EmptyNode.

Specified by:
caseEmptyNode in interface REVisitor<StringLabel>
Overrides:
caseEmptyNode in class AbstractREVisitor<StringLabel>
Parameters:
node - The EmptyNode to be processed
context - The calling context
Throws:
REVisitorException - if an error occurs

caseEpsilonNode

public void caseEpsilonNode(EpsilonNode<StringLabel> node,
                            java.lang.Object context)
Allows this REVisitor to process the given EpsilonNode.

Specified by:
caseEpsilonNode in interface REVisitor<StringLabel>
Overrides:
caseEpsilonNode in class AbstractREVisitor<StringLabel>
Parameters:
node - The EpsilonNode to be processed
context - The calling context
Throws:
REVisitorException - if an error occurs

caseExponentNode

public void caseExponentNode(ExponentNode<StringLabel> node,
                             java.lang.Object context)
Allows this Visitor to process the given ExponentNode.

Specified by:
caseExponentNode in interface REVisitor<StringLabel>
Overrides:
caseExponentNode in class AbstractREVisitor<StringLabel>
Parameters:
node - The ExponentNode to be processed
context - The calling context
Throws:
REVisitorException - if an error occurs

caseKleenePlusNode

public void caseKleenePlusNode(KleenePlusNode<StringLabel> node,
                               java.lang.Object context)
Allows this REVisitor to process the given KleenePlusNode.

Specified by:
caseKleenePlusNode in interface REVisitor<StringLabel>
Overrides:
caseKleenePlusNode in class AbstractREVisitor<StringLabel>
Parameters:
node - The KleenePlusNode to be processed
context - The calling context
Throws:
REVisitorException - if an error occurs

caseKleeneStarNode

public void caseKleeneStarNode(KleeneStarNode<StringLabel> node,
                               java.lang.Object context)
Allows this REVisitor to process the given KleeneStarNode.

Specified by:
caseKleeneStarNode in interface REVisitor<StringLabel>
Overrides:
caseKleeneStarNode in class AbstractREVisitor<StringLabel>
Parameters:
node - The KleeneStarNode to be processed
context - The calling context
Throws:
REVisitorException - if an error occurs

caseLabelNode

public void caseLabelNode(LabelNode<StringLabel> node,
                          java.lang.Object context)
Allows this REVisitor to process the given LabelNode.

Specified by:
caseLabelNode in interface REVisitor<StringLabel>
Overrides:
caseLabelNode in class AbstractREVisitor<StringLabel>
Parameters:
node - The LabelNode to be processed
context - The calling context
Throws:
REVisitorException - if an error occurs

caseNotClassSetNode

public void caseNotClassSetNode(NotClassSetNode<StringLabel> node,
                                java.lang.Object context)
Allows this Visitor to process the given NotClassSetNode.

Specified by:
caseNotClassSetNode in interface REVisitor<StringLabel>
Overrides:
caseNotClassSetNode in class AbstractREVisitor<StringLabel>
Parameters:
node - The NotClassSetNode to be processed
context - The calling context
Throws:
REVisitorException - if an error occurs

caseOptionNode

public void caseOptionNode(OptionNode<StringLabel> node,
                           java.lang.Object context)
Allows this Visitor to process the given OptionNode

Specified by:
caseOptionNode in interface REVisitor<StringLabel>
Overrides:
caseOptionNode in class AbstractREVisitor<StringLabel>
Parameters:
node - The OptionNode to be processed
context - The calling context
Throws:
REVisitorException - if an error occurs