1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.dbutils;
18
19 import java.sql.ResultSet;
20 import java.sql.SQLException;
21 import java.util.List;
22 import java.util.Map;
23
24 /**
25 * <code>RowProcessor</code> implementations convert
26 * <code>ResultSet</code> rows into various other objects. Implementations
27 * can extend <code>BasicRowProcessor</code> to protect themselves
28 * from changes to this interface.
29 *
30 * @see BasicRowProcessor
31 */
32 public interface RowProcessor {
33
34 /**
35 * Create an <code>Object[]</code> from the column values in one
36 * <code>ResultSet</code> row. The <code>ResultSet</code> should be
37 * positioned on a valid row before passing it to this method.
38 * Implementations of this method must not alter the row position of
39 * the <code>ResultSet</code>.
40 *
41 * @param rs ResultSet that supplies the array data
42 * @throws SQLException if a database access error occurs
43 * @return the newly created array
44 */
45 public Object[] toArray(ResultSet rs) throws SQLException;
46
47 /**
48 * Create a JavaBean from the column values in one <code>ResultSet</code>
49 * row. The <code>ResultSet</code> should be positioned on a valid row before
50 * passing it to this method. Implementations of this method must not
51 * alter the row position of the <code>ResultSet</code>.
52 *
53 * @param rs ResultSet that supplies the bean data
54 * @param type Class from which to create the bean instance
55 * @throws SQLException if a database access error occurs
56 * @return the newly created bean
57 */
58 public Object toBean(ResultSet rs, Class type) throws SQLException;
59
60 /**
61 * Create a <code>List</code> of JavaBeans from the column values in all
62 * <code>ResultSet</code> rows. <code>ResultSet.next()</code> should
63 * <strong>not</strong> be called before passing it to this method.
64 *
65 * @param rs ResultSet that supplies the bean data
66 * @param type Class from which to create the bean instance
67 * @throws SQLException if a database access error occurs
68 * @return A <code>List</code> of beans with the given type in the order
69 * they were returned by the <code>ResultSet</code>.
70 */
71 public List toBeanList(ResultSet rs, Class type) throws SQLException;
72
73 /**
74 * Create a <code>Map</code> from the column values in one
75 * <code>ResultSet</code> row. The <code>ResultSet</code> should be
76 * positioned on a valid row before
77 * passing it to this method. Implementations of this method must not
78 * alter the row position of the <code>ResultSet</code>.
79 *
80 * @param rs ResultSet that supplies the map data
81 * @throws SQLException if a database access error occurs
82 * @return the newly created Map
83 */
84 public Map toMap(ResultSet rs) throws SQLException;
85
86 }