org.mmbase.storage.search.implementation
Class ModifiableQuery

java.lang.Object
  extended by org.mmbase.storage.search.implementation.ModifiableQuery
All Implemented Interfaces:
Serializable, Cacheable, SearchQuery

public class ModifiableQuery
extends Object
implements SearchQuery, Serializable

A ModifiedQuery enables a modifiable lightweight copy of a SearchQuery to be created by wrapping the original query.

This class is provided primarily for use by core-, security- and storage layer classes, in those rare cases where modifications may be appropriate to a query before processing it.

The ModifiedQuery wraps the original query, and can be modified without affecting the original query. Modifications are not validated, and may lead to inconsistent data in the query (e.g. sorting on fields that are not in the query), resulting in a query that can not be processed by the storage. Avoiding such inconsistencies is the responsibility of the user.

Since:
MMBase-1.7
Version:
$Id: ModifiableQuery.java 41982 2010-04-20 14:05:14Z michiel $
Author:
Rob van Maris
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface org.mmbase.storage.search.SearchQuery
DEFAULT_MAX_NUMBER, DEFAULT_OFFSET
 
Constructor Summary
ModifiableQuery(SearchQuery query)
          Creates a new instance of ModifiedQuery
 
Method Summary
 boolean equals(Object obj)
          Compares this query to the specified object.
 CachePolicy getCachePolicy()
          Returns the CachePolicy of the object.
 Constraint getConstraint()
          Gets the constraints on the search results.
 List<StepField> getFields()
          Gets the stepfields in the search request.
 int getMaxNumber()
          Gets the maximum number of results to be returned, or -1 if the number of results to be returned is unlimited.
 int getOffset()
          Gets the (zerobased) offset in the list of results, of the first result to return.
 List<SortOrder> getSortOrders()
          Gets the SortOrder objects in the order they are to be applied.
 List<Step> getSteps()
          Gets the steps in the search request.
 int hashCode()
           Should correspond to BasicSearchQuery.hashCode()
 boolean isAggregating()
          Tests if this is an aggregating query, i.e.
 boolean isDistinct()
          Tests if the search request is to return distinct results.
 boolean markUsed()
           
 ModifiableQuery setAggregating(Boolean aggregating)
          Sets the aggregating property.
 void setCachePolicy(CachePolicy policy)
          Sets the CachePolicy of the query.
 ModifiableQuery setConstraint(Constraint constraint)
          Sets the constraint property.
 ModifiableQuery setDistinct(Boolean distinct)
          Sets the distinct property.
 ModifiableQuery setFields(List<StepField> fields)
          Sets the fields property.
 ModifiableQuery setMaxNumber(int maxNumber)
          Sets the maxNumber property.
 ModifiableQuery setOffset(int offset)
          Sets the offset property.
 ModifiableQuery setSortOrders(List<SortOrder> sortOrders)
          Sets the sortOrders property.
 ModifiableQuery setSteps(List<Step> steps)
          Sets the steps property.
 String toString()
          Returns a string representation of this SearchQuery.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ModifiableQuery

public ModifiableQuery(SearchQuery query)
Creates a new instance of ModifiedQuery

Method Detail

setMaxNumber

public ModifiableQuery setMaxNumber(int maxNumber)
Sets the maxNumber property.

Parameters:
maxNumber - The maxNumber value, -1 means: use query.getMaxNumber().
Returns:
This ModifiableQuery instance.

setOffset

public ModifiableQuery setOffset(int offset)
Sets the offset property.

Parameters:
offset - The offset value, -1 means: use query.getOffset().
Returns:
This ModifiableQuery instance.

setConstraint

public ModifiableQuery setConstraint(Constraint constraint)
Sets the constraint property.

Parameters:
constraint - The constraint, null means: use query.getConstraint().
Returns:
This ModifiableQuery instance.

setFields

public ModifiableQuery setFields(List<StepField> fields)
Sets the fields property.

Parameters:
fields - The fields, null means: use query.getFields().
Returns:
This ModifiableQuery instance.

setSortOrders

public ModifiableQuery setSortOrders(List<SortOrder> sortOrders)
Sets the sortOrders property.

Parameters:
sortOrders - The sortorders, null means: use query.getSortOrders().
Returns:
This ModifiableQuery instance.

setSteps

public ModifiableQuery setSteps(List<Step> steps)
Sets the steps property.

Parameters:
steps - The steps, null means: use query.getSteps()Returns:
This ModifiableQuery instance.

setDistinct

public ModifiableQuery setDistinct(Boolean distinct)
Sets the distinct property.

Parameters:
distinct - The value of the distinct property, null means: use query.isDistinct().
Returns:
This ModifiableQuery instance.

setAggregating

public ModifiableQuery setAggregating(Boolean aggregating)
Sets the aggregating property.

Parameters:
aggregating - The value of the aggregating property, null means: use query.isAggregating().
Returns:
This ModifiableQuery instance.

getMaxNumber

public int getMaxNumber()
Description copied from interface: SearchQuery
Gets the maximum number of results to be returned, or -1 if the number of results to be returned is unlimited.

Note: limiting the number of results may not be supported by the database layer.

Specified by:
getMaxNumber in interface SearchQuery

getOffset

public int getOffset()
Description copied from interface: SearchQuery
Gets the (zerobased) offset in the list of results, of the first result to return. Note that, since it is zerobased, it is equal to the number of results that are skipped.

Note: skipping results may not be supported by the database layer.

Specified by:
getOffset in interface SearchQuery

getConstraint

public Constraint getConstraint()
Description copied from interface: SearchQuery
Gets the constraints on the search results.

This corresponds to (part of) the constraints in the WHERE-clause in SQL SELECT-syntax.

Specified by:
getConstraint in interface SearchQuery

getFields

public List<StepField> getFields()
Description copied from interface: SearchQuery
Gets the stepfields in the search request.

This corresponds to the fields in SQL SELECT-syntax.

Specified by:
getFields in interface SearchQuery

getSortOrders

public List<SortOrder> getSortOrders()
Description copied from interface: SearchQuery
Gets the SortOrder objects in the order they are to be applied. This specifies the sorting order of the search results.

This corresponds to the ORDER BY clause in SQL SELECT syntax.

Specified by:
getSortOrders in interface SearchQuery

getSteps

public List<Step> getSteps()
Description copied from interface: SearchQuery
Gets the steps in the search request.

This corresponds to the tables in SQL SELECT-syntax.

Specified by:
getSteps in interface SearchQuery

isDistinct

public boolean isDistinct()
Description copied from interface: SearchQuery
Tests if the search request is to return distinct results. In that case duplicate nodes will be removed from the result.

This corresponds to the use of "DISTINCT" in SQL SELECT-syntax .

Specified by:
isDistinct in interface SearchQuery

isAggregating

public boolean isAggregating()
Description copied from interface: SearchQuery
Tests if this is an aggregating query, i.e. containing aggregated fields.

Specified by:
isAggregating in interface SearchQuery

getCachePolicy

public CachePolicy getCachePolicy()
Description copied from interface: Cacheable
Returns the CachePolicy of the object.

Specified by:
getCachePolicy in interface Cacheable
Returns:
the CachePolicy object.

setCachePolicy

public void setCachePolicy(CachePolicy policy)
Description copied from interface: Cacheable
Sets the CachePolicy of the query.

Specified by:
setCachePolicy in interface Cacheable
Parameters:
policy - the CachePolicy object.

equals

public boolean equals(Object obj)
Compares this query to the specified object. The result is true if and only if the argument is a non-null SearchQuery object representing the same query. Should correspond to BasicSearchQuery.equals(java.lang.Object)

Specified by:
equals in interface SearchQuery
Overrides:
equals in class Object
Parameters:
obj - The object to compare with.
Returns:
true if the objects are equal, false otherwise.

hashCode

public int hashCode()
Should correspond to BasicSearchQuery.hashCode()

Specified by:
hashCode in interface SearchQuery
Overrides:
hashCode in class Object

toString

public String toString()
Description copied from interface: SearchQuery
Returns a string representation of this SearchQuery. The string representation has the form "SearchQuery(distinct:<distinct>, steps:<steps>, fields:<fields>, constraint:<constraint>, sortorders:<sortorders>, max:<max>, offset:<offset>)" where

Specified by:
toString in interface SearchQuery
Overrides:
toString in class Object
Returns:
A string representation of this SearchQuery.

markUsed

public boolean markUsed()
Specified by:
markUsed in interface SearchQuery


MMBase 2.0-SNAPSHOT - null