edu.uky.rch.ept.xmlSegmentTree
Interface SegmentTreeVisitor

All Known Implementing Classes:
AbstractSegmentTreeVisitor

public interface SegmentTreeVisitor

Interface for traversing a segment tree. A SegmentTreeVisitor is passed as the first argument of SegmentTree.traverse(SegmentTreeVisitor, ElementFilter); that visitor object receives a message at each step in the traversal of a segment tree. The sequence of calls is generally:

  1. enter()
  2. beginElement() for each element beginning at this node
  3. preLeft(). If true:
  4. preRight(). If true:
  5. endElement() for each element ending at this node


Method Summary
 void beginElement(Element e)
          Called for each Element beginning at this node.
 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.
 

Method Detail

enter

public void enter(Position left,
                  Position right)
           throws TraversalException
Called as a node of the segment tree is entered.

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
Called just before recursing to the left subtree.

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
Called just after recursing to the left subtree.

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 void beginElement(Element e)
                  throws TraversalException
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.

Parameters:
e - the element.
Throws:
TraversalException - to end the traversal

endElement

public void endElement(Element e)
                throws TraversalException
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.

Parameters:
e - the element.
Throws:
TraversalException - to end the traversal

preRight

public boolean preRight(Position left,
                        Position mid,
                        Position right)
                 throws TraversalException
Called just before recursing to the right subtree.

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
Called just after recursing to the right subtree.

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
Called just before SegmentTree.traverse() returns.

Throws:
TraversalException - to end the traversal

getData

public Object getData()
Retrieve data computed by the traversal. This method is not called by SegmentTree.traverse().

Returns:
data computed during the traversal, possibly null.