Package it.unimi.di.big.mg4j.query.nodes
Class CheckForSelectQueryVisitor
- java.lang.Object
-
- it.unimi.di.big.mg4j.query.nodes.CheckForSelectQueryVisitor
-
- All Implemented Interfaces:
QueryBuilderVisitor<Set<String>>
,FlyweightPrototype<QueryBuilderVisitor<Set<String>>>
public class CheckForSelectQueryVisitor extends Object implements QueryBuilderVisitor<Set<String>>
AQueryBuilderVisitor
that returnsBoolean.FALSE
only if the visited query contains aSelect
node that does not lie in the aligner of anAlign
query (as in that case the index is not part of the answer).- Author:
- Sebastiano Vigna
-
-
Field Summary
Fields Modifier and Type Field Description String
errorMessage
-
Constructor Summary
Constructors Constructor Description CheckForSelectQueryVisitor(String defaultIndex)
-
Method Summary
Modifier and Type Method Description QueryBuilderVisitor<Set<String>>
copy()
Set<String>[]
newArray(int len)
Builds an array of given length of typeT
.QueryBuilderVisitor<Set<String>>
prepare()
Prepares the internal state of this visitor for a(nother) visit.Set<String>
visit(False node)
VisitsFalse
.Set<String>
visit(Prefix node)
Visits aPrefix
.Set<String>
visit(Range node)
Visits aRange
.Set<String>
visit(Term node)
Visits aTerm
.Set<String>
visit(True node)
VisitsTrue
.Set<String>
visitPost(Align node, Set<String>[] v)
Visits anAlign
node after recursing into the corresponding subtree.Set<String>
visitPost(And node, Set<String>[] v)
Visits anAnd
node after recursing into the corresponding subtree.Set<String>
visitPost(Annotation node, Set<String> v)
Visits aAnnotation
node after recursing into the corresponding subtree.Set<String>
visitPost(Consecutive node, Set<String>[] v)
Visits aConsecutive
node after recursing into the corresponding subtree.Set<String>
visitPost(Containment node, Set<String>[] v)
Visits anContainment
node after recursing into the corresponding subtree.Set<String>
visitPost(Difference node, Set<String>[] v)
Visits aDifference
node after recursing into the corresponding subtree.Set<String>
visitPost(Inclusion node, Set<String>[] v)
Visits anInclusion
node after recursing into the corresponding subtree.Set<String>
visitPost(LowPass node, Set<String> v)
Visits aLowPass
node after recursing into the corresponding subtree.Set<String>
visitPost(MultiTerm node, Set<String>[] v)
Visits aMultiTerm
node after recursing into the corresponding subtree.Set<String>
visitPost(Not node, Set<String> v)
Visits aNot
node after recursing into the corresponding subtree.Set<String>
visitPost(OrderedAnd node, Set<String>[] v)
Visits anOrderedAnd
node after recursing into the corresponding subtree.Set<String>
visitPost(Or node, Set<String>[] v)
Visits anOr
node after recursing into the corresponding subtree.Set<String>
visitPost(Remap node, Set<String> v)
Visits aRemap
node after recursing into the corresponding subtree.Set<String>
visitPost(Select node, Set<String> v)
Visits aSelect
node after recursing into the corresponding subtree.Set<String>
visitPost(Weight node, Set<String> v)
Visits aWeight
node after recursing into the corresponding subtree.boolean
visitPre(Align node)
Visits anAlign
node before recursing into the corresponding subtree.boolean
visitPre(And node)
Visits anAnd
node before recursing into the corresponding subtree.boolean
visitPre(Annotation node)
Visits aAnnotation
node before recursing into the corresponding subtree.boolean
visitPre(Consecutive node)
Visits aConsecutive
node before recursing into the corresponding subtree.boolean
visitPre(Containment node)
Visits anContainment
node before recursing into the corresponding subtree.boolean
visitPre(Difference node)
Visits aDifference
node before recursing into the corresponding subtree.boolean
visitPre(Inclusion node)
Visits anInclusion
node before recursing into the corresponding subtree.boolean
visitPre(LowPass node)
Visits aLowPass
node before recursing into the corresponding subtree.boolean
visitPre(MultiTerm node)
Visits aMultiTerm
node before recursing into the corresponding subtree.boolean
visitPre(Not node)
Visits aNot
node before recursing into the corresponding subtree.boolean
visitPre(Or node)
Visits anOr
node before recursing into the corresponding subtree.boolean
visitPre(OrderedAnd node)
Visits anOrderedAnd
node before recursing into the corresponding subtree.boolean
visitPre(Remap node)
Visits aRemap
node before recursing into the corresponding subtree.boolean
visitPre(Select node)
Visits aSelect
node before recursing into the corresponding subtree.boolean
visitPre(Weight node)
Visits aWeight
node before recursing into the corresponding subtree.
-
-
-
Field Detail
-
errorMessage
public String errorMessage
-
-
Constructor Detail
-
CheckForSelectQueryVisitor
public CheckForSelectQueryVisitor(String defaultIndex)
-
-
Method Detail
-
prepare
public QueryBuilderVisitor<Set<String>> prepare()
Description copied from interface:QueryBuilderVisitor
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.
- Specified by:
prepare
in interfaceQueryBuilderVisitor<Set<String>>
- Returns:
- this visitor.
-
newArray
public Set<String>[] newArray(int len)
Description copied from interface:QueryBuilderVisitor
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
.- Specified by:
newArray
in interfaceQueryBuilderVisitor<Set<String>>
- Parameters:
len
- the required array length.- Returns:
- an array of type
T
of lengthlen
.
-
copy
public QueryBuilderVisitor<Set<String>> copy()
- Specified by:
copy
in interfaceFlyweightPrototype<QueryBuilderVisitor<Set<String>>>
- Specified by:
copy
in interfaceQueryBuilderVisitor<Set<String>>
-
visitPre
public boolean visitPre(And node) throws QueryBuilderVisitorException
Description copied from interface:QueryBuilderVisitor
Visits anAnd
node before recursing into the corresponding subtree.- Specified by:
visitPre
in interfaceQueryBuilderVisitor<Set<String>>
- Parameters:
node
- the node to be visited.- Returns:
- true if the visit should continue.
- Throws:
QueryBuilderVisitorException
-
visitPre
public boolean visitPre(Consecutive node) throws QueryBuilderVisitorException
Description copied from interface:QueryBuilderVisitor
Visits aConsecutive
node before recursing into the corresponding subtree.- Specified by:
visitPre
in interfaceQueryBuilderVisitor<Set<String>>
- Parameters:
node
- the node to be visited.- Returns:
- true if the visit should continue.
- Throws:
QueryBuilderVisitorException
-
visitPre
public boolean visitPre(LowPass node) throws QueryBuilderVisitorException
Description copied from interface:QueryBuilderVisitor
Visits aLowPass
node before recursing into the corresponding subtree.- Specified by:
visitPre
in interfaceQueryBuilderVisitor<Set<String>>
- Parameters:
node
- the node to be visited.- Returns:
- true if the visit should continue.
- Throws:
QueryBuilderVisitorException
-
visitPre
public boolean visitPre(Annotation node) throws QueryBuilderVisitorException
Description copied from interface:QueryBuilderVisitor
Visits aAnnotation
node before recursing into the corresponding subtree.- Specified by:
visitPre
in interfaceQueryBuilderVisitor<Set<String>>
- Parameters:
node
- the node to be visited.- Returns:
- true if the visit should continue.
- Throws:
QueryBuilderVisitorException
-
visitPre
public boolean visitPre(Not node) throws QueryBuilderVisitorException
Description copied from interface:QueryBuilderVisitor
Visits aNot
node before recursing into the corresponding subtree.- Specified by:
visitPre
in interfaceQueryBuilderVisitor<Set<String>>
- Parameters:
node
- the node to be visited.- Returns:
- true if the visit should continue.
- Throws:
QueryBuilderVisitorException
-
visitPre
public boolean visitPre(Or node) throws QueryBuilderVisitorException
Description copied from interface:QueryBuilderVisitor
Visits anOr
node before recursing into the corresponding subtree.- Specified by:
visitPre
in interfaceQueryBuilderVisitor<Set<String>>
- Parameters:
node
- the node to be visited.- Returns:
- true if the visit should continue.
- Throws:
QueryBuilderVisitorException
-
visitPre
public boolean visitPre(OrderedAnd node) throws QueryBuilderVisitorException
Description copied from interface:QueryBuilderVisitor
Visits anOrderedAnd
node before recursing into the corresponding subtree.- Specified by:
visitPre
in interfaceQueryBuilderVisitor<Set<String>>
- Parameters:
node
- the node to be visited.- Returns:
- true if the visit should continue.
- Throws:
QueryBuilderVisitorException
-
visitPre
public boolean visitPre(Align node) throws QueryBuilderVisitorException
Description copied from interface:QueryBuilderVisitor
Visits anAlign
node before recursing into the corresponding subtree.- Specified by:
visitPre
in interfaceQueryBuilderVisitor<Set<String>>
- Parameters:
node
- the node to be visited.- Returns:
- true if the visit should continue.
- Throws:
QueryBuilderVisitorException
-
visitPre
public boolean visitPre(MultiTerm node) throws QueryBuilderVisitorException
Description copied from interface:QueryBuilderVisitor
Visits aMultiTerm
node before recursing into the corresponding subtree.- Specified by:
visitPre
in interfaceQueryBuilderVisitor<Set<String>>
- Parameters:
node
- the node to be visited.- Returns:
- true if the visit should continue.
- Throws:
QueryBuilderVisitorException
-
visitPre
public boolean visitPre(Select node) throws QueryBuilderVisitorException
Description copied from interface:QueryBuilderVisitor
Visits aSelect
node before recursing into the corresponding subtree.- Specified by:
visitPre
in interfaceQueryBuilderVisitor<Set<String>>
- Parameters:
node
- the node to be visited.- Returns:
- true if the visit should continue.
- Throws:
QueryBuilderVisitorException
-
visitPre
public boolean visitPre(Remap node) throws QueryBuilderVisitorException
Description copied from interface:QueryBuilderVisitor
Visits aRemap
node before recursing into the corresponding subtree.- Specified by:
visitPre
in interfaceQueryBuilderVisitor<Set<String>>
- Parameters:
node
- the node to be visited.- Returns:
- true if the visit should continue.
- Throws:
QueryBuilderVisitorException
-
visitPre
public boolean visitPre(Weight node) throws QueryBuilderVisitorException
Description copied from interface:QueryBuilderVisitor
Visits aWeight
node before recursing into the corresponding subtree.- Specified by:
visitPre
in interfaceQueryBuilderVisitor<Set<String>>
- Parameters:
node
- the node to be visited.- Returns:
- true if the visit should continue.
- Throws:
QueryBuilderVisitorException
-
visitPre
public boolean visitPre(Difference node) throws QueryBuilderVisitorException
Description copied from interface:QueryBuilderVisitor
Visits aDifference
node before recursing into the corresponding subtree.- Specified by:
visitPre
in interfaceQueryBuilderVisitor<Set<String>>
- Parameters:
node
- the node to be visited.- Returns:
- true if the visit should continue.
- Throws:
QueryBuilderVisitorException
-
visitPre
public boolean visitPre(Inclusion node) throws QueryBuilderVisitorException
Description copied from interface:QueryBuilderVisitor
Visits anInclusion
node before recursing into the corresponding subtree.- Specified by:
visitPre
in interfaceQueryBuilderVisitor<Set<String>>
- Parameters:
node
- the node to be visited.- Returns:
- true if the visit should continue.
- Throws:
QueryBuilderVisitorException
-
visitPre
public boolean visitPre(Containment node) throws QueryBuilderVisitorException
Description copied from interface:QueryBuilderVisitor
Visits anContainment
node before recursing into the corresponding subtree.- Specified by:
visitPre
in interfaceQueryBuilderVisitor<Set<String>>
- Parameters:
node
- the node to be visited.- Returns:
- true if the visit should continue.
- Throws:
QueryBuilderVisitorException
-
visitPost
public Set<String> visitPost(And node, Set<String>[] v) throws QueryBuilderVisitorException
Description copied from interface:QueryBuilderVisitor
Visits anAnd
node after recursing into the corresponding subtree.- Specified by:
visitPost
in interfaceQueryBuilderVisitor<Set<String>>
- Parameters:
node
- the internal node to be visited.v
- 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
-
visitPost
public Set<String> visitPost(Consecutive node, Set<String>[] v) throws QueryBuilderVisitorException
Description copied from interface:QueryBuilderVisitor
Visits aConsecutive
node after recursing into the corresponding subtree.- Specified by:
visitPost
in interfaceQueryBuilderVisitor<Set<String>>
- Parameters:
node
- the internal node to be visited.v
- 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
-
visitPost
public Set<String> visitPost(LowPass node, Set<String> v) throws QueryBuilderVisitorException
Description copied from interface:QueryBuilderVisitor
Visits aLowPass
node after recursing into the corresponding subtree.- Specified by:
visitPost
in interfaceQueryBuilderVisitor<Set<String>>
- Parameters:
node
- the internal node to be visited.v
- 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
-
visitPost
public Set<String> visitPost(Annotation node, Set<String> v) throws QueryBuilderVisitorException
Description copied from interface:QueryBuilderVisitor
Visits aAnnotation
node after recursing into the corresponding subtree.- Specified by:
visitPost
in interfaceQueryBuilderVisitor<Set<String>>
- Parameters:
node
- the internal node to be visited.v
- 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
-
visitPost
public Set<String> visitPost(Not node, Set<String> v) throws QueryBuilderVisitorException
Description copied from interface:QueryBuilderVisitor
Visits aNot
node after recursing into the corresponding subtree.- Specified by:
visitPost
in interfaceQueryBuilderVisitor<Set<String>>
- Parameters:
node
- the internal node to be visited.v
- 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
-
visitPost
public Set<String> visitPost(Or node, Set<String>[] v) throws QueryBuilderVisitorException
Description copied from interface:QueryBuilderVisitor
Visits anOr
node after recursing into the corresponding subtree.- Specified by:
visitPost
in interfaceQueryBuilderVisitor<Set<String>>
- 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
-
visitPost
public Set<String> visitPost(OrderedAnd node, Set<String>[] v) throws QueryBuilderVisitorException
Description copied from interface:QueryBuilderVisitor
Visits anOrderedAnd
node after recursing into the corresponding subtree.- Specified by:
visitPost
in interfaceQueryBuilderVisitor<Set<String>>
- Parameters:
node
- the internal node to be visited.v
- 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
-
visitPost
public Set<String> visitPost(Align node, Set<String>[] v) throws QueryBuilderVisitorException
Description copied from interface:QueryBuilderVisitor
Visits anAlign
node after recursing into the corresponding subtree.- Specified by:
visitPost
in interfaceQueryBuilderVisitor<Set<String>>
- Parameters:
node
- the internal node to be visited.v
- 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
-
visitPost
public Set<String> visitPost(MultiTerm node, Set<String>[] v) throws QueryBuilderVisitorException
Description copied from interface:QueryBuilderVisitor
Visits aMultiTerm
node after recursing into the corresponding subtree.- Specified by:
visitPost
in interfaceQueryBuilderVisitor<Set<String>>
- Parameters:
node
- the internal node to be visited.v
- 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
-
visitPost
public Set<String> visitPost(Select node, Set<String> v)
Description copied from interface:QueryBuilderVisitor
Visits aSelect
node after recursing into the corresponding subtree.- Specified by:
visitPost
in interfaceQueryBuilderVisitor<Set<String>>
- Parameters:
node
- the internal node to be visited.v
- 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
.
-
visitPost
public Set<String> visitPost(Remap node, Set<String> v) throws QueryBuilderVisitorException
Description copied from interface:QueryBuilderVisitor
Visits aRemap
node after recursing into the corresponding subtree.- Specified by:
visitPost
in interfaceQueryBuilderVisitor<Set<String>>
- Parameters:
node
- the internal node to be visited.v
- 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
-
visitPost
public Set<String> visitPost(Weight node, Set<String> v) throws QueryBuilderVisitorException
Description copied from interface:QueryBuilderVisitor
Visits aWeight
node after recursing into the corresponding subtree.- Specified by:
visitPost
in interfaceQueryBuilderVisitor<Set<String>>
- Parameters:
node
- the internal node to be visited.v
- 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
-
visitPost
public Set<String> visitPost(Difference node, Set<String>[] v) throws QueryBuilderVisitorException
Description copied from interface:QueryBuilderVisitor
Visits aDifference
node after recursing into the corresponding subtree.- Specified by:
visitPost
in interfaceQueryBuilderVisitor<Set<String>>
- Parameters:
node
- the internal node to be visited.v
- 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
-
visitPost
public Set<String> visitPost(Inclusion node, Set<String>[] v) throws QueryBuilderVisitorException
Description copied from interface:QueryBuilderVisitor
Visits anInclusion
node after recursing into the corresponding subtree.- Specified by:
visitPost
in interfaceQueryBuilderVisitor<Set<String>>
- Parameters:
node
- the internal node to be visited.v
- 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
-
visitPost
public Set<String> visitPost(Containment node, Set<String>[] v) throws QueryBuilderVisitorException
Description copied from interface:QueryBuilderVisitor
Visits anContainment
node after recursing into the corresponding subtree.- Specified by:
visitPost
in interfaceQueryBuilderVisitor<Set<String>>
- Parameters:
node
- the internal node to be visited.v
- 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
-
visit
public Set<String> visit(Term node) throws QueryBuilderVisitorException
Description copied from interface:QueryBuilderVisitor
Visits aTerm
.- Specified by:
visit
in interfaceQueryBuilderVisitor<Set<String>>
- Parameters:
node
- the leaf to be visited.- Returns:
- true if the visit should continue.
- Throws:
QueryBuilderVisitorException
-
visit
public Set<String> visit(Prefix node) throws QueryBuilderVisitorException
Description copied from interface:QueryBuilderVisitor
Visits aPrefix
.- Specified by:
visit
in interfaceQueryBuilderVisitor<Set<String>>
- 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
public Set<String> visit(Range node) throws QueryBuilderVisitorException
Description copied from interface:QueryBuilderVisitor
Visits aRange
.- Specified by:
visit
in interfaceQueryBuilderVisitor<Set<String>>
- Parameters:
node
- the leaf to be visited.- Returns:
- true if the visit should continue.
- Throws:
QueryBuilderVisitorException
-
visit
public Set<String> visit(True node) throws QueryBuilderVisitorException
Description copied from interface:QueryBuilderVisitor
VisitsTrue
.- Specified by:
visit
in interfaceQueryBuilderVisitor<Set<String>>
- Parameters:
node
- the leaf to be visited.- Returns:
- true if the visit should continue.
- Throws:
QueryBuilderVisitorException
-
visit
public Set<String> visit(False node) throws QueryBuilderVisitorException
Description copied from interface:QueryBuilderVisitor
VisitsFalse
.- Specified by:
visit
in interfaceQueryBuilderVisitor<Set<String>>
- Parameters:
node
- the leaf to be visited.- Returns:
- true if the visit should continue.
- Throws:
QueryBuilderVisitorException
-
-