2.17.2: 2011-06-17

net.sf.basedb.core
Class DataResultIterator<I extends BasicData>

java.lang.Object
  extended by net.sf.basedb.core.DataResultIterator<I>
All Implemented Interfaces:
Iterator<I>, QueryResult, ResultIterator<I>

public class DataResultIterator<I extends BasicData>
extends Object
implements ResultIterator<I>

Return the results of a DataQuery as an iterator. This type of iterator is only used for batchable items like reporter and raw data. It is expected that the query uses the stateless Hibernate session available from DbControl.getStatelessSession(). If not, the returned objects are automatically disconnected from the Hibernate session to avoid memory problems and bypassing permission checks.

Version:
2.0
Author:
Samuel, Nicklas
See Also:
DataQuery.iterate(DbControl)
Last modified
$Date: 2009-04-06 14:52:39 +0200 (Mon, 06 Apr 2009) $

Field Summary
private  ScrollIterator<I> data
          The internal iterator of BasicData objects.
private  Class<I> dataClass
          The class of the data objects returned by the query (and this object).
private  Item itemType
          The type of items returned by the query.
private  SessionControl sc
          The SessionControl
private  org.hibernate.Session session
          The Hibernate Session that was used in the query, null if a stateless session is used.
private  long totalCount
          The total number of items.
 
Constructor Summary
DataResultIterator(ScrollIterator<I> data, SessionControl sc, org.hibernate.Session session, Class<I> dataClass, long totalCount)
           
 
Method Summary
 void close()
          From the ResultIterator interface ---------------------------------
 Item getItemType()
          Get the type of items contained in this list.
 long getTotalCount()
          From the QueryResult interface ---------------------------------
 boolean hasNext()
           
 boolean isClosed()
          Check if the iterator has been closed.
 I next()
           
 void remove()
          Not supported.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

data

private final ScrollIterator<I extends BasicData> data
The internal iterator of BasicData objects.


session

private final org.hibernate.Session session
The Hibernate Session that was used in the query, null if a stateless session is used.


sc

private final SessionControl sc
The SessionControl


totalCount

private final long totalCount
The total number of items.


dataClass

private final Class<I extends BasicData> dataClass
The class of the data objects returned by the query (and this object).


itemType

private final Item itemType
The type of items returned by the query.

Constructor Detail

DataResultIterator

DataResultIterator(ScrollIterator<I> data,
                   SessionControl sc,
                   org.hibernate.Session session,
                   Class<I> dataClass,
                   long totalCount)
Method Detail

getTotalCount

public long getTotalCount()
From the QueryResult interface ---------------------------------

Specified by:
getTotalCount in interface QueryResult
Returns:
The total number of items, or -1 if not known
See Also:
Query.setReturnTotalCount(boolean)

close

public void close()
From the ResultIterator interface ---------------------------------

Specified by:
close in interface ResultIterator<I extends BasicData>

isClosed

public boolean isClosed()
Description copied from interface: ResultIterator
Check if the iterator has been closed.

Specified by:
isClosed in interface ResultIterator<I extends BasicData>

hasNext

public boolean hasNext()
Specified by:
hasNext in interface Iterator<I extends BasicData>

next

public I next()
Specified by:
next in interface Iterator<I extends BasicData>

remove

public void remove()
Not supported.

Specified by:
remove in interface Iterator<I extends BasicData>
Throws:
UnsupportedOperationException - Always

getItemType

public Item getItemType()
Get the type of items contained in this list.

Returns:
An Item object or null if not known

2.17.2: 2011-06-17