Interface QueryBuilderVisitor<T>
-
- All Superinterfaces:
FlyweightPrototype<QueryBuilderVisitor<T>>
- All Known Implementing Classes:
AbstractQueryBuilderVisitor,AbstractTermExpander.ExpanderVisitor,CheckForSelectQueryVisitor,DocumentIteratorBuilderVisitor,MultiIndexTermExpander.ExpanderVisitor
public interface QueryBuilderVisitor<T> extends FlyweightPrototype<QueryBuilderVisitor<T>>
A visitor for a composite query.Instances of this class are builder visitors, that is, visitors that during their visit build a complex object (of course, it is possible not building an object at all).
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.The most typical usage of this class is that of building document iterators following the structure of the query. By writing different builder visitors for different families of document iterators, parsing and document-iterator construction are completely decoupled.
Note that this visitor interface and that defined in
DocumentIteratorVisitorare based on different principles: see the comments therein.- Author:
- Sebastiano Vigna
-
-
Method Summary
Modifier and Type Method Description QueryBuilderVisitor<T>copy()T[]newArray(int len)Builds an array of given length of typeT.QueryBuilderVisitor<T>prepare()Prepares the internal state of this visitor for a(nother) visit.Tvisit(False node)VisitsFalse.Tvisit(Prefix node)Visits aPrefix.Tvisit(Range node)Visits aRange.Tvisit(Term node)Visits aTerm.Tvisit(True node)VisitsTrue.TvisitPost(Align node, T[] subNodeResult)Visits anAlignnode after recursing into the corresponding subtree.TvisitPost(And node, T[] subNodeResult)Visits anAndnode after recursing into the corresponding subtree.TvisitPost(Annotation node, T subNodeResult)Visits aAnnotationnode after recursing into the corresponding subtree.TvisitPost(Consecutive node, T[] subNodeResult)Visits aConsecutivenode after recursing into the corresponding subtree.TvisitPost(Containment node, T[] subNodeResult)Visits anContainmentnode after recursing into the corresponding subtree.TvisitPost(Difference node, T[] subNodeResult)Visits aDifferencenode after recursing into the corresponding subtree.TvisitPost(Inclusion node, T[] subNodeResult)Visits anInclusionnode after recursing into the corresponding subtree.TvisitPost(LowPass node, T subNodeResult)Visits aLowPassnode after recursing into the corresponding subtree.TvisitPost(MultiTerm node, T[] subNodeResult)Visits aMultiTermnode after recursing into the corresponding subtree.TvisitPost(Not node, T subNodeResult)Visits aNotnode after recursing into the corresponding subtree.TvisitPost(OrderedAnd node, T[] subNodeResult)Visits anOrderedAndnode after recursing into the corresponding subtree.TvisitPost(Or node, T[] subNodeResult)Visits anOrnode after recursing into the corresponding subtree.TvisitPost(Remap node, T subNodeResult)Visits aRemapnode after recursing into the corresponding subtree.TvisitPost(Select node, T subNodeResult)Visits aSelectnode after recursing into the corresponding subtree.TvisitPost(Weight node, T subNodeResult)Visits aWeightnode after recursing into the corresponding subtree.booleanvisitPre(Align node)Visits anAlignnode before recursing into the corresponding subtree.booleanvisitPre(And node)Visits anAndnode before recursing into the corresponding subtree.booleanvisitPre(Annotation node)Visits aAnnotationnode before recursing into the corresponding subtree.booleanvisitPre(Consecutive node)Visits aConsecutivenode before recursing into the corresponding subtree.booleanvisitPre(Containment node)Visits anContainmentnode before recursing into the corresponding subtree.booleanvisitPre(Difference node)Visits aDifferencenode before recursing into the corresponding subtree.booleanvisitPre(Inclusion node)Visits anInclusionnode before recursing into the corresponding subtree.booleanvisitPre(LowPass node)Visits aLowPassnode before recursing into the corresponding subtree.booleanvisitPre(MultiTerm node)Visits aMultiTermnode before recursing into the corresponding subtree.booleanvisitPre(Not node)Visits aNotnode before recursing into the corresponding subtree.booleanvisitPre(Or node)Visits anOrnode before recursing into the corresponding subtree.booleanvisitPre(OrderedAnd node)Visits anOrderedAndnode before recursing into the corresponding subtree.booleanvisitPre(Remap node)Visits aRemapnode before recursing into the corresponding subtree.booleanvisitPre(Select node)Visits aSelectnode before recursing into the corresponding subtree.booleanvisitPre(Weight node)Visits aWeightnode before recursing into the corresponding subtree.
-
-
-
Method Detail
-
prepare
QueryBuilderVisitor<T> 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.
-
newArray
T[] newArray(int len)
Builds an array of given length of typeT.Because of erasure, generic classes in Java cannot allocate arrays of generic types. This impossibility can be a problem if for some reason the
visitPost()methods expect an actual array of typeT. This method must provide an array of given length that is an acceptable input for allvisitPost()methods.Note that by declaring an implementing class of this interface that has a sole constructor accepting an argument of type
Class<T>, you will force the user to provide the class of the generic type, opening the way for the reflective methods inArray.- Parameters:
len- the required array length.- Returns:
- an array of type
Tof lengthlen.
-
visitPre
boolean visitPre(And node) throws QueryBuilderVisitorException
Visits anAndnode before recursing into the corresponding subtree.- Parameters:
node- the node to be visited.- Returns:
- true if the visit should continue.
- Throws:
QueryBuilderVisitorException
-
visitPost
T visitPost(And node, T[] subNodeResult) throws QueryBuilderVisitorException
Visits anAndnode after recursing into the corresponding subtree.- Parameters:
node- the internal node to be visited.subNodeResult- the array of results returned by subnodes.- Returns:
- an appropriate return value (usually, the object built using the elements in
subNodeResult) if the visit should continue, ornull. - Throws:
QueryBuilderVisitorException
-
visitPre
boolean visitPre(Consecutive node) throws QueryBuilderVisitorException
Visits aConsecutivenode before recursing into the corresponding subtree.- Parameters:
node- the node to be visited.- Returns:
- true if the visit should continue.
- Throws:
QueryBuilderVisitorException
-
visitPost
T visitPost(Consecutive node, T[] subNodeResult) throws QueryBuilderVisitorException
Visits aConsecutivenode after recursing into the corresponding subtree.- Parameters:
node- the internal node to be visited.subNodeResult- the array of results returned by subnodes.- Returns:
- an appropriate return value (usually, the object built using the elements in
subNodeResult) if the visit should continue, ornull. - Throws:
QueryBuilderVisitorException
-
visitPre
boolean visitPre(LowPass node) throws QueryBuilderVisitorException
Visits aLowPassnode before recursing into the corresponding subtree.- Parameters:
node- the node to be visited.- Returns:
- true if the visit should continue.
- Throws:
QueryBuilderVisitorException
-
visitPost
T visitPost(LowPass node, T subNodeResult) throws QueryBuilderVisitorException
Visits aLowPassnode after recursing into the corresponding subtree.- Parameters:
node- the internal node to be visited.subNodeResult- the of result returned by the sole subnode.- Returns:
- an appropriate return value (usually, the object built using
subNodeResult) if the visit should continue, ornull. - Throws:
QueryBuilderVisitorException
-
visitPre
boolean visitPre(Annotation node) throws QueryBuilderVisitorException
Visits aAnnotationnode before recursing into the corresponding subtree.- Parameters:
node- the node to be visited.- Returns:
- true if the visit should continue.
- Throws:
QueryBuilderVisitorException
-
visitPost
T visitPost(Annotation node, T subNodeResult) throws QueryBuilderVisitorException
Visits aAnnotationnode after recursing into the corresponding subtree.- Parameters:
node- the internal node to be visited.subNodeResult- the of result returned by the sole subnode.- Returns:
- an appropriate return value (usually, the object built using
subNodeResult) if the visit should continue, ornull. - Throws:
QueryBuilderVisitorException
-
visitPre
boolean visitPre(Not node) throws QueryBuilderVisitorException
Visits aNotnode before recursing into the corresponding subtree.- Parameters:
node- the node to be visited.- Returns:
- true if the visit should continue.
- Throws:
QueryBuilderVisitorException
-
visitPost
T visitPost(Not node, T subNodeResult) throws QueryBuilderVisitorException
Visits aNotnode after recursing into the corresponding subtree.- Parameters:
node- the internal node to be visited.subNodeResult- the of result returned by the sole subnode.- Returns:
- an appropriate return value (usually, the object built using
subNodeResult) if the visit should continue, ornull. - Throws:
QueryBuilderVisitorException
-
visitPre
boolean visitPre(Or node) throws QueryBuilderVisitorException
Visits anOrnode before recursing into the corresponding subtree.- Parameters:
node- the node to be visited.- Returns:
- true if the visit should continue.
- Throws:
QueryBuilderVisitorException
-
visitPost
T visitPost(Or node, T[] subNodeResult) throws QueryBuilderVisitorException
Visits anOrnode after recursing into the corresponding subtree.- Parameters:
node- the internal node to be visited.- Returns:
- an appropriate return value (usually, the object built using the elements in
subNodeResult) if the visit should continue, ornull. - Throws:
QueryBuilderVisitorException
-
visitPre
boolean visitPre(OrderedAnd node) throws QueryBuilderVisitorException
Visits anOrderedAndnode before recursing into the corresponding subtree.- Parameters:
node- the node to be visited.- Returns:
- true if the visit should continue.
- Throws:
QueryBuilderVisitorException
-
visitPost
T visitPost(OrderedAnd node, T[] subNodeResult) throws QueryBuilderVisitorException
Visits anOrderedAndnode after recursing into the corresponding subtree.- Parameters:
node- the internal node to be visited.subNodeResult- the array of results returned by subnodes.- Returns:
- an appropriate return value (usually, the object built using the elements in
subNodeResult) if the visit should continue, ornull. - Throws:
QueryBuilderVisitorException
-
visitPre
boolean visitPre(Align node) throws QueryBuilderVisitorException
Visits anAlignnode before recursing into the corresponding subtree.- Parameters:
node- the node to be visited.- Returns:
- true if the visit should continue.
- Throws:
QueryBuilderVisitorException
-
visitPost
T visitPost(Align node, T[] subNodeResult) throws QueryBuilderVisitorException
Visits anAlignnode after recursing into the corresponding subtree.- Parameters:
node- the internal node to be visited.subNodeResult- the array of results returned by subnodes.- Returns:
- an appropriate return value (usually, the object built using the elements in
subNodeResult) if the visit should continue, ornull. - Throws:
QueryBuilderVisitorException
-
visitPre
boolean visitPre(Difference node) throws QueryBuilderVisitorException
Visits aDifferencenode before recursing into the corresponding subtree.- Parameters:
node- the node to be visited.- Returns:
- true if the visit should continue.
- Throws:
QueryBuilderVisitorException
-
visitPost
T visitPost(Difference node, T[] subNodeResult) throws QueryBuilderVisitorException
Visits aDifferencenode after recursing into the corresponding subtree.- Parameters:
node- the internal node to be visited.subNodeResult- the array of results returned by subnodes.- Returns:
- an appropriate return value (usually, the object built using the elements in
subNodeResult) if the visit should continue, ornull. - Throws:
QueryBuilderVisitorException
-
visitPre
boolean visitPre(Inclusion node) throws QueryBuilderVisitorException
Visits anInclusionnode before recursing into the corresponding subtree.- Parameters:
node- the node to be visited.- Returns:
- true if the visit should continue.
- Throws:
QueryBuilderVisitorException
-
visitPost
T visitPost(Inclusion node, T[] subNodeResult) throws QueryBuilderVisitorException
Visits anInclusionnode after recursing into the corresponding subtree.- Parameters:
node- the internal node to be visited.subNodeResult- the array of results returned by subnodes.- Returns:
- an appropriate return value (usually, the object built using the elements in
subNodeResult) if the visit should continue, ornull. - Throws:
QueryBuilderVisitorException
-
visitPre
boolean visitPre(Containment node) throws QueryBuilderVisitorException
Visits anContainmentnode before recursing into the corresponding subtree.- Parameters:
node- the node to be visited.- Returns:
- true if the visit should continue.
- Throws:
QueryBuilderVisitorException
-
visitPost
T visitPost(Containment node, T[] subNodeResult) throws QueryBuilderVisitorException
Visits anContainmentnode after recursing into the corresponding subtree.- Parameters:
node- the internal node to be visited.subNodeResult- the array of results returned by subnodes.- Returns:
- an appropriate return value (usually, the object built using the elements in
subNodeResult) if the visit should continue, ornull. - Throws:
QueryBuilderVisitorException
-
visitPre
boolean visitPre(MultiTerm node) throws QueryBuilderVisitorException
Visits aMultiTermnode before recursing into the corresponding subtree.- Parameters:
node- the node to be visited.- Returns:
- true if the visit should continue.
- Throws:
QueryBuilderVisitorException
-
visitPost
T visitPost(MultiTerm node, T[] subNodeResult) throws QueryBuilderVisitorException
Visits aMultiTermnode after recursing into the corresponding subtree.- Parameters:
node- the internal node to be visited.subNodeResult- the of result returned by the sole subnode.- Returns:
- an appropriate return value (usually, the object built using
subNodeResult) if the visit should continue, ornull. - Throws:
QueryBuilderVisitorException
-
visitPre
boolean visitPre(Select node) throws QueryBuilderVisitorException
Visits aSelectnode before recursing into the corresponding subtree.- Parameters:
node- the node to be visited.- Returns:
- true if the visit should continue.
- Throws:
QueryBuilderVisitorException
-
visitPost
T visitPost(Select node, T subNodeResult) throws QueryBuilderVisitorException
Visits aSelectnode after recursing into the corresponding subtree.- Parameters:
node- the internal node to be visited.subNodeResult- the of result returned by the sole subnode.- Returns:
- an appropriate return value (usually, the object built using
subNodeResult) if the visit should continue, ornull. - Throws:
QueryBuilderVisitorException
-
visitPre
boolean visitPre(Remap node) throws QueryBuilderVisitorException
Visits aRemapnode before recursing into the corresponding subtree.- Parameters:
node- the node to be visited.- Returns:
- true if the visit should continue.
- Throws:
QueryBuilderVisitorException
-
visitPost
T visitPost(Remap node, T subNodeResult) throws QueryBuilderVisitorException
Visits aRemapnode after recursing into the corresponding subtree.- Parameters:
node- the internal node to be visited.subNodeResult- the of result returned by the sole subnode.- Returns:
- an appropriate return value (usually, the object built using
subNodeResult) if the visit should continue, ornull. - Throws:
QueryBuilderVisitorException
-
visitPre
boolean visitPre(Weight node) throws QueryBuilderVisitorException
Visits aWeightnode before recursing into the corresponding subtree.- Parameters:
node- the node to be visited.- Returns:
- true if the visit should continue.
- Throws:
QueryBuilderVisitorException
-
visitPost
T visitPost(Weight node, T subNodeResult) throws QueryBuilderVisitorException
Visits aWeightnode after recursing into the corresponding subtree.- Parameters:
node- the internal node to be visited.subNodeResult- the of result returned by the sole subnode.- Returns:
- an appropriate return value (usually, the object built using
subNodeResult) if the visit should continue, ornull. - Throws:
QueryBuilderVisitorException
-
visit
T visit(Term node) throws QueryBuilderVisitorException
Visits aTerm.- Parameters:
node- the leaf to be visited.- Returns:
- true if the visit should continue.
- Throws:
QueryBuilderVisitorException
-
visit
T visit(Prefix node) throws QueryBuilderVisitorException
Visits aPrefix.- Parameters:
node- the leaf to be visited.- Returns:
- an appropriate return value (usually, the object built using the elements in
subNodeResult) if the visit should continue, ornull. - Throws:
QueryBuilderVisitorException
-
visit
T visit(Range node) throws QueryBuilderVisitorException
Visits aRange.- Parameters:
node- the leaf to be visited.- Returns:
- true if the visit should continue.
- Throws:
QueryBuilderVisitorException
-
visit
T visit(True node) throws QueryBuilderVisitorException
VisitsTrue.- Parameters:
node- the leaf to be visited.- Returns:
- true if the visit should continue.
- Throws:
QueryBuilderVisitorException
-
visit
T visit(False node) throws QueryBuilderVisitorException
VisitsFalse.- Parameters:
node- the leaf to be visited.- Returns:
- true if the visit should continue.
- Throws:
QueryBuilderVisitorException
-
copy
QueryBuilderVisitor<T> copy()
- Specified by:
copyin interfaceFlyweightPrototype<T>
-
-