org.apache.commons.dbutils
Class ResultSetIterator

java.lang.Object
  extended byorg.apache.commons.dbutils.ResultSetIterator
All Implemented Interfaces:
Iterator

public class ResultSetIterator
extends Object
implements Iterator

Wraps a ResultSet in an Iterator. This is useful when you want to present a non-database application layer with domain neutral data.

This implementation requires the ResultSet.isLast() method to be implemented.

Author:
Henri Yandell, David Graham

Field Summary
private  RowProcessor convert
          The processor to use when converting a row into an Object[].
private  ResultSet rs
          The wrapped ResultSet.
 
Constructor Summary
ResultSetIterator(ResultSet rs)
          Constructor for ResultSetIterator.
ResultSetIterator(ResultSet rs, RowProcessor convert)
          Constructor for ResultSetIterator.
 
Method Summary
 boolean hasNext()
           
 Object next()
          Returns the next row as an Object[].
 void remove()
          Deletes the current row from the ResultSet.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rs

private ResultSet rs
The wrapped ResultSet.


convert

private RowProcessor convert
The processor to use when converting a row into an Object[].

Constructor Detail

ResultSetIterator

public ResultSetIterator(ResultSet rs)
Constructor for ResultSetIterator.

Parameters:
rs - Wrap this ResultSet in an Iterator.

ResultSetIterator

public ResultSetIterator(ResultSet rs,
                         RowProcessor convert)
Constructor for ResultSetIterator.

Parameters:
rs - Wrap this ResultSet in an Iterator.
convert - The processor to use when converting a row into an Object[]. Defaults to a BasicRowProcessor.
Method Detail

hasNext

public boolean hasNext()
Specified by:
hasNext in interface Iterator

next

public Object next()
Returns the next row as an Object[].

Specified by:
next in interface Iterator
Returns:
An Object[] with the same number of elements as columns in the ResultSet.
See Also:
Iterator.next()

remove

public void remove()
Deletes the current row from the ResultSet.

Specified by:
remove in interface Iterator
See Also:
Iterator.remove()