|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
public interface ManagedListIterator
Iterator on persistent index or on QueryResult.
This iterator allows iterating over elements of an index or a query result.
The iterator is derived from ManagedIterator
interface. Thus, you can pass this iterator to methods that normally work with
ManagedIterator, resp. ListIterator.
This interface has a release() method that you should call when you
are done with the iterator to release resources.
Please note that the iterator is not quite stable when adding data in current persistence manager, just like regular Java iterators (see notes).
Iterator instances returned will be positioned at first readable record (if any). Then, you can iterate like this:
final ManagedListIterator iter = query.run(pm);
try {
while (iter.hasNext()) {
final Object o = iter.next();
// process o
}
} finally {
iter.release();
}
// iter should NOT be referenced here anymore
The iterator also supports hasPrevious() and previous()
methods to iterate in reverse direction. Alternating calls to next()
and previous() more times will return always the same object.
Notes:
remove() method to remove object last
returned by a call to next() or previous() (provided the
object can be locked, otherwise you'll get an exception). Iterator behaviour
is undefined if you remove objects while iterating in some other way than
by using remove() method.
UnsupportedOperationException for add()
and set(), because these cannot be implemented.
ManagedIterator,
ListIterator| Method Summary | |
|---|---|
boolean |
hasNext()
|
boolean |
hasPrevious()
|
java.lang.Object |
next()
|
int |
nextIndex()
|
java.lang.Object |
previous()
|
int |
previousIndex()
|
void |
release()
Release resources bound by the iterator. |
void |
remove()
|
| Methods inherited from interface java.util.ListIterator |
|---|
add, set |
| Method Detail |
|---|
boolean hasNext()
hasNext in interface java.util.IteratorhasNext in interface java.util.ListIteratorhasNext in interface ManagedIteratorboolean hasPrevious()
hasPrevious in interface java.util.ListIteratorjava.lang.Object next()
next in interface java.util.Iteratornext in interface java.util.ListIteratornext in interface ManagedIteratorjava.lang.Object previous()
previous in interface java.util.ListIteratorvoid release()
ManagedIterator
release in interface ManagedIteratorvoid remove()
remove in interface java.util.Iteratorremove in interface java.util.ListIteratorremove in interface ManagedIteratorint nextIndex()
nextIndex in interface java.util.ListIteratorint previousIndex()
previousIndex in interface java.util.ListIterator
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||