com.ibm.pdq.runtime.data.handlers
Class IteratorResultHandler<T>

java.lang.Object
  extended by com.ibm.pdq.runtime.data.handlers.IteratorResultHandler<T>
All Implemented Interfaces:
ResultHandler<ResultIterator<T>>
Direct Known Subclasses:
IteratorPagingResultHandler

public class IteratorResultHandler<T>
extends Object
implements ResultHandler<ResultIterator<T>>

An implementation of ResultHandler that can be specified to cause pureQuery to return content of the results of an SQL query as an instance of ResultIterator. The rows are returned by the ResultIterator<T> in the same order in which they are returned from the data source. See ResultHandler for a description of how an implementation of ResultHandler can be specified to a pureQuery method.

The constructors of IteratorResultHandler<T> require the user to specify the format in which to return each row of the results. One way to specify the format is by providing a class. If a class is provided, pureQuery creates an instance of that class to contain each row of the results. The format also can be specified by providing an instance of an implementation of RowHandler to use to process each row of the results. <T> is the generic type of the RowHandler or the Class that is specified to a constructor, and it is the generic type of the returned ResultIterator<T>.

An instance of IteratorResultHandler<T> maintains no state information other than the format in which the ResultIterator<T> returns each row. Therefore, a single instance of IteratorResultHandler<T> can be used for more than one pureQuery method.


Constructor Summary

Constructor Summary
Constructor and Description
IteratorResultHandler(Class<T> beanClass)
Constructs an instance of IteratorResultHandler<T> that can be provided to a pureQuery method so that the method returns an instance of ResultIterator that returns content of the rows of the SQL query results as instances of the class beanClass.
IteratorResultHandler(RowHandler<T> singleRowHandler)
Constructs an instance of IteratorResultHandler<T> that can be provided to a pureQuery method so that the method returns an instance of ResultIterator that uses singleRowHandler to process and to return each row of the SQL query results.

Method Summary

Method Summary
Return Data TypeMethod Name and Description
ResultIterator<T> handle(ResultSet resultSet)
Returns an instance of ResultIterator that can be used to return each row of resultSet in the specified format.

Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail

IteratorResultHandler

public IteratorResultHandler(Class<T> beanClass)
Constructs an instance of IteratorResultHandler<T> that can be provided to a pureQuery method so that the method returns an instance of ResultIterator that returns content of the rows of the SQL query results as instances of the class beanClass.
Parameters:
beanClass - the Class in which to return content of each row of the SQL query results

IteratorResultHandler

public IteratorResultHandler(RowHandler<T> singleRowHandler)
Constructs an instance of IteratorResultHandler<T> that can be provided to a pureQuery method so that the method returns an instance of ResultIterator that uses singleRowHandler to process and to return each row of the SQL query results.
Parameters:
singleRowHandler - the instance of an implementation of RowHandler that is used to process each row of the SQL query results

Method Detail

handle

public ResultIterator<T> handle(ResultSet resultSet)
Returns an instance of ResultIterator that can be used to return each row of resultSet in the specified format. (The format to be used for each row was specified when the constructor was called.) When an IteratorResultHandler<T> is specified for a pureQuery inline method, pureQuery calls handle(ResultSet) to create the instance of ResultIterator<T> that is returned from the inline method.

<T> is the generic type of the RowHandler or the Class that is specified to a constructor, and it is the generic type of the returned ResultIterator<T>.

Specified by:
handle in interface ResultHandler<ResultIterator<T>>
Parameters:
resultSet - a ResultSet that represents the results from an SQL statement
Returns:
an instance of ResultIterator that can be used to return each row of resultSet in the specified format. (The format to be used for each row was specified when the constructor was called.) <T> is the generic type of the RowHandler or the Class that is specified to a constructor, and it is the generic type of the returned ResultIterator<T>.