edu.uky.rch.ept.xmlSegmentTree
Class AbstractSegmentTreeVisitor

java.lang.Object
  extended byedu.uky.rch.ept.xmlSegmentTree.AbstractSegmentTreeVisitor
All Implemented Interfaces:
SegmentTreeVisitor
Direct Known Subclasses:
SegmentTree.OutputVisitor, SegmentTree.TransformedOutputVisitor

public abstract class AbstractSegmentTreeVisitor
extends Object
implements SegmentTreeVisitor

Abstract class for traversing a segment tree. Contains default implementations of all the methods of SegmentTreeVisitor except beginElement() and endElement(). These default implementations do nothing; preLeft() and preRight() always return true. getData() always returns null.


Constructor Summary
AbstractSegmentTreeVisitor()
           
 
Method Summary
abstract  void beginElement(Element e)
          Called for each Element beginning at this node.
abstract  void endElement(Element e)
          Called for each Element ending at this node.
 void enter(Position left, Position right)
          Called as a node of the segment tree is entered.
 void finished()
          Called just before SegmentTree.traverse() returns.
 Object getData()
          Retrieve data computed by the traversal.
 void postLeft(Position left, Position mid, Position right)
          Called just after recursing to the left subtree.
 void postRight(Position left, Position mid, Position right)
          Called just after recursing to the right subtree.
 boolean preLeft(Position left, Position mid, Position right)
          Called just before recursing to the left subtree.
 boolean preRight(Position left, Position mid, Position right)
          Called just before recursing to the right subtree.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractSegmentTreeVisitor

public AbstractSegmentTreeVisitor()
Method Detail

enter

public void enter(Position left,
                  Position right)
           throws TraversalException
Description copied from interface: SegmentTreeVisitor
Called as a node of the segment tree is entered.

Specified by:
enter in interface SegmentTreeVisitor
Parameters:
left - the lower bound for this node.
right - the upper bound for this node.
Throws:
TraversalException - to end the traversal

preLeft

public boolean preLeft(Position left,
                       Position mid,
                       Position right)
                throws TraversalException
Description copied from interface: SegmentTreeVisitor
Called just before recursing to the left subtree.

Specified by:
preLeft in interface SegmentTreeVisitor
Parameters:
left - the left bound for this node and the left subtree
mid - the right bound for the left subtree
right - the right bound for this node
Returns:
true if we should continue down the left subtree, false otherwise
Throws:
TraversalException - to end the traversal

postLeft

public void postLeft(Position left,
                     Position mid,
                     Position right)
              throws TraversalException
Description copied from interface: SegmentTreeVisitor
Called just after recursing to the left subtree.

Specified by:
postLeft in interface SegmentTreeVisitor
Parameters:
left - the left bound for this node and the left subtree
mid - the right bound for the left subtree
right - the right bound for this node
Throws:
TraversalException - to end the traversal

beginElement

public abstract void beginElement(Element e)
                           throws TraversalException
Description copied from interface: SegmentTreeVisitor
Called for each Element beginning at this node. Called first for tagged elements, in decreasing order of length, then for string elements, in decreasing order of length.

Specified by:
beginElement in interface SegmentTreeVisitor
Parameters:
e - the element.
Throws:
TraversalException - to end the traversal

endElement

public abstract void endElement(Element e)
                         throws TraversalException
Description copied from interface: SegmentTreeVisitor
Called for each Element ending at this node. Called first for string elements, in increasing order of length, then for tagged elements, in increasing order of length.

Specified by:
endElement in interface SegmentTreeVisitor
Parameters:
e - the element.
Throws:
TraversalException - to end the traversal

preRight

public boolean preRight(Position left,
                        Position mid,
                        Position right)
                 throws TraversalException
Description copied from interface: SegmentTreeVisitor
Called just before recursing to the right subtree.

Specified by:
preRight in interface SegmentTreeVisitor
Parameters:
left - the left bound for this node
mid - the left bound for the right subtree
right - the right bound for this node and the right subtree
Returns:
true if we should continue down the right subtree, false otherwise
Throws:
TraversalException - to end the traversal

postRight

public void postRight(Position left,
                      Position mid,
                      Position right)
               throws TraversalException
Description copied from interface: SegmentTreeVisitor
Called just after recursing to the right subtree.

Specified by:
postRight in interface SegmentTreeVisitor
Parameters:
left - the left bound for this node
mid - the left bound for the right subtree
right - the right bound for this node and the right subtree
Throws:
TraversalException - to end the traversal

finished

public void finished()
              throws TraversalException
Description copied from interface: SegmentTreeVisitor
Called just before SegmentTree.traverse() returns.

Specified by:
finished in interface SegmentTreeVisitor
Throws:
TraversalException - to end the traversal

getData

public Object getData()
Description copied from interface: SegmentTreeVisitor
Retrieve data computed by the traversal. This method is not called by SegmentTree.traverse().

Specified by:
getData in interface SegmentTreeVisitor
Returns:
data computed during the traversal, possibly null.