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 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(Set<? extends SearchQuery> must, Set<? extends SearchQuery> should, 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(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(Set<? extends SearchQuery> subqueries)
          Return a query that "ORs" together a list of queries.
 boolean equals(Object obj)
           
 String getKey()
           
 Set<SearchQuery> getMustNotQueries()
           
 Set<SearchQuery> getMustQueries()
           
 List getParameters()
          List of parameters as Strings or SearchQuerys.
 Set<SearchQuery> getShouldQueries()
           
 int hashCode()
           
static SearchQuery orQuery(SearchQuery... queries)
          Create a query that is the OR of the provided sub-queries
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BooleanQuery

public BooleanQuery(Set<? extends SearchQuery> must,
                    Set<? extends SearchQuery> should,
                    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:
IllegalArgumentException - if the parameters are not correct.
Method Detail

getKey

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

composeAndQuery

public static SearchQuery composeAndQuery(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:
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:
IllegalArgumentException - if the list of subqueries is empty.

composeOrQuery

public static SearchQuery composeOrQuery(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:
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 Set<SearchQuery> getMustQueries()

getShouldQueries

public Set<SearchQuery> getShouldQueries()

getMustNotQueries

public Set<SearchQuery> getMustNotQueries()

getParameters

public 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(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2003–2015 Atlassian. All rights reserved.