public class BeanHandler extends java.lang.Object implements ResultSetHandler
ResultSetHandler
implementation that converts the first
ResultSet
row into a JavaBean. This class is thread safe.ResultSetHandler
Modifier and Type | Field and Description |
---|---|
private RowProcessor |
convert
The RowProcessor implementation to use when converting rows
into beans.
|
private java.lang.Class |
type
The Class of beans produced by this handler.
|
Constructor and Description |
---|
BeanHandler(java.lang.Class type)
Creates a new instance of BeanHandler.
|
BeanHandler(java.lang.Class type,
RowProcessor convert)
Creates a new instance of BeanHandler.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
handle(java.sql.ResultSet rs)
Convert the first row of the
ResultSet into a bean with the
Class given in the constructor. |
private java.lang.Class type
private RowProcessor convert
public BeanHandler(java.lang.Class type)
type
- The Class that objects returned from handle()
are created from.public BeanHandler(java.lang.Class type, RowProcessor convert)
type
- The Class that objects returned from handle()
are created from.convert
- The RowProcessor
implementation
to use when converting rows into beans.public java.lang.Object handle(java.sql.ResultSet rs) throws java.sql.SQLException
ResultSet
into a bean with the
Class
given in the constructor.handle
in interface ResultSetHandler
rs
- The ResultSet
to handle. It has not been touched
before being passed to this method.null
if there were no
rows in the ResultSet
.java.sql.SQLException
- if a database access error occursResultSetHandler.handle(java.sql.ResultSet)