commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject svn commit: r470976 - /jakarta/commons/proper/dbutils/trunk/src/java/org/apache/commons/dbutils/handlers/GenericListHandler.java
Date Fri, 03 Nov 2006 20:21:07 GMT
Author: bayard
Date: Fri Nov  3 12:21:07 2006
New Revision: 470976

URL: http://svn.apache.org/viewvc?view=rev&rev=470976
Log:
Missed the new class from #DBUTILS-16. 

Added:
    jakarta/commons/proper/dbutils/trunk/src/java/org/apache/commons/dbutils/handlers/GenericListHandler.java
  (with props)

Added: jakarta/commons/proper/dbutils/trunk/src/java/org/apache/commons/dbutils/handlers/GenericListHandler.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/dbutils/trunk/src/java/org/apache/commons/dbutils/handlers/GenericListHandler.java?view=auto&rev=470976
==============================================================================
--- jakarta/commons/proper/dbutils/trunk/src/java/org/apache/commons/dbutils/handlers/GenericListHandler.java
(added)
+++ jakarta/commons/proper/dbutils/trunk/src/java/org/apache/commons/dbutils/handlers/GenericListHandler.java
Fri Nov  3 12:21:07 2006
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.dbutils.handlers;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.dbutils.ResultSetHandler;
+
+/**
+ * Abstract class that simplify development of <code>ResultSetHandler</code>
+ * classes that convert <code>ResultSet</code> into <code>List</code>.
+ */
+abstract class GenericListHandler implements ResultSetHandler {
+	/**
+	 * Whole <code>ResultSet</code> handler. It produce <code>List</code>
as
+	 * result. To convert individual rows into Java objects it uses
+	 * <code>handleRow(ResultSet)</code> method.
+	 *
+	 * @see #handleRow(ResultSet)
+	 */
+	public Object handle(ResultSet rs) throws SQLException {
+		List rows = new ArrayList();
+		while (rs.next()) {
+			rows.add(this.handleRow(rs));
+		}
+		return rows;
+	}
+	
+	/**
+	 * Row handler. Method converts current row into some Java object.
+	 *
+	 * @param rs <code>ResultSet</code> to process.
+	 * @return row processing result
+	 * @throws SQLException error occurs
+	 */
+	protected abstract Object handleRow(ResultSet rs) throws SQLException;
+}

Propchange: jakarta/commons/proper/dbutils/trunk/src/java/org/apache/commons/dbutils/handlers/GenericListHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message