org.mycore.services.fieldquery
Class MCRQuery

java.lang.Object
  extended by org.mycore.services.fieldquery.MCRQuery

public class MCRQuery
extends Object

Represents a query with its condition and optional parameters


Constructor Summary
MCRQuery(MCRCondition cond)
          Builds a new MCRQuery object without sort criteria and unlimited results.
MCRQuery(MCRCondition cond, List<MCRSortBy> sortBy, int maxResults)
          Builds a new MCRQuery object with sort criteria and limited number of results.
 
Method Summary
 Document buildXML()
          Builds a XML representation of the query
 MCRCondition getCondition()
          Returns the query condition
 List getHosts()
          Returns the list of remote hosts to query
 int getMaxResults()
          Returns the maximum number of results the query should return
 List<MCRSortBy> getSortBy()
          Returns the list of MCRSortBy criteria for sorting query results
static MCRQuery parseXML(Document doc)
          Parses a XML representation of a query.
 void setHosts(List<String> hosts)
          Sets the remote hosts to query.
 void setMaxResults(int maxResults)
          Sets the maximum number of results the query should return.
 void setSortBy(List<MCRSortBy> sortBy)
          Sets the sort criteria for the query results
 void setSortBy(MCRSortBy sortBy)
          Sets the sort criteria for the query results
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MCRQuery

public MCRQuery(MCRCondition cond)
Builds a new MCRQuery object without sort criteria and unlimited results.

Parameters:
cond - the query conditions

MCRQuery

public MCRQuery(MCRCondition cond,
                List<MCRSortBy> sortBy,
                int maxResults)
Builds a new MCRQuery object with sort criteria and limited number of results.

Parameters:
cond - the query conditions
sortBy - a list of MCRSortBy criteria for sorting the results
maxResults - the maximum number of results to return
Method Detail

getCondition

public MCRCondition getCondition()
Returns the query condition

Returns:
the query condition

getMaxResults

public int getMaxResults()
Returns the maximum number of results the query should return

Returns:
the maximum number of results, or 0

setMaxResults

public void setMaxResults(int maxResults)
Sets the maximum number of results the query should return. Default is 0 which means "return all results".

Parameters:
maxResults - the maximum number of results

getSortBy

public List<MCRSortBy> getSortBy()
Returns the list of MCRSortBy criteria for sorting query results

Returns:
a list of MCRSortBy objects, may be empty

setSortBy

public void setSortBy(List<MCRSortBy> sortBy)
Sets the sort criteria for the query results

Parameters:
sortBy - a list of MCRSortBy objects, may be empty

setSortBy

public void setSortBy(MCRSortBy sortBy)
Sets the sort criteria for the query results

Parameters:
sortBy - a MCRSortBy object

getHosts

public List getHosts()
Returns the list of remote hosts to query

Returns:
a list of host alias Strings, may be empty

setHosts

public void setHosts(List<String> hosts)
Sets the remote hosts to query. Default is an empty list, which means only the local host is queried.

Parameters:
hosts - a list of host alias Strings, may be empty

buildXML

public Document buildXML()
Builds a XML representation of the query

Returns:
a XML document containing all query parameters

parseXML

public static MCRQuery parseXML(Document doc)
Parses a XML representation of a query.

Parameters:
xml - the XML document
Returns:
the parsed MCRQuery