//============================================================================== // SqlObjectResultSet.java // // Note: This requires Java 1.5 or later. //============================================================================== package tribble.sql; import java.lang.Character; import java.lang.String; import java.lang.StringBuilder; import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; import java.util.HashMap; /******************************************************************************* * SQL query result set. * See {@link SqlTypeQuery} for details. * * *

* Note: This requires Java 1.5 or later. * *

*
Source code:
*
Available at: * http://david.tribble.com/src/java/tribble/sql/SqlTypeResultSet.java *
*
Documentation:
*
Available at: * http://david.tribble.com/docs/tribble/sql/SqlTypeResultSet.html *
*
* * * @version @(#)$Revision: 1.2 $ $Date: 2008/09/15 17:43:45 $ * @since 2008-02-14 * @author David R. Tribble (david@tribble.com) *

* Copyright ©2008 by David R. Tribble, all rights reserved.
* Permission is granted to any person or entity except those designated by * by the United States Department of State as a terrorist, or terrorist * government or agency, to use and distribute this source code provided * that the original copyright notice remains present and unaltered. */ public class SqlTypeResultSet { static final String REV = "@(#)tribble/sql/SqlTypeResultSet.java $Revision: 1.2 $ $Date: 2008/09/15 17:43:45 $\n"; // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ // Variables /** Query result object type. */ private Class m_type; /** Parent SQL query that produced this result set. */ private SqlTypeQuery m_query; /** Result set of the query. */ private SqlObjectResultSet m_results; // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ // Constructors /*************************************************************************** * Constructor. * * @since 1.1, 2008-02-14 */ SqlTypeResultSet(Class resultType, SqlTypeQuery query, SqlObjectResultSet results) { m_type = resultType; m_query = query; m_results = results; } // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ // Methods /*************************************************************************** * Close this result set, releasing all object storage associated with it. * *

* Note that this method never throws SQLException, even if such an * exception results during the closing of the result set. * * @since 1.1, 2008-02-24 */ public void close() { // Close the result set if (m_results != null) { m_results.close(); m_results = null; } } /*************************************************************************** * Determines if there is a next row in the results of the SQL query, and * advances to that row. * * @throws SQLException * Thrown if an error occurs when the SQL result set is advanced to the next * result row. * * @since 1.1, 2008-02-24 */ public boolean next() throws SQLException { // Sanity check if (m_results == null) throw new SQLException("Result set is no longer active"); // Advance the result set pointer to the next result row return m_results.next(); } /*************************************************************************** * Retrieve the next row from the results of the SQL query. * * @since 1.1, 2008-02-14 */ public ResultType getResult() throws SQLException { // Sanity check if (m_results == null) throw new SQLException("Result set is no longer active"); // Create a new object for the current result row return (ResultType) m_results.getResult(); } } // End SqlTypeResultSet.java