Class ArrayHandler
- java.lang.Object
-
- org.apache.commons.dbutils.handlers.ArrayHandler
-
- All Implemented Interfaces:
ResultSetHandler<java.lang.Object[]>
public class ArrayHandler extends java.lang.Object implements ResultSetHandler<java.lang.Object[]>
ResultSetHandler
implementation that converts aResultSet
into anObject[]
. This class is thread safe.- See Also:
ResultSetHandler
-
-
Field Summary
Fields Modifier and Type Field Description private RowProcessor
convert
The RowProcessor implementation to use when converting rows into arrays.private static java.lang.Object[]
EMPTY_ARRAY
An empty array to return when no more rows are available in the ResultSet.(package private) static RowProcessor
ROW_PROCESSOR
Singleton processor instance that handlers share to save memory.
-
Constructor Summary
Constructors Constructor Description ArrayHandler()
Creates a new instance of ArrayHandler using aBasicRowProcessor
for conversion.ArrayHandler(RowProcessor convert)
Creates a new instance of ArrayHandler.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object[]
handle(java.sql.ResultSet rs)
Places the column values from the first row in anObject[]
.
-
-
-
Field Detail
-
ROW_PROCESSOR
static final RowProcessor ROW_PROCESSOR
Singleton processor instance that handlers share to save memory. Notice the default scoping to allow only classes in this package to use this instance.
-
EMPTY_ARRAY
private static final java.lang.Object[] EMPTY_ARRAY
An empty array to return when no more rows are available in the ResultSet.
-
convert
private final RowProcessor convert
The RowProcessor implementation to use when converting rows into arrays.
-
-
Constructor Detail
-
ArrayHandler
public ArrayHandler()
Creates a new instance of ArrayHandler using aBasicRowProcessor
for conversion.
-
ArrayHandler
public ArrayHandler(RowProcessor convert)
Creates a new instance of ArrayHandler.- Parameters:
convert
- TheRowProcessor
implementation to use when converting rows into arrays.
-
-
Method Detail
-
handle
public java.lang.Object[] handle(java.sql.ResultSet rs) throws java.sql.SQLException
Places the column values from the first row in anObject[]
.- Specified by:
handle
in interfaceResultSetHandler<java.lang.Object[]>
- Parameters:
rs
-ResultSet
to process.- Returns:
- An Object[]. If there are no rows in the
ResultSet
an empty array will be returned. - Throws:
java.sql.SQLException
- if a database access error occurs- See Also:
ResultSetHandler.handle(java.sql.ResultSet)
-
-