![]() |
Quadcap Embeddable Database |
00001 package com.quadcap.sql; 00002 00003 /* Copyright 1999 - 2003 Quadcap Software. All rights reserved. 00004 * 00005 * This software is distributed under the Quadcap Free Software License. 00006 * This software may be used or modified for any purpose, personal or 00007 * commercial. Open Source redistributions are permitted. Commercial 00008 * redistribution of larger works derived from, or works which bundle 00009 * this software requires a "Commercial Redistribution License"; see 00010 * http://www.quadcap.com/purchase. 00011 * 00012 * Redistributions qualify as "Open Source" under one of the following terms: 00013 * 00014 * Redistributions are made at no charge beyond the reasonable cost of 00015 * materials and delivery. 00016 * 00017 * Redistributions are accompanied by a copy of the Source Code or by an 00018 * irrevocable offer to provide a copy of the Source Code for up to three 00019 * years at the cost of materials and delivery. Such redistributions 00020 * must allow further use, modification, and redistribution of the Source 00021 * Code under substantially the same terms as this license. 00022 * 00023 * Redistributions of source code must retain the copyright notices as they 00024 * appear in each source code file, these license terms, and the 00025 * disclaimer/limitation of liability set forth as paragraph 6 below. 00026 * 00027 * Redistributions in binary form must reproduce this Copyright Notice, 00028 * these license terms, and the disclaimer/limitation of liability set 00029 * forth as paragraph 6 below, in the documentation and/or other materials 00030 * provided with the distribution. 00031 * 00032 * The Software is provided on an "AS IS" basis. No warranty is 00033 * provided that the Software is free of defects, or fit for a 00034 * particular purpose. 00035 * 00036 * Limitation of Liability. Quadcap Software shall not be liable 00037 * for any damages suffered by the Licensee or any third party resulting 00038 * from use of the Software. 00039 */ 00040 00041 import java.io.IOException; 00042 00043 import java.util.Vector; 00044 00045 import java.sql.SQLException; 00046 00047 /** 00048 * The base cursor interface. 00049 * 00050 * @author Stan Bailes 00051 */ 00052 public interface Cursor extends Tuple { 00053 // ---------------------- Row accessors 00054 /** 00055 * Return the cursor's current row 00056 */ 00057 public Row getRow() throws SQLException; 00058 00059 /** 00060 * Insert the specified row into the cursor's underlying table 00061 */ 00062 public void insertRow(Row row) throws SQLException; 00063 00064 /** 00065 * Replace the current cursor row with the specified row 00066 */ 00067 public void updateRow(Row row) throws SQLException; 00068 00069 /** 00070 * Delete the current cursor row 00071 */ 00072 public void deleteRow() throws SQLException; 00073 00074 /** 00075 * Some cursors have rows where the rows can be identified by row 00076 * id, and sometimes the cursors even know the row id for the 00077 * current row. If you know, tell us here! If you don't know, 00078 * just return 0. 00079 */ 00080 public long getRowId(); 00081 00082 00083 // ---------------------- Movement 00084 /** 00085 * Position the cursor before the first row 00086 */ 00087 public void beforeFirst() throws SQLException; 00088 00089 /** 00090 * Position the cursor after the last row. 00091 */ 00092 public void afterLast() throws SQLException; 00093 00094 /** 00095 * Move to the specified absolute row. The first row is '1'. 00096 * absolute(-1) moves to the last row. absolute(0) throws an 00097 * exception. 00098 * 00099 * @param row if > 0 the (one-based) row number else negative 00100 * offset from last row in cursor. 00101 * @return <b>true</b> if the specified row can be successfully 00102 * positioned. 00103 */ 00104 public boolean absolute(int row) throws SQLException; 00105 00106 /** 00107 * Advance the cursor and return true if we advanced to a valid row 00108 */ 00109 public boolean next() throws SQLException; 00110 00111 /** 00112 * Move the cursor back one row and return true if we moved back 00113 * to a valid row. 00114 */ 00115 public boolean prev() throws SQLException; 00116 00117 /** 00118 * Close the cursor and free up any resources (including closing 00119 * the cursor's transaction if that is feasible) used by the cursor. 00120 * 00121 * @exception SQLException may be thrown 00122 */ 00123 public void close() throws SQLException; 00124 00125 // ---------------------- Accessors 00126 00127 /** 00128 * If the underlying implementation knows, or can compute cheaply, 00129 * the actual size of the ResultSet, it should return a non-negative 00130 * number here. If the size is unknown and it would be expensive to 00131 * compute it (i.e., on the order of <code>while next()) size++</code>), 00132 * then the implementation should return -1 00133 */ 00134 public long size() throws SQLException; 00135 00136 /** 00137 * Return <b>true</b> if the specified column is writable. 00138 * 00139 * @param column the (one-based) column number 00140 * @exception SQLException may be thrown 00141 */ 00142 public boolean isWritable(int column) throws SQLException; 00143 00144 /** 00145 * Return the cursor in the enclosing context (this applies if we're 00146 * in a sub-query, for example) 00147 */ 00148 public Cursor getOuterCursor(); 00149 00150 /** 00151 * Set the cursor context in which this subquery is executing 00152 * 00153 * @param outer the cursor from the outer context 00154 */ 00155 public void setOuterCursor(Cursor outer); 00156 00157 /** 00158 * Return the cursor's session 00159 */ 00160 public Session getSession(); 00161 00162 /** 00163 * Some cursors are, or can be viewed as, tables. If your cursor 00164 * is such a type, return your table here, otherwise simply return 00165 * null. 00166 */ 00167 public Table getTable(); 00168 00169 /** 00170 * An attempt at an API to allow cursor reuse. 00171 */ 00172 public void reset(Expression where, Cursor outer) throws SQLException; 00173 }