Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
RowProcessor |
|
| 1.0;1 |
1 | /* | |
2 | * Licensed to the Apache Software Foundation (ASF) under one or more | |
3 | * contributor license agreements. See the NOTICE file distributed with | |
4 | * this work for additional information regarding copyright ownership. | |
5 | * The ASF licenses this file to You under the Apache License, Version 2.0 | |
6 | * (the "License"); you may not use this file except in compliance with | |
7 | * the License. You may obtain a copy of the License at | |
8 | * | |
9 | * http://www.apache.org/licenses/LICENSE-2.0 | |
10 | * | |
11 | * Unless required by applicable law or agreed to in writing, software | |
12 | * distributed under the License is distributed on an "AS IS" BASIS, | |
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
14 | * See the License for the specific language governing permissions and | |
15 | * limitations under the License. | |
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 | } |