T - The type of the elements that are iterated.public class MemoryBasedCopyingRemoteIterator<T> extends java.lang.Object implements RemoteIterator<java.util.List<T>>
| Modifier and Type | Field and Description |
|---|---|
protected int |
current
The reference to the current element which is to be retrieved next.
|
protected java.util.List<T> |
elements
The elements of this memory based iterator.
|
| Constructor and Description |
|---|
MemoryBasedCopyingRemoteIterator(java.util.Collection<T> elements)
Creates a new caching remote iterator for the designated result set to be
alive for the designated time.
|
| 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).
|
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).
|
protected volatile java.util.List<T> elements
protected int current
public MemoryBasedCopyingRemoteIterator(java.util.Collection<T> elements)
drop() on the created
iterator.elements - The elements of this iterator.public java.util.List<T> getNext(int count) throws 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.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 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.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 DataConsistencyException
RemoteIteratorDataSourceException since the already returned elements may
not be retrieved any more.getAll in interface RemoteIterator<java.util.List<T>>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)
RemoteIterator
A 0 or a negative value is equal to dropping this iterator.
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.public void drop()
RemoteIteratordrop in interface RemoteIterator<java.util.List<T>>