1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package com.finalist.tools.database;
19
20 import java.sql.*;
21 import java.util.*;
22
23 /***
24 * Abstract class that database specific RowMappers should extend.
25 *
26 * @author P.S.D.Reitsma, Finalist IT Group
27 * @version 1.0
28 */
29 public abstract class RowMapper {
30
31 /***
32 * Method that binds an object of a specified type into a PreparedStatement and returns the PreparedStatement.
33 *
34 * @return PreparedStatement the resulting PreparedStatement after the bind has happened.
35 * @param pstmt PreparedStatement to which the object should be bound.
36 * @param bindVar the object that is to be bound.
37 * @param bindVarClassType the full classname that identifies the type of the class
38 * @param pos the position at which the object should be bound into the statement.
39 * @throws NotMappableException when no appropriate bind method could be found
40 * @throws SQLException
41 */
42 public abstract PreparedStatement bind(PreparedStatement pstmt, Object bindVar, String bindVarClassType, int pos) throws SQLException, NotMappableException;
43
44
45 /***
46 * Method that reads the values from a ResultSet for one row and stores them into a HashMap.
47 *
48 * @return the resulting HashMap
49 * @param rset the resultset that serves a source
50 * @param target the HashMap in which the values will be stored
51 * @throws NotMappableException when no appropriate unbind method could be found
52 * @throws SQLException
53 */
54 public abstract HashMap unBindIntoHashMap(ResultSet rset, HashMap target) throws SQLException, NotMappableException;
55
56
57 /***
58 * Method that reads the values from a ResultSet an populates the properties of a bean
59 *
60 * @return the resulting bean
61 * @param rset the resultset that serves a source
62 * @param target the bean of which the properties should be set
63 * @throws NotMappableException when no appropriate unbind method could be found
64 * @throws SQLException
65 */
66 public abstract Object unBindIntoBean(ResultSet rset, Object target) throws SQLException, NotMappableException;
67 }
68