![]() |
Quadcap Embeddable Database |
00001 package com.quadcap.sql.index; 00002 00003 /* Copyright 1997 - 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 /** 00044 * BCursor 00045 * 00046 * @author Stan Bailes 00047 */ 00048 public interface BCursor { 00049 // Cursor positioning 00050 00051 /** 00052 * Seek to (before) the specified key 00053 */ 00054 boolean seek(byte[] key, int len) throws IOException; 00055 00056 /** 00057 * Seek to (before) the specified key 00058 */ 00059 boolean seek(byte[] buf) throws IOException; 00060 00061 /** 00062 * Position cursor before the first record 00063 */ 00064 void beforeFirst() throws IOException; 00065 00066 /** 00067 * Position the cursor after the last record 00068 */ 00069 void afterLast() throws IOException; 00070 00071 /** 00072 * Move to the specified record; one-based. 00073 * -1 means last record, -2 means next to last, etc. 00074 * @return <b>true</b> if the specified record exists. 00075 */ 00076 boolean absolute(int x) throws IOException; 00077 00078 /** 00079 * Move past the next record and return true the cursor is 00080 * now pointed at a valid record. 00081 */ 00082 boolean next() throws IOException; 00083 00084 /** 00085 * Move before the previous record and return true the cursor is 00086 * now pointed at a valid record. 00087 */ 00088 boolean prev() throws IOException; 00089 00090 int getKey(byte[] buf) throws IOException; 00091 byte[] getKeyBuf(); 00092 void setKeyBuf(byte[] buf); 00093 int getKeyLen(); 00094 byte[] getKey(); // XXX a crutch. 00095 00096 int getVal(byte[] buf) throws IOException; 00097 byte[] getValBuf(); 00098 void setValBuf(byte[] buf); 00099 int getValLen(); 00100 byte[] getVal(); // XXX a crutch. 00101 00102 long getValAsLong() throws IOException; 00103 00104 long size() throws IOException; 00105 long position() throws IOException; 00106 00107 /** 00108 * Release this cursor back to the pool 00109 */ 00110 void release(); 00111 00112 /** 00113 * Release any resources held by this cursor (but maintain ownership of 00114 * it -- it can be resurrected by another positioning call. 00115 */ 00116 void close() throws IOException; 00117 00118 /** 00119 * Delete the currently positioned record 00120 */ 00121 boolean delete() throws IOException; 00122 00123 /** 00124 * Insert a new key/data pair. We are presumably positioned just before 00125 * the spot where the new record should go, but we will check, anyway. 00126 */ 00127 boolean insert(byte[] key, int klen, 00128 byte[] data, int doff, int dlen) throws IOException; 00129 boolean insert(byte[] key, byte[] data) throws IOException; 00130 00131 /** 00132 * Replace the data portion of the current item with the specified data 00133 */ 00134 boolean replace(byte[] data, int doff, int dlen) throws IOException; 00135 boolean replace(byte[] data) throws IOException; 00136 00137 }