org.sadun.util
Class SqlIdIterator

java.lang.Object
  extended byorg.sadun.util.SqlIdIterator
All Implemented Interfaces:
IdIterator

public class SqlIdIterator
extends java.lang.Object
implements IdIterator

An IdIterator based on an SQL statement executed over a given Connection.

Author:
Cristiano Sadun

Field Summary
 
Fields inherited from interface org.sadun.util.IdIterator
BACKWARD, FORWARD
 
Constructor Summary
SqlIdIterator(ConnectionPool connectionPool, java.lang.String tableName, java.lang.String idColumnName)
           
SqlIdIterator(ConnectionPool connectionPool, java.lang.String tableName, java.lang.String idColumnName, java.lang.String upperLimit, java.lang.String lowerLimit)
           
SqlIdIterator(java.sql.Connection conn, java.lang.String tableName, java.lang.String idColumnName)
           
SqlIdIterator(java.sql.Connection conn, java.lang.String tableName, java.lang.String idColumnName, java.lang.String upperLimit, java.lang.String lowerLimit)
           
 
Method Summary
 void close()
          Releases this SqlIdIterator's result set and statement, but does not close the connection.
 java.lang.String getCurrentId()
          Return the id on which the iterator is currently positioned.
 java.lang.String getNextId(int direction)
          Moves the current id to the next in the given direction and returns it.
 boolean hasNext(int direction)
          (non-Javadoc)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SqlIdIterator

public SqlIdIterator(ConnectionPool connectionPool,
                     java.lang.String tableName,
                     java.lang.String idColumnName)
              throws java.sql.SQLException

SqlIdIterator

public SqlIdIterator(ConnectionPool connectionPool,
                     java.lang.String tableName,
                     java.lang.String idColumnName,
                     java.lang.String upperLimit,
                     java.lang.String lowerLimit)
              throws java.sql.SQLException

SqlIdIterator

public SqlIdIterator(java.sql.Connection conn,
                     java.lang.String tableName,
                     java.lang.String idColumnName)
              throws java.sql.SQLException

SqlIdIterator

public SqlIdIterator(java.sql.Connection conn,
                     java.lang.String tableName,
                     java.lang.String idColumnName,
                     java.lang.String upperLimit,
                     java.lang.String lowerLimit)
              throws java.sql.SQLException
Method Detail

hasNext

public boolean hasNext(int direction)
(non-Javadoc)

Specified by:
hasNext in interface IdIterator
Parameters:
direction - one of IdIterator.FORWARD or IdIterator.BACKWARD constants.
Returns:
true if there exist an id in the given direction.
See Also:
IdIterator.hasNext(int)

getCurrentId

public java.lang.String getCurrentId()
Description copied from interface: IdIterator
Return the id on which the iterator is currently positioned.

Specified by:
getCurrentId in interface IdIterator
Returns:
the id on which the iterator is currently positioned.

getNextId

public java.lang.String getNextId(int direction)
Description copied from interface: IdIterator
Moves the current id to the next in the given direction and returns it.

Specified by:
getNextId in interface IdIterator
Parameters:
direction - one of IdIterator.FORWARD or IdIterator.BACKWARD constants.
Returns:
the next id in the given direction.

close

public void close()
Releases this SqlIdIterator's result set and statement, but does not close the connection.

However, if the SqlIdIterator has been constructed via a ConnectionPool (see SqlIdIterator(ConnectionPool, String, String, String, String) and SqlIdIterator(ConnectionPool, String, String)), the connection is released to the pool.

Specified by:
close in interface IdIterator