public class BasicRowProcessor extends Object implements RowProcessor
RowProcessor
interface.
This class is thread-safe.
RowProcessor
Constructor and Description |
---|
BasicRowProcessor()
BasicRowProcessor constructor.
|
BasicRowProcessor(BeanProcessor convert)
BasicRowProcessor constructor.
|
Modifier and Type | Method and Description |
---|---|
protected static Map<String,Object> |
createCaseInsensitiveHashMap(int cols) |
static BasicRowProcessor |
instance()
Deprecated.
Create instances with the constructors instead. This will
be removed after DbUtils 1.1.
|
Object[] |
toArray(ResultSet resultSet)
Convert a
ResultSet row into an Object[] . |
<T> T |
toBean(ResultSet resultSet,
Class<? extends T> type)
Convert a
ResultSet row into a JavaBean. |
<T> List<T> |
toBeanList(ResultSet resultSet,
Class<? extends T> type)
Convert a
ResultSet into a List of JavaBeans. |
Map<String,Object> |
toMap(ResultSet resultSet)
Convert a
ResultSet row into a Map . |
public BasicRowProcessor()
public BasicRowProcessor(BeanProcessor convert)
convert
- The BeanProcessor to use when converting columns to
bean properties.protected static Map<String,Object> createCaseInsensitiveHashMap(int cols)
@Deprecated public static BasicRowProcessor instance()
public Object[] toArray(ResultSet resultSet) throws SQLException
ResultSet
row into an Object[]
.
This implementation copies column values into the array in the same
order they're returned from the ResultSet
. Array elements
will be set to null
if the column was SQL NULL.toArray
in interface RowProcessor
resultSet
- ResultSet that supplies the array dataSQLException
- if a database access error occursRowProcessor.toArray(java.sql.ResultSet)
public <T> T toBean(ResultSet resultSet, Class<? extends T> type) throws SQLException
ResultSet
row into a JavaBean. This
implementation delegates to a BeanProcessor instance.toBean
in interface RowProcessor
T
- The type of bean to createresultSet
- ResultSet that supplies the bean datatype
- Class from which to create the bean instanceSQLException
- if a database access error occursRowProcessor.toBean(java.sql.ResultSet, Class)
,
BeanProcessor.toBean(java.sql.ResultSet, Class)
public <T> List<T> toBeanList(ResultSet resultSet, Class<? extends T> type) throws SQLException
ResultSet
into a List
of JavaBeans.
This implementation delegates to a BeanProcessor instance.toBeanList
in interface RowProcessor
T
- The type of bean to createresultSet
- ResultSet that supplies the bean datatype
- Class from which to create the bean instanceList
of beans with the given type in the order
they were returned by the ResultSet
.SQLException
- if a database access error occursRowProcessor.toBeanList(java.sql.ResultSet, Class)
,
BeanProcessor.toBeanList(java.sql.ResultSet, Class)
public Map<String,Object> toMap(ResultSet resultSet) throws SQLException
ResultSet
row into a Map
.
This implementation returns a Map
with case insensitive column names as keys. Calls to
map.get("COL")
and map.get("col")
return the same value. Furthermore this implementation
will return an ordered map, that preserves the ordering of the columns in the ResultSet, so that iterating over
the entry set of the returned map will return the first column of the ResultSet, then the second and so forth.
toMap
in interface RowProcessor
resultSet
- ResultSet that supplies the map dataSQLException
- if a database access error occursRowProcessor.toMap(java.sql.ResultSet)
Copyright © 2002–2023 The Apache Software Foundation. All rights reserved.