com.sap.tc.mobile.cfs.pers.api.util
Interface ManagedListIterator

All Superinterfaces:
java.util.Iterator, java.util.ListIterator, ManagedIterator

public interface ManagedListIterator
extends ManagedIterator, java.util.ListIterator

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:

Author:
d039184
See Also:
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

hasNext

boolean hasNext()
Specified by:
hasNext in interface java.util.Iterator
Specified by:
hasNext in interface java.util.ListIterator
Specified by:
hasNext in interface ManagedIterator

hasPrevious

boolean hasPrevious()
Specified by:
hasPrevious in interface java.util.ListIterator

next

java.lang.Object next()
Specified by:
next in interface java.util.Iterator
Specified by:
next in interface java.util.ListIterator
Specified by:
next in interface ManagedIterator

previous

java.lang.Object previous()
Specified by:
previous in interface java.util.ListIterator

release

void release()
Description copied from interface: ManagedIterator
Release resources bound by the iterator.

Specified by:
release in interface ManagedIterator

remove

void remove()
Specified by:
remove in interface java.util.Iterator
Specified by:
remove in interface java.util.ListIterator
Specified by:
remove in interface ManagedIterator

nextIndex

int nextIndex()
Specified by:
nextIndex in interface java.util.ListIterator

previousIndex

int previousIndex()
Specified by:
previousIndex in interface java.util.ListIterator