|
0
|
1 |
package hirondelle.web4j.database;
|
|
|
2 |
|
|
|
3 |
import java.sql.ResultSet;
|
|
|
4 |
import java.sql.SQLException;
|
|
|
5 |
import hirondelle.web4j.BuildImpl;
|
|
|
6 |
|
|
|
7 |
/**
|
|
|
8 |
Construct a building block object from the <em>first</em> column of a <tt>ResultSet</tt>.
|
|
|
9 |
|
|
|
10 |
<P>This implementation violates the rule that all columns must be used to construct the
|
|
|
11 |
target object.
|
|
|
12 |
*/
|
|
|
13 |
final class ValueFromRow<E> extends ModelBuilder<E>{
|
|
|
14 |
|
|
|
15 |
ValueFromRow(Class<E> aSupportedTargetClass){
|
|
|
16 |
fClass = aSupportedTargetClass;
|
|
|
17 |
}
|
|
|
18 |
|
|
|
19 |
E build(ResultSet aRow) throws SQLException {
|
|
|
20 |
return fColumnToObject.convert(aRow, FIRST_COLUMN, fClass);
|
|
|
21 |
}
|
|
|
22 |
|
|
|
23 |
// PRIVATE //
|
|
|
24 |
private final Class<E> fClass;
|
|
|
25 |
|
|
|
26 |
/** Translates column values into desired objects. */
|
|
|
27 |
private ConvertColumn fColumnToObject = BuildImpl.forConvertColumn();
|
|
|
28 |
|
|
|
29 |
private static final int FIRST_COLUMN = 1;
|
|
|
30 |
}
|