00001
00025
package org.objectweb.cjdbc.driver;
00026
00027
import java.io.ByteArrayInputStream;
00028
import java.io.OutputStream;
00029
import java.io.Serializable;
00030
import java.io.StringReader;
00031
import java.io.Writer;
00032
import java.sql.SQLException;
00033
00034
import org.objectweb.cjdbc.common.sql.NotImplementedException;
00035
00059 public class Clob implements java.sql.
Clob, Serializable
00060 {
00062 private String
stringData = null;
00063
00069 public Clob(String data)
00070 {
00071
stringData = data;
00072 }
00073
00084 public long length() throws SQLException
00085 {
00086
return stringData.length();
00087 }
00088
00098 public java.io.InputStream
getAsciiStream() throws SQLException
00099 {
00100
return new ByteArrayInputStream(
stringData.getBytes());
00101 }
00102
00112 public java.io.Reader
getCharacterStream() throws SQLException
00113 {
00114
return new StringReader(
stringData);
00115 }
00116
00129 public String
getSubString(
long pos,
int length)
throws SQLException
00130 {
00131
if (
length >
stringData.length())
00132
throw new SQLException(
"Clob contains only " +
stringData.length()
00133 +
" characters (asking for " +
length +
").");
00134
return stringData.substring((
int) pos,
length);
00135 }
00136
00151 public long position(String searchstr,
long start)
throws SQLException
00152 {
00153
return stringData.indexOf(searchstr, (
int) start);
00154 }
00155
00170 public long position(java.sql.Clob searchstr,
long start)
throws SQLException
00171 {
00172
return position(searchstr.getSubString(0, (
int) searchstr.length()),
00173 (
int) start);
00174 }
00175
00176
00177
00186 public OutputStream
setAsciiStream(
long pos)
throws SQLException
00187 {
00188
throw new NotImplementedException(
"setAsciiStream");
00189 }
00190
00199 public Writer
setCharacterStream(
long pos)
throws SQLException
00200 {
00201
throw new NotImplementedException(
"setCharacterStream");
00202 }
00203
00213 public int setString(
long pos, String str)
throws SQLException
00214 {
00215
throw new NotImplementedException(
"setString");
00216 }
00217
00229 public int setString(
long pos, String str,
int offset,
int len)
00230
throws SQLException
00231 {
00232
throw new NotImplementedException(
"setString");
00233 }
00234
00242 public void truncate(
long len)
throws SQLException
00243 {
00244
throw new NotImplementedException(
"truncate");
00245 }
00246 }