Adding JMCR-Stable version
[Benchmarks_CSolver.git] / JMCR-Stable / real-world application / derby-10.3.2.1 / java / tools / org / apache / derby / impl / tools / ij / ijResultSetResult.java
diff --git a/JMCR-Stable/real-world application/derby-10.3.2.1/java/tools/org/apache/derby/impl/tools/ij/ijResultSetResult.java b/JMCR-Stable/real-world application/derby-10.3.2.1/java/tools/org/apache/derby/impl/tools/ij/ijResultSetResult.java
new file mode 100644 (file)
index 0000000..c32aa79
--- /dev/null
@@ -0,0 +1,81 @@
+/*\r
+\r
+   Derby - Class org.apache.derby.impl.tools.ij.ijResultSetResult\r
+\r
+   Licensed to the Apache Software Foundation (ASF) under one\r
+   or more contributor license agreements.  See the NOTICE file\r
+   distributed with this work for additional information\r
+   regarding copyright ownership.  The ASF licenses this file\r
+   to you under the Apache License, Version 2.0 (the\r
+   "License"); you may not use this file except in compliance\r
+   with the License.  You may obtain a copy of the License at\r
+\r
+      http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+   Unless required by applicable law or agreed to in writing, software\r
+   distributed under the License is distributed on an "AS IS" BASIS,\r
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+   See the License for the specific language governing permissions and\r
+   limitations under the License.\r
+\r
+ */\r
+\r
+package org.apache.derby.impl.tools.ij;\r
+\r
+import java.sql.Connection;\r
+import java.sql.ResultSet;\r
+import java.sql.Statement;\r
+import java.sql.SQLException;\r
+import java.sql.SQLWarning;\r
+\r
+/**\r
+ * This impl is intended to be used with a resultset,\r
+ * where the execution of the statement is already complete.\r
+ */\r
+public class ijResultSetResult extends ijResultImpl {\r
+\r
+       ResultSet resultSet;\r
+       Statement statement;\r
+\r
+       int[]     displayColumns = null;\r
+       int[]     columnWidths = null;\r
+\r
+       /**\r
+        * Create a ijResultImpl that represents a result set.\r
+        */\r
+       public ijResultSetResult(ResultSet r) throws SQLException {\r
+               resultSet = r;\r
+               statement = resultSet.getStatement();\r
+       }\r
+\r
+       /**\r
+        * Create a ijResultImpl that represents a result set, only\r
+        * displaying a subset of the columns, using specified column widths.\r
+        * \r
+        * @param r The result set to display\r
+        * @param display Which column numbers to display, or null to display\r
+        *                all columns.\r
+        * @param widths  The widths of the columns specified in 'display', or\r
+        *                null to display using default column sizes.\r
+        */\r
+       public ijResultSetResult(ResultSet r, int[] display,\r
+                                                        int[] widths) throws SQLException {\r
+               resultSet = r;\r
+               statement = resultSet.getStatement();\r
+\r
+               displayColumns = display;\r
+               columnWidths   = widths;\r
+       }\r
+\r
+       public boolean isResultSet() throws SQLException { return statement==null || statement.getUpdateCount() == -1; }\r
+\r
+       public ResultSet getResultSet() throws SQLException { return resultSet; }\r
+\r
+       public void closeStatement() throws SQLException { if(statement!=null) statement.close(); else resultSet.close(); }\r
+\r
+       public int[] getColumnDisplayList() { return displayColumns; }\r
+       public int[] getColumnWidthList() { return columnWidths; }\r
+\r
+       public SQLWarning getSQLWarnings() throws SQLException { return resultSet.getWarnings(); }\r
+       public void clearSQLWarnings() throws SQLException { resultSet.clearWarnings(); }\r
+}\r