Terrier IR Platform
1.1.1

uk.ac.gla.terrier.querying.parser
Class MultiTermQuery

java.lang.Object
  extended by uk.ac.gla.terrier.querying.parser.Query
      extended by uk.ac.gla.terrier.querying.parser.MultiTermQuery
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
PhraseQuery

public class MultiTermQuery
extends Query

Represents a query consisting of more than one terms or other sub-queries, qualified with field, requirement or phrase operators.

Version:
$Revision: 1.20 $
Author:
Vassilis Plachouras, Craig Macdonald
See Also:
Serialized Form

Constructor Summary
MultiTermQuery()
          A default constructor.
 
Method Summary
 void add(Query query)
          Adds a subquery to this query.
 void add(java.lang.String term)
           
 boolean applyTermPipeline(TermPipelineAccessor tpa)
          Applies the given term pipeline to the query terms and sub-queries that construct this query.
 java.lang.Object clone()
          Deep copy this Query object
 int getNumberOfTerms()
          Returns the number of terms, or subqueries.
 void getTermsOf(java.lang.Class c, java.util.ArrayList alist, boolean req)
          Returns all the query terms, in subqueries that are instances of a given class
 void obtainAllOf(java.lang.Class c, java.util.ArrayList a)
           
 boolean obtainControls(java.util.HashSet allowed, java.util.Hashtable controls)
          Checks all child objects to see if they are FieldQuery objects, they are each called to see if the are controls.
 void obtainQueryTerms(MatchingQueryTerms terms)
          Prepares the query for matching by transforming the query objects to a set of query terms.
 void obtainQueryTerms(MatchingQueryTerms terms, boolean required)
          Prepares the query for matching by transforming the query objects to a set of query terms.
 java.lang.String toString()
          Returns a string representation of the query.
 
Methods inherited from class uk.ac.gla.terrier.querying.parser.Query
setChild
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MultiTermQuery

public MultiTermQuery()
A default constructor.

Method Detail

getNumberOfTerms

public int getNumberOfTerms()
Returns the number of terms, or subqueries.

Returns:
int the number of terms, or subqueries of this query.

clone

public java.lang.Object clone()
Description copied from class: Query
Deep copy this Query object

Overrides:
clone in class Query

add

public void add(java.lang.String term)

add

public void add(Query query)
Adds a subquery to this query.

Parameters:
query - Query a subquery.

toString

public java.lang.String toString()
Returns a string representation of the query.

Specified by:
toString in class Query
Returns:
String the string of this query.

applyTermPipeline

public boolean applyTermPipeline(TermPipelineAccessor tpa)
Applies the given term pipeline to the query terms and sub-queries that construct this query.

Overrides:
applyTermPipeline in class Query
Parameters:
tpa - TermPipelineAccessor the object that gives access to a term pipeline.
Returns:
boolean true if the query is not empty, otherwise returns false.

obtainQueryTerms

public void obtainQueryTerms(MatchingQueryTerms terms)
Prepares the query for matching by transforming the query objects to a set of query terms.

Overrides:
obtainQueryTerms in class Query
Parameters:
terms - MatchingQueryTerms the object which holds the query terms and their modifiers.

obtainQueryTerms

public void obtainQueryTerms(MatchingQueryTerms terms,
                             boolean required)
Prepares the query for matching by transforming the query objects to a set of query terms.

Overrides:
obtainQueryTerms in class Query
Parameters:
terms - MatchingQueryTerms the object which holds the query terms and their modifiers.
required - boolean indicates whether the field query is required or not.

obtainControls

public boolean obtainControls(java.util.HashSet allowed,
                              java.util.Hashtable controls)
Checks all child objects to see if they are FieldQuery objects, they are each called to see if the are controls. Child objects which return true are removed from the tree. If all child objects return true then this object is also considered dead, and should be removed.

Overrides:
obtainControls in class Query
Parameters:
allowed - The HashSet of control names that are allowed to be set.
controls - The Hashtable into which child objects much add found controls
Returns:
true if this object should be considered dead (no longer part of the query), false otherwise.

getTermsOf

public void getTermsOf(java.lang.Class c,
                       java.util.ArrayList alist,
                       boolean req)
Returns all the query terms, in subqueries that are instances of a given class

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

obtainAllOf

public void obtainAllOf(java.lang.Class c,
                        java.util.ArrayList a)
Overrides:
obtainAllOf in class Query

Terrier IR Platform
1.1.1

Terrier Information Retrieval Platform 1.1.1. Copyright 2004-2007 University of Glasgow