laser.regularlanguage.regularexpression
Class ClassSetNode<L extends LabelInterface>

java.lang.Object
  extended by laser.regularlanguage.regularexpression.TreeNode<L>
      extended by laser.regularlanguage.regularexpression.ClassSetNode<L>
Type Parameters:
L - The type of Label associated with this regular expression
All Implemented Interfaces:
java.io.Serializable, REConstants

public class ClassSetNode<L extends LabelInterface>
extends TreeNode<L>

ClassSetNode is a leaf node in the Regular Expression Parse Tree representing a set of labels, meaning a choice between any label in the set.

Author:
Jamieson M. Cobleigh (laser-software@cs.umass.edu)
See Also:
Serialized Form

Field Summary
 
Fields inherited from class laser.regularlanguage.regularexpression.TreeNode
LS
 
Fields inherited from interface laser.regularlanguage.regularexpression.REConstants
CHOICE, COMMA, COMMENT_PREFIX, CONCATENATION, DOT, EMPTY, EPSILON, EXPONENT, KLEENE_PLUS, KLEENE_STAR, LBRACE, LBRACKET, LPAREN, NOT, OPTION, RANGE, RBRACE, RBRACKET, RPAREN
 
Constructor Summary
ClassSetNode()
          Creates a new empty ClassSetNode.
ClassSetNode(java.util.Set<L> s)
          Creates a new ClassSetNode containing the Labels in the given Set
 
Method Summary
 void addLabel(L label)
          Adds a label to the Set
 void apply(REVisitor<L> visitor, java.lang.Object context)
          Applies the given REVisitor to this TreeNode.
 ClassSetNode<L> copyTree()
          Returns a copy of the Tree rooted at this node.
 boolean equalsTree(TreeNode<L> node2)
          Returns true if the tree rooted at this node and the tree rooted at the given node are equal and false otherwise.
 java.util.List<TreeNode<L>> getChildren()
          Returns a List of the children of this TreeNode.
 java.util.Set<L> getLabels()
          Gets the labels in the Set
 java.util.Set<L> getLabelsUsed()
          Returns a Set of the labels used by this TreeNode.
 java.lang.String print(java.lang.String prefix)
          Prints the Tree rooted at this node.
 
Methods inherited from class laser.regularlanguage.regularexpression.TreeNode
toString, trace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ClassSetNode

public ClassSetNode()
Creates a new empty ClassSetNode.


ClassSetNode

public ClassSetNode(java.util.Set<L> s)
Creates a new ClassSetNode containing the Labels in the given Set

Parameters:
s - the Set of Labels to add
Method Detail

addLabel

public void addLabel(L label)
Adds a label to the Set

Parameters:
label - the label to add

getLabels

public java.util.Set<L> getLabels()
Gets the labels in the Set

Returns:
The labels in the Set

apply

public void apply(REVisitor<L> visitor,
                  java.lang.Object context)
           throws REVisitorException
Applies the given REVisitor to this TreeNode.

Specified by:
apply in class TreeNode<L extends LabelInterface>
Parameters:
visitor - The REVisitor to be applied
context - The calling context
Throws:
REVisitorException - if an error occurs

copyTree

public ClassSetNode<L> copyTree()
Returns a copy of the Tree rooted at this node. This will fail to terminate if the tree becomes a cyclic graph.

Specified by:
copyTree in class TreeNode<L extends LabelInterface>
Returns:
a copy of the Tree rooted at this node

print

public java.lang.String print(java.lang.String prefix)
Prints the Tree rooted at this node. This will fail to terminate if the tree becomes a cyclic graph.

Specified by:
print in class TreeNode<L extends LabelInterface>
Parameters:
prefix - The string to be appended before everything printed for this level. Should be a String of spaces
Returns:
A string representation of this TreeNode

getChildren

public java.util.List<TreeNode<L>> getChildren()
Returns a List of the children of this TreeNode.

Specified by:
getChildren in class TreeNode<L extends LabelInterface>
Returns:
A List of the children of this TreeNode

getLabelsUsed

public java.util.Set<L> getLabelsUsed()
Returns a Set of the labels used by this TreeNode.

Specified by:
getLabelsUsed in class TreeNode<L extends LabelInterface>
Returns:
A Set of the labels used by this TreeNode

equalsTree

public boolean equalsTree(TreeNode<L> node2)
Returns true if the tree rooted at this node and the tree rooted at the given node are equal and false otherwise.

NOTE: This will fail to terminate if the tree becomes a cyclic graph.

Overrides:
equalsTree in class TreeNode<L extends LabelInterface>
Parameters:
node2 - The second TreeNode
Returns:
True if this TreeNode and the given TreeNode are equal and false otherwise