org.zeroexchange.dataset.criteria
Class CriteriaDataSet<T extends Persistent>

java.lang.Object
  extended by org.zeroexchange.dataset.criteria.CriteriaDataSet<T>
All Implemented Interfaces:
Iterable<T>, DataSet<T>, SlicingDataSet<T>
Direct Known Subclasses:
ProcessorsCriteriaDataSet

public abstract class CriteriaDataSet<T extends Persistent>
extends Object
implements SlicingDataSet<T>

The criteria-based data set.

Author:
black

Constructor Summary
CriteriaDataSet(Class<T> itemClass)
           
 
Method Summary
protected abstract  org.hibernate.Criteria createBaseCriteria()
          Creates the base items criteria.
protected  org.hibernate.Criteria createCountCriteria()
          Override in subclasses if needed.
protected  org.hibernate.Criteria createListCriteria(long start, long count)
          Override in subclasses if needed.
 long getCount()
           
 Class<T> getItemClass()
          Returns item class.
 long getStart()
           
 long getTotalCount()
          Returns total count of items could be returned by the current dataset.
 Iterator<T> iterator()
          
protected  void processCriteria(org.hibernate.Criteria criteria, boolean count)
          Extension point to process criteria.
 void setCount(long count)
          Sets the max size of fetching fragment.
 void setStart(long start)
          Sets the start index.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CriteriaDataSet

public CriteriaDataSet(Class<T> itemClass)
Method Detail

getTotalCount

public long getTotalCount()
Returns total count of items could be returned by the current dataset.

Specified by:
getTotalCount in interface DataSet<T extends Persistent>

setStart

public void setStart(long start)
Sets the start index.

Specified by:
setStart in interface SlicingDataSet<T extends Persistent>

setCount

public void setCount(long count)
Sets the max size of fetching fragment.

Specified by:
setCount in interface SlicingDataSet<T extends Persistent>

getStart

public long getStart()
Returns:
the start

getCount

public long getCount()
Returns:
the count

iterator

public Iterator<T> iterator()

Specified by:
iterator in interface Iterable<T extends Persistent>

createCountCriteria

protected org.hibernate.Criteria createCountCriteria()
Override in subclasses if needed.


processCriteria

protected void processCriteria(org.hibernate.Criteria criteria,
                               boolean count)
Extension point to process criteria.


createListCriteria

protected org.hibernate.Criteria createListCriteria(long start,
                                                    long count)
Override in subclasses if needed.


getItemClass

public Class<T> getItemClass()
Returns item class.

Specified by:
getItemClass in interface DataSet<T extends Persistent>

createBaseCriteria

protected abstract org.hibernate.Criteria createBaseCriteria()
Creates the base items criteria.



Copyright © 2013. All Rights Reserved.