2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
20 import java.io.InputStream;
21 import java.io.OutputStream;
22 import java.io.Reader;
23 import java.io.Writer;
26 * A Java interface mapping for the SQL CLOB type.
28 * An SQL {@code CLOB} type stores a large array of characters as the value in a
29 * column of a database.
31 * The {@code java.sql.Clob} interface provides methods for setting and
32 * retrieving data in the {@code Clob}, for querying {@code Clob} data length,
33 * for searching for data within the {@code Clob}.
35 public interface Clob {
38 * Gets the value of this {@code Clob} object as an ASCII stream.
40 * @return an ASCII {@code InputStream} giving access to the
42 * @throws SQLException
43 * if an error occurs accessing the {@code Clob}.
45 public InputStream getAsciiStream() throws SQLException;
48 * Gets the data of this {@code Clob} object in a {@code java.io.Reader}.
50 * @return a character stream Reader object giving access to the {@code
52 * @throws SQLException
53 * if an error occurs accessing the {@code Clob}.
55 public Reader getCharacterStream() throws SQLException;
58 * Gets a copy of a specified substring in this {@code Clob}.
61 * the index of the start of the substring in the {@code Clob}.
63 * the length of the data to retrieve.
64 * @return A string containing the requested data.
65 * @throws SQLException
66 * if an error occurs accessing the {@code Clob}.
68 public String getSubString(long pos, int length) throws SQLException;
71 * Retrieves the number of characters in this {@code Clob} object.
73 * @return a long value with the number of character in this {@code Clob}.
74 * @throws SQLException
75 * if an error occurs accessing the {@code Clob}.
77 public long length() throws SQLException;
80 * Retrieves the character position at which a specified {@code Clob} object
81 * appears in this {@code Clob} object.
84 * the specified {@code Clob} to search for.
86 * the position within this {@code Clob} to start the search
87 * @return a long value with the position at which the specified {@code
88 * Clob} occurs within this {@code Clob}.
89 * @throws SQLException
90 * if an error occurs accessing the {@code Clob}.
92 public long position(Clob searchstr, long start) throws SQLException;
95 * Retrieves the character position at which a specified substring appears
96 * in this {@code Clob} object.
99 * the string to search for.
101 * the position at which to start the search within this {@code
103 * @return a long value with the position at which the specified string
104 * occurs within this {@code Clob}.
105 * @throws SQLException
106 * if an error occurs accessing the {@code Clob}.
108 public long position(String searchstr, long start) throws SQLException;
111 * Retrieves a stream which can be used to write Ascii characters to this
112 * {@code Clob} object, starting at specified position.
115 * the position at which to start the writing.
116 * @return an OutputStream which can be used to write ASCII characters to
118 * @throws SQLException
119 * if an error occurs accessing the {@code Clob}.
121 public OutputStream setAsciiStream(long pos) throws SQLException;
124 * Retrieves a stream which can be used to write a stream of unicode
125 * characters to this {@code Clob} object, at a specified position.
128 * the position at which to start the writing.
129 * @return a Writer which can be used to write unicode characters to this
131 * @throws SQLException
132 * if an error occurs accessing the {@code Clob}.
134 public Writer setCharacterStream(long pos) throws SQLException;
137 * Writes a given Java String to this {@code Clob} object at a specified
141 * the position at which to start the writing.
143 * the string to write.
144 * @return the number of characters written.
145 * @throws SQLException
146 * if an error occurs accessing the {@code Clob}.
148 public int setString(long pos, String str) throws SQLException;
151 * Writes {@code len} characters of a string, starting at a specified
152 * character offset, to this {@code Clob}.
155 * the position at which to start the writing.
157 * the String to write.
159 * the offset within {@code str} to start writing from.
161 * the number of characters to write.
162 * @return the number of characters written.
163 * @throws SQLException
164 * if an error occurs accessing the {@code Clob}.
166 public int setString(long pos, String str, int offset, int len)
170 * Truncates this {@code Clob} after the specified number of characters.
173 * the length in characters giving the place to
174 * truncate this {@code Clob}.
175 * @throws SQLException
176 * if an error occurs accessing the {@code Clob}.
178 public void truncate(long len) throws SQLException;
181 * Frees any resources held by this clob. After {@code free} is called, calling
182 * method other than {@code free} will throw {@code SQLException} (calling {@code free}
183 * repeatedly will do nothing).
185 * @throws SQLException
187 public void free() throws SQLException;
190 * Returns a {@link Reader} that reads {@code length} characters from this clob, starting
191 * at 1-based offset {code pos}.
193 public Reader getCharacterStream(long pos, long length) throws SQLException;