com.j256.ormlite.dao
Interface CloseableIterator<T>

All Superinterfaces:
Iterator<T>
All Known Implementing Classes:
SelectIterator

public interface CloseableIterator<T>
extends Iterator<T>

Extension to Iterator to provide a close() method. This should be in the JDK.

NOTE: You must call close() method when you are done otherwise the underlying SQL statement and connection may be kept open.

Author:
graywatson

Method Summary
 void close()
          Close any underlying SQL statements.
 T current()
          Return the current result object that we have accessed or null if none.
 T first()
          Move to the first result and return it or null if none.
 DatabaseResults getRawResults()
          Return the underlying database results object if any.
 T moveRelative(int offset)
          Move a relative position in the list and return that result or null if none.
 void moveToNext()
          Move to the next item in the iterator without calling Iterator.next().
 T nextThrow()
          Returns the Iterator.next() object in the table or null if none.
 T previous()
          Moves to the previous result and return it or null if none.
 
Methods inherited from interface java.util.Iterator
hasNext, next, remove
 

Method Detail

close

void close()
           throws SQLException
Close any underlying SQL statements.

Throws:
SQLException

getRawResults

DatabaseResults getRawResults()
Return the underlying database results object if any. May return null. This should not be used unless you know what you are doing.


moveToNext

void moveToNext()
Move to the next item in the iterator without calling Iterator.next().


first

T first()
        throws SQLException
Move to the first result and return it or null if none. This may not work with the default iterator depending on your database.

Throws:
SQLException

previous

T previous()
           throws SQLException
Moves to the previous result and return it or null if none. This may not work with the default iterator depending on your database.

Throws:
SQLException

current

T current()
          throws SQLException
Return the current result object that we have accessed or null if none.

Throws:
SQLException

nextThrow

T nextThrow()
            throws SQLException
Returns the Iterator.next() object in the table or null if none.

Throws:
SQLException - Throws a SQLException on error since Iterator.next() cannot throw because it is part of the Iterator definition. It will not throw if there is no next.

moveRelative

T moveRelative(int offset)
               throws SQLException
Move a relative position in the list and return that result or null if none. Moves forward (positive value) or backwards (negative value) the list of results. moveRelative(1) should be the same as Iterator.next(). moveRelative(-1) is the same as previous() result. This may not work with the default iterator depending on your database.

Parameters:
offset - Number of rows to move. Positive moves forward in the results. Negative moves backwards.
Throws:
SQLException


This documentation is licensed by Gray Watson under the Creative Commons Attribution-Share Alike 3.0 License.