org.apache.commons.dbutils
Class BasicRowProcessor

java.lang.Object
  extended by org.apache.commons.dbutils.BasicRowProcessor
All Implemented Interfaces:
RowProcessor

public class BasicRowProcessor
extends Object
implements RowProcessor

Basic implementation of the RowProcessor interface.

This class is thread-safe.

See Also:
RowProcessor

Constructor Summary
BasicRowProcessor()
          BasicRowProcessor constructor.
BasicRowProcessor(BeanProcessor convert)
          BasicRowProcessor constructor.
 
Method Summary
static BasicRowProcessor instance()
          Deprecated. Create instances with the constructors instead. This will be removed after DbUtils 1.1.
 Object[] toArray(ResultSet rs)
          Convert a ResultSet row into an Object[].
<T> T
toBean(ResultSet rs, Class<T> type)
          Convert a ResultSet row into a JavaBean.
<T> List<T>
toBeanList(ResultSet rs, Class<T> type)
          Convert a ResultSet into a List of JavaBeans.
 Map<String,Object> toMap(ResultSet rs)
          Convert a ResultSet row into a Map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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:
DbUtils 1.1
Method Detail

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 rs)
                 throws SQLException
Convert a 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.

Specified by:
toArray in interface RowProcessor
Parameters:
rs - 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 rs,
                    Class<T> type)
         throws SQLException
Convert a ResultSet row into a JavaBean. This implementation delegates to a BeanProcessor instance.

Specified by:
toBean in interface RowProcessor
Type Parameters:
T - The type of bean to create
Parameters:
rs - ResultSet that supplies the bean data
type - 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, java.lang.Class), BeanProcessor.toBean(java.sql.ResultSet, java.lang.Class)

toBeanList

public <T> List<T> toBeanList(ResultSet rs,
                              Class<T> type)
                   throws SQLException
Convert a ResultSet into a List of JavaBeans. This implementation delegates to a BeanProcessor instance.

Specified by:
toBeanList in interface RowProcessor
Type Parameters:
T - The type of bean to create
Parameters:
rs - ResultSet that supplies the bean data
type - Class from which to create the bean instance
Returns:
A List of beans with the given type in the order they were returned by the ResultSet.
Throws:
SQLException - if a database access error occurs
See Also:
RowProcessor.toBeanList(java.sql.ResultSet, java.lang.Class), BeanProcessor.toBeanList(java.sql.ResultSet, java.lang.Class)

toMap

public Map<String,Object> toMap(ResultSet rs)
                         throws SQLException
Convert a 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.

Specified by:
toMap in interface RowProcessor
Parameters:
rs - 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)


Copyright © 2002-2011 The Apache Software Foundation. All Rights Reserved.