org.tolven.app.entity
Class QueryControl

java.lang.Object
  extended by org.tolven.app.entity.QueryControl
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
MenuQueryControl

public class QueryControl
extends java.lang.Object
implements java.io.Serializable

An argument-passing bean specifying query range, sort criteria and direction, and filter criteria.

Author:
John Churin
See Also:
Serialized Form

Constructor Summary
QueryControl()
           
 
Method Summary
 void addFilter(java.lang.String key, java.lang.Object value)
          Add an entry to the collection of filters.
 java.lang.String getFilter()
           
 java.util.Map<java.lang.String,java.lang.Object> getFilters()
          Return the collection of filters.
 int getLimit()
          Return the maximum number of rows to return.
 java.util.Date getNow()
          Queries are sometimes based on knowning the current.
 int getOffset()
          The offset into the result set to start returning results.
 java.lang.String getSortDirection()
          ASC or DESC to specify direction of the sort.
 java.lang.String getSortOrder()
          The field to sort on.
 void setFilter(java.lang.String filter)
           
 void setFilters(java.util.Map<java.lang.String,java.lang.Object> filters)
           
 void setLimit(int limit)
           
 void setNow(java.util.Date now)
           
 void setOffset(int offset)
           
 void setSortDirection(java.lang.String sortDirection)
           
 void setSortOrder(java.lang.String sortOrder)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

QueryControl

public QueryControl()
Method Detail

getLimit

public int getLimit()
Return the maximum number of rows to return. The actual number may be less. There is no "default". choose a very large number if that's what you want returned (although doing so is likely to blow out memory). Most queries typically return well under 1000 rows at a time.

Returns:
Number of rows to return

setLimit

public void setLimit(int limit)

getNow

public java.util.Date getNow()
Queries are sometimes based on knowning the current. In order to avoid problems with different queries using different values for now (usually only varying by miliseconds but nevertheless causing strange results when items fall though the cracks). At the beginning of a transaction, a single transaction-wide "now" is established and this everything occurs either before or after this one timestamp.

Returns:
A Date (timestamp)

setNow

public void setNow(java.util.Date now)

getOffset

public int getOffset()
The offset into the result set to start returning results. An offset of zero causes the query to start at the begining.

Returns:

setOffset

public void setOffset(int offset)

getSortDirection

public java.lang.String getSortDirection()
ASC or DESC to specify direction of the sort. May be null in which case the result set is not sorted.

Returns:
sort direction indicator (ascending or descending)

setSortDirection

public void setSortDirection(java.lang.String sortDirection)

toString

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

getSortOrder

public java.lang.String getSortOrder()
The field to sort on.

Returns:

setSortOrder

public void setSortOrder(java.lang.String sortOrder)

getFilters

public java.util.Map<java.lang.String,java.lang.Object> getFilters()
Return the collection of filters. This method always returns a collection, even if it has to first create one.

Returns:
Return a reference to the actual collection of filters, not a copy

setFilters

public void setFilters(java.util.Map<java.lang.String,java.lang.Object> filters)

addFilter

public void addFilter(java.lang.String key,
                      java.lang.Object value)
Add an entry to the collection of filters. You cannot set the same key twice.


getFilter

public java.lang.String getFilter()

setFilter

public void setFilter(java.lang.String filter)