001/* Clob.java -- Access Character Large OBjects 002 Copyright (C) 1999, 2000, 2002, 2006 Free Software Foundation, Inc. 003 004This file is part of GNU Classpath. 005 006GNU Classpath is free software; you can redistribute it and/or modify 007it under the terms of the GNU General Public License as published by 008the Free Software Foundation; either version 2, or (at your option) 009any later version. 010 011GNU Classpath is distributed in the hope that it will be useful, but 012WITHOUT ANY WARRANTY; without even the implied warranty of 013MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 014General Public License for more details. 015 016You should have received a copy of the GNU General Public License 017along with GNU Classpath; see the file COPYING. If not, write to the 018Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 01902110-1301 USA. 020 021Linking this library statically or dynamically with other modules is 022making a combined work based on this library. Thus, the terms and 023conditions of the GNU General Public License cover the whole 024combination. 025 026As a special exception, the copyright holders of this library give you 027permission to link this library with independent modules to produce an 028executable, regardless of the license terms of these independent 029modules, and to copy and distribute the resulting executable under 030terms of your choice, provided that you also meet, for each linked 031independent module, the terms and conditions of the license of that 032module. An independent module is a module which is not derived from 033or based on this library. If you modify this library, you may extend 034this exception to your version of the library, but you are not 035obligated to do so. If you do not wish to do so, delete this 036exception statement from your version. */ 037 038 039package java.sql; 040 041import java.io.InputStream; 042import java.io.OutputStream; 043import java.io.Reader; 044import java.io.Writer; 045 046/** 047 * This interface contains methods for accessing a SQL CLOB (Character Large 048 * OBject) type. 049 * 050 * @author Aaron M. Renn (arenn@urbanophile.com) 051 */ 052public interface Clob 053{ 054 /** 055 * This method returns the number of characters in this <code>Clob</code>. 056 * 057 * @return The number of characters in this <code>Clob</code>. 058 * @exception SQLException If an error occurs. 059 * @since 1.2 060 */ 061 long length() throws SQLException; 062 063 /** 064 * This method returns the specified portion of this <code>Clob</code> as a 065 * <code>String</code>. 066 * 067 * @param start The index into this <code>Clob</code> (index values 068 * start at 1) to start returning characters from. 069 * @param count The requested number of characters to return. 070 * @return The requested <code>Clob</code> section, as a <code>String</code>. 071 * @exception SQLException If an error occurs. 072 * @since 1.2 073 */ 074 String getSubString(long start, int count) throws SQLException; 075 076 /** 077 * This method returns a character stream that reads the contents of this 078 * <code>Clob</code>. 079 * 080 * @return A character stream to read this <code>Clob</code>'s contents. 081 * @exception SQLException If an error occurs. 082 * @since 1.2 083 */ 084 Reader getCharacterStream() throws SQLException; 085 086 /** 087 * This method returns a byte stream that reads the contents of this 088 * <code>Clob</code> as a series of ASCII bytes. 089 * 090 * @return A stream to read this <code>Clob</code>'s contents. 091 * @exception SQLException If an error occurs. 092 * @since 1.2 093 */ 094 InputStream getAsciiStream() throws SQLException; 095 096 /** 097 * This method returns the index into this <code>Clob</code> of the first 098 * occurrence of the specified character pattern (supplied by the caller as a 099 * <code>String</code>). The search begins at the specified index. 100 * 101 * @param pattern The character pattern to search for, passed as a 102 * <code>String</code>. 103 * @param start The index into this <code>Clob</code> to start searching 104 * (indices start at 1). 105 * @return The index at which the pattern was found (indices start at 1), or 106 * -1 if the pattern was not found. 107 * @exception SQLException If an error occurs. 108 * @since 1.2 109 */ 110 long position(String pattern, long start) throws SQLException; 111 112 /** 113 * This method returns the index into this <code>Clob</code> of the first 114 * occurrence of the specified character pattern (supplied by the caller as a 115 * <code>Clob</code>). The search begins at the specified index. 116 * 117 * @param pattern The character pattern to search for, passed as a 118 * <code>Clob</code>. 119 * @param start The index into this <code>Clob</code> to start searching 120 * (indices start at 1). 121 * @return The index at which the pattern was found (indices start at 1), or 122 * -1 if the pattern was not found. 123 * @exception SQLException If an error occurs. 124 * @since 1.2 125 */ 126 long position(Clob pattern, long start) throws SQLException; 127 128 /** 129 * Writes the specified string into this <code>Clob</code>, starting at the 130 * specified index. 131 * 132 * @param start The index at which the writing starts. 133 * @param value The string to write. 134 * @return The number of characters written. 135 * @exception SQLException If an error occurs. 136 * @since 1.4 137 */ 138 int setString(long start, String value) throws SQLException; 139 140 /** 141 * Writes the specified portion of a string into this <code>Clob</code>, 142 * starting at the specified index. 143 * 144 * @param startWrite The index at which the writing starts. 145 * @param value The string to write a portion of. 146 * @param startRead The offset into the string where the portion to copy 147 * starts. 148 * @param count The number of characters to write. 149 * @return The number of characters written. 150 * @exception SQLException If an error occurs. 151 * @since 1.4 152 */ 153 int setString(long startWrite, String value, int startRead, int count) 154 throws SQLException; 155 156 /** 157 * Returns an ASCII text stream that writes into this <code>Clob</code>, 158 * starting at the specified index. 159 * 160 * @param start The index at which the writing starts. 161 * @return An ASCII text stream to write into this <code>Clob</code>. 162 * @exception SQLException If an error occurs. 163 * @since 1.4 164 */ 165 OutputStream setAsciiStream(long start) throws SQLException; 166 167 /** 168 * Returns a character stream that writes into this <code>Clob</code>, 169 * starting at the specified index. 170 * 171 * @param start The index at which the writing starts. 172 * @return A character stream to write into this <code>Clob</code>. 173 * @exception SQLException If an error occurs. 174 * @since 1.4 175 */ 176 Writer setCharacterStream(long start) throws SQLException; 177 178 /** 179 * Truncates this <code>Clob</code> to be at most the specified number of 180 * characters long. 181 * 182 * @param count The length this <code>Clob</code> is truncated to. 183 * @exception SQLException If an error occurs. 184 * @since 1.4 185 */ 186 void truncate(long count) throws SQLException; 187}