it.unimi.di.mg4j.query.nodes
Class CheckForSelectQueryVisitor

java.lang.Object
  extended by it.unimi.di.mg4j.query.nodes.CheckForSelectQueryVisitor
All Implemented Interfaces:
QueryBuilderVisitor<Set<String>>, FlyweightPrototype<QueryBuilderVisitor<Set<String>>>

public class CheckForSelectQueryVisitor
extends Object
implements QueryBuilderVisitor<Set<String>>

A QueryBuilderVisitor that returns Boolean.FALSE only if the visited query contains a Select node that does not lie in the aligner of an Align query (as in that case the index is not part of the answer).

Author:
Sebastiano Vigna

Field Summary
 String errorMessage
           
 
Constructor Summary
CheckForSelectQueryVisitor(String defaultIndex)
           
 
Method Summary
 QueryBuilderVisitor<Set<String>> copy()
           
 Set<String>[] newArray(int len)
          Builds an array of given length of type T.
 QueryBuilderVisitor<Set<String>> prepare()
          Prepares the internal state of this visitor for a(nother) visit.
 Set<String> visit(False node)
          Visits False.
 Set<String> visit(Prefix node)
          Visits a Prefix.
 Set<String> visit(Range node)
          Visits a Range.
 Set<String> visit(Term node)
          Visits a Term.
 Set<String> visit(True node)
          Visits True.
 Set<String> visitPost(Align node, Set<String>[] v)
          Visits an Align node after recursing into the corresponding subtree.
 Set<String> visitPost(And node, Set<String>[] v)
          Visits an And node after recursing into the corresponding subtree.
 Set<String> visitPost(Consecutive node, Set<String>[] v)
          Visits a Consecutive node after recursing into the corresponding subtree.
 Set<String> visitPost(Difference node, Set<String>[] v)
          Visits an Difference node after recursing into the corresponding subtree.
 Set<String> visitPost(LowPass node, Set<String> v)
          Visits a LowPass node after recursing into the corresponding subtree.
 Set<String> visitPost(MultiTerm node, Set<String>[] v)
          Visits a MultiTerm node after recursing into the corresponding subtree.
 Set<String> visitPost(Not node, Set<String> v)
          Visits a Not node after recursing into the corresponding subtree.
 Set<String> visitPost(OrderedAnd node, Set<String>[] v)
          Visits an OrderedAnd node after recursing into the corresponding subtree.
 Set<String> visitPost(Or node, Set<String>[] v)
          Visits an Or node after recursing into the corresponding subtree.
 Set<String> visitPost(Remap node, Set<String> v)
          Visits a Remap node after recursing into the corresponding subtree.
 Set<String> visitPost(Select node, Set<String> v)
          Visits a Select node after recursing into the corresponding subtree.
 Set<String> visitPost(Weight node, Set<String> v)
          Visits a Weight node after recursing into the corresponding subtree.
 boolean visitPre(Align node)
          Visits an Align node before recursing into the corresponding subtree.
 boolean visitPre(And node)
          Visits an And node before recursing into the corresponding subtree.
 boolean visitPre(Consecutive node)
          Visits a Consecutive node before recursing into the corresponding subtree.
 boolean visitPre(Difference node)
          Visits an Difference node before recursing into the corresponding subtree.
 boolean visitPre(LowPass node)
          Visits a LowPass node before recursing into the corresponding subtree.
 boolean visitPre(MultiTerm node)
          Visits a MultiTerm node before recursing into the corresponding subtree.
 boolean visitPre(Not node)
          Visits a Not node before recursing into the corresponding subtree.
 boolean visitPre(Or node)
          Visits an Or node before recursing into the corresponding subtree.
 boolean visitPre(OrderedAnd node)
          Visits an OrderedAnd node before recursing into the corresponding subtree.
 boolean visitPre(Remap node)
          Visits a Remap node before recursing into the corresponding subtree.
 boolean visitPre(Select node)
          Visits a Select node before recursing into the corresponding subtree.
 boolean visitPre(Weight node)
          Visits a Weight node before recursing into the corresponding subtree.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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 interface QueryBuilderVisitor<Set<String>>
Returns:
this visitor.

newArray

public Set<String>[] newArray(int len)
Description copied from interface: QueryBuilderVisitor
Builds an array of given length of type T.

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 type T. This method must provide an array of given length that is an acceptable input for all visitPost() 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 in Array.

Specified by:
newArray in interface QueryBuilderVisitor<Set<String>>
Parameters:
len - the required array length.
Returns:
an array of type T of length len.

copy

public QueryBuilderVisitor<Set<String>> copy()
Specified by:
copy in interface QueryBuilderVisitor<Set<String>>
Specified by:
copy in interface FlyweightPrototype<QueryBuilderVisitor<Set<String>>>

visitPre

public boolean visitPre(And node)
                 throws QueryBuilderVisitorException
Description copied from interface: QueryBuilderVisitor
Visits an And node before recursing into the corresponding subtree.

Specified by:
visitPre in interface QueryBuilderVisitor<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 a Consecutive node before recursing into the corresponding subtree.

Specified by:
visitPre in interface QueryBuilderVisitor<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 a LowPass node before recursing into the corresponding subtree.

Specified by:
visitPre in interface QueryBuilderVisitor<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 a Not node before recursing into the corresponding subtree.

Specified by:
visitPre in interface QueryBuilderVisitor<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 an Or node before recursing into the corresponding subtree.

Specified by:
visitPre in interface QueryBuilderVisitor<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 an OrderedAnd node before recursing into the corresponding subtree.

Specified by:
visitPre in interface QueryBuilderVisitor<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 an Align node before recursing into the corresponding subtree.

Specified by:
visitPre in interface QueryBuilderVisitor<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 a MultiTerm node before recursing into the corresponding subtree.

Specified by:
visitPre in interface QueryBuilderVisitor<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 a Select node before recursing into the corresponding subtree.

Specified by:
visitPre in interface QueryBuilderVisitor<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 a Remap node before recursing into the corresponding subtree.

Specified by:
visitPre in interface QueryBuilderVisitor<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 a Weight node before recursing into the corresponding subtree.

Specified by:
visitPre in interface QueryBuilderVisitor<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 an Difference node before recursing into the corresponding subtree.

Specified by:
visitPre in interface QueryBuilderVisitor<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 an And node after recursing into the corresponding subtree.

Specified by:
visitPost in interface QueryBuilderVisitor<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, or null.
Throws:
QueryBuilderVisitorException

visitPost

public Set<String> visitPost(Consecutive node,
                             Set<String>[] v)
                      throws QueryBuilderVisitorException
Description copied from interface: QueryBuilderVisitor
Visits a Consecutive node after recursing into the corresponding subtree.

Specified by:
visitPost in interface QueryBuilderVisitor<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, or null.
Throws:
QueryBuilderVisitorException

visitPost

public Set<String> visitPost(LowPass node,
                             Set<String> v)
                      throws QueryBuilderVisitorException
Description copied from interface: QueryBuilderVisitor
Visits a LowPass node after recursing into the corresponding subtree.

Specified by:
visitPost in interface QueryBuilderVisitor<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, or null.
Throws:
QueryBuilderVisitorException

visitPost

public Set<String> visitPost(Not node,
                             Set<String> v)
                      throws QueryBuilderVisitorException
Description copied from interface: QueryBuilderVisitor
Visits a Not node after recursing into the corresponding subtree.

Specified by:
visitPost in interface QueryBuilderVisitor<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, or null.
Throws:
QueryBuilderVisitorException

visitPost

public Set<String> visitPost(Or node,
                             Set<String>[] v)
                      throws QueryBuilderVisitorException
Description copied from interface: QueryBuilderVisitor
Visits an Or node after recursing into the corresponding subtree.

Specified by:
visitPost in interface QueryBuilderVisitor<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, or null.
Throws:
QueryBuilderVisitorException

visitPost

public Set<String> visitPost(OrderedAnd node,
                             Set<String>[] v)
                      throws QueryBuilderVisitorException
Description copied from interface: QueryBuilderVisitor
Visits an OrderedAnd node after recursing into the corresponding subtree.

Specified by:
visitPost in interface QueryBuilderVisitor<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, or null.
Throws:
QueryBuilderVisitorException

visitPost

public Set<String> visitPost(Align node,
                             Set<String>[] v)
                      throws QueryBuilderVisitorException
Description copied from interface: QueryBuilderVisitor
Visits an Align node after recursing into the corresponding subtree.

Specified by:
visitPost in interface QueryBuilderVisitor<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, or null.
Throws:
QueryBuilderVisitorException

visitPost

public Set<String> visitPost(MultiTerm node,
                             Set<String>[] v)
                      throws QueryBuilderVisitorException
Description copied from interface: QueryBuilderVisitor
Visits a MultiTerm node after recursing into the corresponding subtree.

Specified by:
visitPost in interface QueryBuilderVisitor<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, or null.
Throws:
QueryBuilderVisitorException

visitPost

public Set<String> visitPost(Select node,
                             Set<String> v)
Description copied from interface: QueryBuilderVisitor
Visits a Select node after recursing into the corresponding subtree.

Specified by:
visitPost in interface QueryBuilderVisitor<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, or null.

visitPost

public Set<String> visitPost(Remap node,
                             Set<String> v)
                      throws QueryBuilderVisitorException
Description copied from interface: QueryBuilderVisitor
Visits a Remap node after recursing into the corresponding subtree.

Specified by:
visitPost in interface QueryBuilderVisitor<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, or null.
Throws:
QueryBuilderVisitorException

visitPost

public Set<String> visitPost(Weight node,
                             Set<String> v)
                      throws QueryBuilderVisitorException
Description copied from interface: QueryBuilderVisitor
Visits a Weight node after recursing into the corresponding subtree.

Specified by:
visitPost in interface QueryBuilderVisitor<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, or null.
Throws:
QueryBuilderVisitorException

visitPost

public Set<String> visitPost(Difference node,
                             Set<String>[] v)
                      throws QueryBuilderVisitorException
Description copied from interface: QueryBuilderVisitor
Visits an Difference node after recursing into the corresponding subtree.

Specified by:
visitPost in interface QueryBuilderVisitor<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, or null.
Throws:
QueryBuilderVisitorException

visit

public Set<String> visit(Term node)
                  throws QueryBuilderVisitorException
Description copied from interface: QueryBuilderVisitor
Visits a Term.

Specified by:
visit in interface QueryBuilderVisitor<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 a Prefix.

Specified by:
visit in interface QueryBuilderVisitor<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, or null.
Throws:
QueryBuilderVisitorException

visit

public Set<String> visit(Range node)
                  throws QueryBuilderVisitorException
Description copied from interface: QueryBuilderVisitor
Visits a Range.

Specified by:
visit in interface QueryBuilderVisitor<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
Visits True.

Specified by:
visit in interface QueryBuilderVisitor<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
Visits False.

Specified by:
visit in interface QueryBuilderVisitor<Set<String>>
Parameters:
node - the leaf to be visited.
Returns:
true if the visit should continue.
Throws:
QueryBuilderVisitorException