public class ResultSetProcessor extends PropertyList
This subclass of PropertyList is able to process ResultSets into Java Objects. The processor must be prepared with a set of Property objects that correspond to the columns expected from the ResultSet. Null Properties represent ResultSet elements that are to be ignored.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CLASS_VERSION
Class version string
|
Constructor and Description |
---|
ResultSetProcessor()
Constructs a new ResultSetProcessor
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object[] |
processResultSet(java.sql.ResultSet pResultSet)
Processes the specified ResultSet and returns an array of the
resulting objects.
|
java.lang.Object[] |
processResultSet(java.sql.ResultSet pResultSet,
int pFirstRow,
int pMaxRows)
Processes the specified ResultSet and returns an array of the
resulting objects.
|
java.lang.Object |
processResultSetRow(java.sql.ResultSet pResultSet)
Processes one ResultSet row.
|
java.lang.Object |
processResultSetRow(java.sql.ResultSet pResultSet,
java.lang.Object pObject)
Processes one ResultSet row by filling in the values of the
specified object, as opposed to creating a new object to hold the
values.
|
java.lang.Object[] |
processResultSetRow(java.sql.ResultSet pResultSet,
java.lang.Object[] pObject)
Processes one ResultSet row by filling in the values of the
specified objects, as opposed to creating new objects to hold the
values.
|
addProperties, addProperty, getBeanClass, getBeanClasses, getClassProperties, getProperties, getProperty, getPropertyCount, getPropertyToClassTable
public ResultSetProcessor()
public java.lang.Object[] processResultSet(java.sql.ResultSet pResultSet) throws java.sql.SQLException
pResultSet
- the ResultSet to processjava.sql.SQLException
- if an error occurred during processingprocessResultSetRow(java.sql.ResultSet)
public java.lang.Object[] processResultSet(java.sql.ResultSet pResultSet, int pFirstRow, int pMaxRows) throws java.sql.SQLException
pResultSet
- the ResultSet to processpFirstRow
- the first row to skip to, where 0 is the first rowpMaxRows
- the maximum number of rows to return. All subsequent
rows are discarded. If -1, then there is no maximum.java.sql.SQLException
- if an error occurred during processingprocessResultSetRow(java.sql.ResultSet)
public java.lang.Object processResultSetRow(java.sql.ResultSet pResultSet) throws java.sql.SQLException
For example, if columns 1-3 were associated with the Person class, and columns 4-5 were associated with the Payscale class, then two objects would be created, one Person and one Payscale. The appropriate result set values would be assigned to the two objects. A 2-element object array would then be created, with element 0 containing the Person and element 1 containing the Payscale. The array is then returned.
If only one class is used by all the columns, then an array of objects is not created. Instead, the object of the appropriate class is created and returned, thereby avoiding the degenerate case of having a bunch of 1-element object arrays.
pResultSet
- the ResultSet from which one row should be
processed.java.sql.SQLException
- if an error occurred during processingprocessResultSet(java.sql.ResultSet)
public java.lang.Object processResultSetRow(java.sql.ResultSet pResultSet, java.lang.Object pObject) throws java.sql.SQLException
pResultSet
- the ResultSet from which one row should be
processed.pObject
- the object whose values are to be filled in from
the rowjava.sql.SQLException
- if an error occurred during processingprocessResultSet(java.sql.ResultSet)
public java.lang.Object[] processResultSetRow(java.sql.ResultSet pResultSet, java.lang.Object[] pObject) throws java.sql.SQLException
pResultSet
- the ResultSet from which one row should be
processed.pObject
- the array of objects whose values are to be
filled in from the rowjava.sql.SQLException
- if an error occurred during processingprocessResultSet(java.sql.ResultSet)