it.unimi.dsi.mg4j.search.visitor
Interface DocumentIteratorVisitor

All Known Implementing Classes:
AbstractDocumentIteratorVisitor, CounterCollectionVisitor, CounterSetupVisitor, TermCollectionVisitor

public interface DocumentIteratorVisitor

A visitor for the tree defined by a DocumentIterator.

Implementations of this interface must be reusable. The user must invoke prepare() before a visit so that the internal state of the visitor can be suitably set up.

For maximum flexibility, there is just one visit method for leaves, but two visits methods for internal nodes, which should be used for preorder and postorder visits, respectively.

Note that this visitor interface and that defined in QueryBuilderVisitor are based on different principles: in the latter case, the action of the visitor will likely be different for each type of internal node, so we have specific visit methods for each type of such nodes. In our case, the visit will most likely behave differently just for internal nodes and leaves, so we prefer a simpler interface thatalso let us implement more easily visitor acceptance methods (DocumentIterator.accept(DocumentIteratorVisitor) and DocumentIterator.acceptOnTruePaths(DocumentIteratorVisitor)).

Author:
Sebastiano Vigna

Method Summary
 DocumentIteratorVisitor prepare()
          Prepares the internal state of this visitor for a(nother) visit.
 boolean visit(IndexIterator indexIterator)
          Visits a leaf.
 boolean visitPost(DocumentIterator documentIterator)
          Visits an internal node after recursing into the corresponding subtree.
 boolean visitPre(DocumentIterator documentIterator)
          Visits an internal node before recursing into the corresponding subtree.
 

Method Detail

prepare

DocumentIteratorVisitor prepare()
Prepares the internal state of this visitor for a(nother) visit.

By specification, it must be safe to call this method any number of times.

Returns:
this visitor.

visitPre

boolean visitPre(DocumentIterator documentIterator)
Visits an internal node before recursing into the corresponding subtree.

Parameters:
documentIterator - the internal node to be visited.
Returns:
true if the visit should continue.

visitPost

boolean visitPost(DocumentIterator documentIterator)
Visits an internal node after recursing into the corresponding subtree.

Parameters:
documentIterator - the internal node to be visited.
Returns:
true if the visit should continue.

visit

boolean visit(IndexIterator indexIterator)
              throws IOException
Visits a leaf.

Parameters:
indexIterator - the leaf to be visited.
Returns:
true if the visit should continue.
Throws:
IOException