org.terrier.querying.parser
Class Query

java.lang.Object
  extended by org.terrier.querying.parser.Query
All Implemented Interfaces:
Serializable, Cloneable
Direct Known Subclasses:
FieldQuery, MultiTermQuery, RequirementQuery, SingleTermQuery

public abstract class Query
extends Object
implements Serializable, Cloneable

An abstract class that models a query, that consists of subqueries and query terms. The subqueries can be phrase queries, field queries, required queries, and combinations of those queries.

Author:
Vassilis Plachouras & Craig Macdonald
See Also:
Serialized Form

Nested Class Summary
static interface Query.ForEachQueryNode
          ForEachQueryNode interface
 
Field Summary
protected  Query child
          An encapsulated query.
protected static SingleTermQuery[] tmpSTQ
          An attribute used constructing arrays of the right type.
 
Constructor Summary
Query()
          default constructor
 
Method Summary
 void apply(Query.ForEachQueryNode processor)
          Apply the specified processor to this node.
 boolean applyTermPipeline(TermPipelineAccessor tpa)
          Applies a term pipeline in the query's terms, through the given term pipeline accessor.
 Object clone()
          Deep copy this Query object
protected  void getTerms(List<Query> alist)
          Returns the terms of the query.
abstract  void getTermsOf(Class<? extends Query> c, List<Query> alist, boolean req)
          Returns all the query terms, in subqueries that are instances of a given class
 void obtainAllOf(Class<? extends Query> c, List<Query> a)
          Returns all the queries of the specified class
 boolean obtainControls(Set<String> allowed, Map<String,String> controls)
          Returns the specified control or false if that control does not exist
 void obtainQueryTerms(MatchingQueryTerms terms)
          Stores the terms of the query in an structure used for matching documents to the query.
 void obtainQueryTerms(MatchingQueryTerms terms, boolean required)
          Stores the terms of the query in an structure used for matching documents to the query.
abstract  String parseTree()
          Returns the parse tree for the query as a string
 void setChild(Query q)
          Sets the subquery object of this query.
abstract  String toString()
          Force anything concrete to provide toString method
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

child

protected Query child
An encapsulated query.


tmpSTQ

protected static final SingleTermQuery[] tmpSTQ
An attribute used constructing arrays of the right type.

Constructor Detail

Query

public Query()
default constructor

Method Detail

clone

public Object clone()
Deep copy this Query object

Overrides:
clone in class Object

toString

public abstract String toString()
Force anything concrete to provide toString method

Overrides:
toString in class Object

parseTree

public abstract String parseTree()
Returns the parse tree for the query as a string


getTermsOf

public abstract void getTermsOf(Class<? extends Query> c,
                                List<Query> alist,
                                boolean req)
Returns all the query terms, in subqueries that are instances of a given class

Parameters:
c - Class a class of queries.
alist - ArrayList the list of query terms.
req - boolean indicates whether it the subqueries are required or not.

setChild

public void setChild(Query q)
Sets the subquery object of this query.

Parameters:
q - Query the subquery object.

applyTermPipeline

public boolean applyTermPipeline(TermPipelineAccessor tpa)
Applies a term pipeline in the query's terms, through the given term pipeline accessor.

Parameters:
tpa - TermPipelineAccessor the object that provides access to the term pipeline.
Returns:
boolean true if the query is not empty, otherwise returns false.

obtainControls

public boolean obtainControls(Set<String> allowed,
                              Map<String,String> controls)
Returns the specified control or false if that control does not exist


obtainQueryTerms

public void obtainQueryTerms(MatchingQueryTerms terms)
Stores the terms of the query in an structure used for matching documents to the query.

Parameters:
terms - MatchingQueryTerms the structure that is used for modelling a query for matching.

obtainQueryTerms

public void obtainQueryTerms(MatchingQueryTerms terms,
                             boolean required)
Stores the terms of the query in an structure used for matching documents to the query.

Parameters:
terms - MatchingQueryTerms the structure that is used for modelling a query for matching.
required - boolean specifies whether the subqueries are required or not.

getTerms

protected void getTerms(List<Query> alist)
Returns the terms of the query.

Parameters:
alist - A structure that contains the query terms.

apply

public void apply(Query.ForEachQueryNode processor)
Apply the specified processor to this node. If the processor allows, move to any children nodes.

Parameters:
processor -

obtainAllOf

public void obtainAllOf(Class<? extends Query> c,
                        List<Query> a)
Returns all the queries of the specified class



Terrier 3.6. Copyright © 2004-2011 University of Glasgow