T
- The class that the code will be operating on.ID
- The class of the ID column associated with the class. The T class does not require an ID field. The class
needs an ID parameter however so you can use Void or Object to satisfy the compiler.public class SelectIterator<T,ID> extends Object implements CloseableIterator<T>
Dao.iterator()
methods.Constructor and Description |
---|
SelectIterator(Class<?> dataClass,
Dao<T,ID> classDao,
GenericRowMapper<T> rowMapper,
ConnectionSource connectionSource,
DatabaseConnection connection,
CompiledStatement compiledStmt,
ObjectCache objectCache)
If the statement parameter is null then this won't log information
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
void |
closeQuietly()
Close any underlying SQL statements but swallow any SQLExceptions.
|
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.
|
boolean |
hasNext()
Returns whether or not there are any remaining objects in the table.
|
boolean |
hasNextThrow()
Returns whether or not there are any remaining objects in the table.
|
T |
moveAbsolute(int position)
Move to an absolute position in the list and return that result or null if none.
|
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 |
next()
Returns the next object in the table.
|
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.
|
void |
remove()
Removes the last object returned by next() by calling delete on the dao associated with the object.
|
void |
removeThrow()
Removes the last object returned by next() by calling delete on the dao associated with the object.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEachRemaining
public SelectIterator(Class<?> dataClass, Dao<T,ID> classDao, GenericRowMapper<T> rowMapper, ConnectionSource connectionSource, DatabaseConnection connection, CompiledStatement compiledStmt, ObjectCache objectCache) throws SQLException
SQLException
public boolean hasNextThrow() throws SQLException
SQLException
- If there was a problem getting more results via SQL.public boolean hasNext()
hasNext
in interface Iterator<T>
IllegalStateException
- If there was a problem getting more results via SQL.public T first() throws SQLException
CloseableIterator
first
in interface CloseableIterator<T>
SQLException
public T previous() throws SQLException
CloseableIterator
previous
in interface CloseableIterator<T>
SQLException
public T current() throws SQLException
CloseableIterator
current
in interface CloseableIterator<T>
SQLException
public T nextThrow() throws SQLException
CloseableIterator
Iterator.next()
object in the table or null if none.nextThrow
in interface CloseableIterator<T>
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.public T next()
next
in interface Iterator<T>
IllegalStateException
- If there was a problem extracting the object from SQL.public T moveRelative(int offset) throws SQLException
CloseableIterator
Iterator.next()
.
moveRelative(-1) is the same as CloseableIterator.previous()
result. This may not work with the default iterator depending
on your database.moveRelative
in interface CloseableIterator<T>
offset
- Number of rows to move. Positive moves forward in the results. Negative moves backwards.SQLException
public T moveAbsolute(int position) throws SQLException
CloseableIterator
moveAbsolute
in interface CloseableIterator<T>
position
- Row number in the result list to move to.SQLException
public void removeThrow() throws SQLException
IllegalStateException
- If there was no previous next() call.SQLException
- If the delete failed.public void remove()
remove
in interface Iterator<T>
IllegalStateException
- If there was no previous next() call or if delete() throws a SQLException (set as the cause).public void close() throws Exception
close
in interface AutoCloseable
Exception
public void closeQuietly()
CloseableIterator
closeQuietly
in interface CloseableIterator<T>
public DatabaseResults getRawResults()
CloseableIterator
getRawResults
in interface CloseableIterator<T>
public void moveToNext()
CloseableIterator
Iterator.next()
.moveToNext
in interface CloseableIterator<T>
This documentation is licensed by Gray Watson under the Creative Commons Attribution-Share Alike 3.0 License.