T - The type of the elements that are retrieved from the encapsulated
result set.public abstract class ResultSetRemoteIterator<T> extends java.lang.Object implements RemoteIterator<java.util.List<T>>
The cursor of the underlying result set is positioned at the first element to be retrieved next in forward-only mode. Therefore in forward direction (the only possible direction) retrieve the element before advancing. In scrollable mode (non forward-only) the result set is positioned at the last element which has been retrieved (except the first element).
| Constructor and Description |
|---|
ResultSetRemoteIterator(ManagedResultSet resultSet,
long aliveTime)
Creates a new remote iterator for the designated result set to be alive for
the designated time.
|
ResultSetRemoteIterator(ManagedResultSet resultSet,
long aliveTime,
java.lang.String[] recTables)
Creates a new remote iterator for the designated result set to be alive for
the designated time dropping the designated recursion tables when dropping
this iterator.
|
| Modifier and Type | Method and Description |
|---|---|
void |
drop()
Explicitly drops this iterator which allows to release occupied memory and
resources.
|
java.util.List<T> |
getAll()
Gets all elements of this iterator at once.
|
java.util.List<T> |
getNext(int count)
Gets the next specified amount of elements of this iterator.
|
java.util.List<T> |
getNext(int count,
int start)
Gets the next specified amount of elements of this iterator starting at the
designated index (0-based).
|
protected abstract T |
getObject(java.sql.ResultSet resSet)
Gets the current object of the designated result set.
|
java.util.List<T> |
getPrevious(int count)
Gets the previous specified amount of elements of this iterator.
|
long |
getRemainingAliveTime()
Gets the time in milliseconds this iterator will still be valid and does
allow access to the underlying data.
|
boolean |
isForwardOnly()
Gets whether this iterator only allows iterating in forward direction, that
is calls to
RemoteIterator.getNext(int) but not to RemoteIterator.getNext(int, int) and
RemoteIterator.getPrevious(int). |
boolean |
isSnapshot()
Gets whether this iterator is a snapshot and therefore its contents is not
subject of change while iterating.
|
long |
keepAlive(long aliveTime)
Keeps this iterator alive for the designated time span (in milliseconds).
|
public ResultSetRemoteIterator(ManagedResultSet resultSet, long aliveTime) throws DataSourceException
resultSet - The result set for which to create a remote iterator. This
must not be null. The result set has to be managed by a
TxManager.aliveTime - The time in milliseconds the created remote iterator is
alive.DataSourceException - If positioning the result set or retrieving the
scroll behaviour of the result set fails, a
DataSourceException will be thrown.public ResultSetRemoteIterator(ManagedResultSet resultSet, long aliveTime, java.lang.String[] recTables) throws DataSourceException
resultSet - The result set for which to create a remote iterator. This
must not be null. The result set has to be managed by a
TxManager.aliveTime - The time in milliseconds the created remote iterator is
alive.recTables - The recursion tables to drop together with this iterator.
null if there are no such tables.DataSourceException - If positioning the result set or retrieving the
scroll behaviour of the result set fails, a
DataSourceException will be thrown.public java.util.List<T> getNext(int count) throws DataSourceException, DataConsistencyException
RemoteIteratorgetNext in interface RemoteIterator<java.util.List<T>>count - The amount of elements to retrieve in forward direction. This
has to be > 0.null will be returned.DataSourceException - If there are problems accessing the underlying
data source, a DataSourceException will be thrown.DataConsistencyException - If there are problems retrieving any of
the next elements via the identifying attribute of the elements
(for instance the primary key of a specific element identifying
the next position) is not available any more, a
DataConsistencyException will be thrown.public java.util.List<T> getNext(int count, int start) throws DataSourceException, DataConsistencyException
RemoteIteratorgetNext in interface RemoteIterator<java.util.List<T>>count - The amount of elements to retrieve in forward direction. This
has to be > 0.start - The index of the element from which to retrieve the next count
elements. 0 is the index of the first element. This has to be >= 0
and it must not be bigger than the amounts of elements in this
iterator.null will be returned.DataSourceException - If there are problems accessing the underlying
data source, a DataSourceException will be thrown.DataConsistencyException - If there are problems retrieving any of
the next elements via the identifying attribute of the elements
(for instance the primary key of a specific element identifying
the next position) is not available any more, a
DataConsistencyException will be thrown.public java.util.List<T> getPrevious(int count) throws DataSourceException, DataConsistencyException
RemoteIteratorgetPrevious in interface RemoteIterator<java.util.List<T>>count - The amount of elements to retrieve in backward direction. This
has to be > 0.null will be returned.DataSourceException - If there are problems accessing the underlying
data source, a DataSourceException will be thrown.DataConsistencyException - If there are problems retrieving any of
the previous next elements via the identifying attribute of the
elements (for instance the primary key of a specific element
identifying the next position) is not available any more or if
this iterator is forward only, a
DataConsistencyException will be thrown.public java.util.List<T> getAll() throws DataSourceException, DataConsistencyException
RemoteIteratorDataSourceException since the already returned elements may
not be retrieved any more.getAll in interface RemoteIterator<java.util.List<T>>DataSourceException - If there are problems accessing the underlying
data source or this iterator is forward only and currently not positioned before the first
element, a DataSourceException will be thrown.DataConsistencyException - If there are problems retrieving any of
the elements via the identifying attribute of the elements (for
instance the primary key of a specific element identifying the
next position) is not available any more, a
DataConsistencyException will be thrown.public boolean isSnapshot()
RemoteIteratorisSnapshot in interface RemoteIterator<java.util.List<T>>public boolean isForwardOnly()
RemoteIteratorRemoteIterator.getNext(int) but not to RemoteIterator.getNext(int, int) and
RemoteIterator.getPrevious(int). This can be restricted by the underlying data
structure, for instance a ResultSet.isForwardOnly in interface RemoteIterator<java.util.List<T>>public long getRemainingAliveTime()
RemoteIteratordropped automatically to save memory and resources. kept alive. Note that this alive time does not
need to correspond to the original alive time requestedgetRemainingAliveTime in interface RemoteIterator<java.util.List<T>>dropped. Long.MIN_VALUE for an already dropped remote iterator.public long keepAlive(long aliveTime)
throws DataSourceException
A 0 or a negative value is equal to dropping this iterator.
This implementation only allows extensions of alive times by 5 minutes.
keepAlive in interface RemoteIterator<java.util.List<T>>aliveTime - The time in milliseconds to keep this iterator alive that
is not to drop it automatically.RemoteIterator.getRemainingAliveTime() in this case whether extending
the keep alive time has been successful or not.DataSourceException - If there are problems accessing the underlying
data source, a DataSourceException will be thrown.public void drop()
throws DataSourceException
RemoteIteratordrop in interface RemoteIterator<java.util.List<T>>DataSourceException - If there are problems accessing the underlying
data source, a DataSourceException will be thrown.protected abstract T getObject(java.sql.ResultSet resSet) throws java.sql.SQLException, DataSourceException
resSet - The result set to retrieve the current position as Java
object.java.sql.SQLException - If there are problems retrieving the current element
from the result set, a SQLException will be thrown.DataSourceException - If there are other problems when accessing the
result set or retrieving additional information, a
DataSourceException will be thrown.