Package org.apache.commons.dbutils
Class BasicRowProcessor
- java.lang.Object
-
- org.apache.commons.dbutils.BasicRowProcessor
-
- All Implemented Interfaces:
RowProcessor
public class BasicRowProcessor extends Object implements RowProcessor
Basic implementation of theRowProcessorinterface.This class is thread-safe.
- See Also:
RowProcessor
-
-
Constructor Summary
Constructors Constructor Description BasicRowProcessor()BasicRowProcessor constructor.BasicRowProcessor(BeanProcessor convert)BasicRowProcessor constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected static Map<String,Object>createCaseInsensitiveHashMap(int cols)static BasicRowProcessorinstance()Deprecated.Create instances with the constructors instead.Object[]toArray(ResultSet resultSet)Convert aResultSetrow into anObject[].<T> TtoBean(ResultSet resultSet, Class<? extends T> type)Convert aResultSetrow into a JavaBean.<T> List<T>toBeanList(ResultSet resultSet, Class<? extends T> type)Convert aResultSetinto aListof JavaBeans.Map<String,Object>toMap(ResultSet resultSet)Convert aResultSetrow into aMap.
-
-
-
Constructor Detail
-
BasicRowProcessor
public BasicRowProcessor()
BasicRowProcessor constructor. Bean processing defaults to a BeanProcessor instance.
-
BasicRowProcessor
public BasicRowProcessor(BeanProcessor convert)
BasicRowProcessor constructor.- Parameters:
convert- The BeanProcessor to use when converting columns to bean properties.- Since:
- 1.1
-
-
Method Detail
-
createCaseInsensitiveHashMap
protected static Map<String,Object> createCaseInsensitiveHashMap(int cols)
-
instance
@Deprecated public static BasicRowProcessor instance()
Deprecated.Create instances with the constructors instead. This will be removed after DbUtils 1.1.Returns the Singleton instance of this class.- Returns:
- The single instance of this class.
-
toArray
public Object[] toArray(ResultSet resultSet) throws SQLException
Convert aResultSetrow into anObject[]. This implementation copies column values into the array in the same order they're returned from theResultSet. Array elements will be set tonullif the column was SQL NULL.- Specified by:
toArrayin interfaceRowProcessor- Parameters:
resultSet- ResultSet that supplies the array data- Returns:
- the newly created array
- Throws:
SQLException- if a database access error occurs- See Also:
RowProcessor.toArray(java.sql.ResultSet)
-
toBean
public <T> T toBean(ResultSet resultSet, Class<? extends T> type) throws SQLException
Convert aResultSetrow into a JavaBean. This implementation delegates to a BeanProcessor instance.- Specified by:
toBeanin interfaceRowProcessor- Type Parameters:
T- The type of bean to create- Parameters:
resultSet- ResultSet that supplies the bean datatype- Class from which to create the bean instance- Returns:
- the newly created bean
- Throws:
SQLException- if a database access error occurs- See Also:
RowProcessor.toBean(java.sql.ResultSet, Class),BeanProcessor.toBean(java.sql.ResultSet, Class)
-
toBeanList
public <T> List<T> toBeanList(ResultSet resultSet, Class<? extends T> type) throws SQLException
Convert aResultSetinto aListof JavaBeans. This implementation delegates to a BeanProcessor instance.- Specified by:
toBeanListin interfaceRowProcessor- Type Parameters:
T- The type of bean to create- Parameters:
resultSet- ResultSet that supplies the bean datatype- Class from which to create the bean instance- Returns:
- A
Listof beans with the given type in the order they were returned by theResultSet. - Throws:
SQLException- if a database access error occurs- See Also:
RowProcessor.toBeanList(java.sql.ResultSet, Class),BeanProcessor.toBeanList(java.sql.ResultSet, Class)
-
toMap
public Map<String,Object> toMap(ResultSet resultSet) throws SQLException
Convert aResultSetrow into aMap.This implementation returns a
Mapwith case insensitive column names as keys. Calls tomap.get("COL")andmap.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.- Specified by:
toMapin interfaceRowProcessor- Parameters:
resultSet- ResultSet that supplies the map data- Returns:
- the newly created Map
- Throws:
SQLException- if a database access error occurs- See Also:
RowProcessor.toMap(java.sql.ResultSet)
-
-