com.atlassian.confluence.search.v2.query
Class BooleanQuery

java.lang.Object
  extended by com.atlassian.confluence.search.v2.query.BooleanQuery
All Implemented Interfaces:
SearchQuery

public class BooleanQuery
extends java.lang.Object
implements SearchQuery

A boolean query that allows and/or and not combinations of sub queries.

TODO: This SearchQuery implementation does not work with the QuerySerializer (or parser) since that mechanism relies on all parameters returned by getParameters having the same meaning; this is not currently true in this implementation.


Constructor Summary
BooleanQuery(java.util.Set<? extends SearchQuery> must, java.util.Set<? extends SearchQuery> should, java.util.Set<? extends SearchQuery> mustNot)
          Construct a new BooleanQuery encapsulating the supplied sub queries.
 
Method Summary
static SearchQuery andQuery(SearchQuery... queries)
          Build an AND query from one or more subqueries.
static SearchQuery composeAndQuery(SearchQuery searchQueryOne, SearchQuery searchQueryTwo)
          Deprecated. since 4.1 use .andQuery() instead.
static SearchQuery composeAndQuery(java.util.Set<? extends SearchQuery> subqueries)
          Return a query that "ANDs" together a list of queries.
static SearchQuery composeOrQuery(SearchQuery searchQueryOne, SearchQuery searchQueryTwo)
          Deprecated. since 4.1 use .orQuery() instead
static SearchQuery composeOrQuery(java.util.Set<? extends SearchQuery> subqueries)
          Return a query that "ORs" together a list of queries.
 boolean equals(java.lang.Object obj)
           
 java.lang.String getKey()
           
 java.util.Set<SearchQuery> getMustNotQueries()
           
 java.util.Set<SearchQuery> getMustQueries()
           
 java.util.List getParameters()
          List of parameters as Strings or SearchQuerys.
 java.util.Set<SearchQuery> getShouldQueries()
           
 int hashCode()
           
static SearchQuery orQuery(SearchQuery... queries)
          Create a query that is the OR of the provided sub-queries
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BooleanQuery

public BooleanQuery(java.util.Set<? extends SearchQuery> must,
                    java.util.Set<? extends SearchQuery> should,
                    java.util.Set<? extends SearchQuery> mustNot)
Construct a new BooleanQuery encapsulating the supplied sub queries. Either of the andQueries or the orQueries may be null but not both. You cannot have any notQueries without having at least one andQuery or orQuery.

Parameters:
must - the queries that must match.
should - the queries that may match.
mustNot - the queries that must not match.
Throws:
java.lang.IllegalArgumentException - if the parameters are not correct.
Method Detail

getKey

public java.lang.String getKey()
Specified by:
getKey in interface SearchQuery
Returns:
the plugin key

composeAndQuery

public static SearchQuery composeAndQuery(java.util.Set<? extends SearchQuery> subqueries)
Return a query that "ANDs" together a list of queries. If the list contains no entries then an AllQuery is installed. If it contains only a single entry, then that entry is returned. Otherwise a BooleanQuery combining the full list is returned.

Parameters:
subqueries - a list of SearchQuerys to combine. Must have size >= 1.
Returns:
a SearchQuery combining the subqueries.
Throws:
java.lang.IllegalArgumentException - if the list of subqueries is empty.

composeAndQuery

public static SearchQuery composeAndQuery(SearchQuery searchQueryOne,
                                          SearchQuery searchQueryTwo)
Deprecated. since 4.1 use .andQuery() instead.

Build an AND query from exactly two sub-queries.

Parameters:
searchQueryOne - the first sub-query
searchQueryTwo - the second sub-query
Returns:
the logical AND of the two provided queries

andQuery

public static SearchQuery andQuery(SearchQuery... queries)
Build an AND query from one or more subqueries.

Parameters:
queries - the SearchQuerys to combine. Must be >= 1.
Returns:
a SearchQuery combining the subqueries.
Throws:
java.lang.IllegalArgumentException - if the list of subqueries is empty.

composeOrQuery

public static SearchQuery composeOrQuery(java.util.Set<? extends SearchQuery> subqueries)
Return a query that "ORs" together a list of queries. If the list contains no entries then an AllQuery is installed. If it contains only a single entry, then that entry is returned. Otherwise a BooleanQuery combining the full list is returned.

Parameters:
subqueries - a list of SearchQuerys to combine. Must have size >= 1.
Returns:
a SearchQuery combining the subqueries.
Throws:
java.lang.IllegalArgumentException - if the list of subqueries is empty.

composeOrQuery

public static SearchQuery composeOrQuery(SearchQuery searchQueryOne,
                                         SearchQuery searchQueryTwo)
Deprecated. since 4.1 use .orQuery() instead

Create a query that is the OR of the two provided sub-queries

Parameters:
searchQueryOne - the first query to OR
searchQueryTwo - the second query to OR
Returns:
the OR of the two provided queries

orQuery

public static SearchQuery orQuery(SearchQuery... queries)
Create a query that is the OR of the provided sub-queries

Parameters:
queries - the queries to OR
Returns:
the OR of the provided queries

getMustQueries

public java.util.Set<SearchQuery> getMustQueries()

getShouldQueries

public java.util.Set<SearchQuery> getShouldQueries()

getMustNotQueries

public java.util.Set<SearchQuery> getMustNotQueries()

getParameters

public java.util.List getParameters()
Description copied from interface: SearchQuery
List of parameters as Strings or SearchQuerys.

Specified by:
getParameters in interface SearchQuery
Returns:
a List containing all the sub queries combined together. I'm not sure this is ever useful to anyone.

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2003-2013 Atlassian. All Rights Reserved.