1 24 25 package org.objectweb.cjdbc.driver; 26 27 import java.io.ByteArrayInputStream ; 28 import java.io.OutputStream ; 29 import java.io.Serializable ; 30 import java.io.StringReader ; 31 import java.io.Writer ; 32 import java.sql.SQLException ; 33 34 import org.objectweb.cjdbc.common.exceptions.NotImplementedException; 35 36 61 public class Clob implements java.sql.Clob , Serializable 62 { 63 private static final long serialVersionUID = 1832832422588968988L; 64 65 66 private String stringData = null; 67 68 73 public Clob(String data) 74 { 75 stringData = data; 76 } 77 78 88 public long length() throws SQLException 89 { 90 return stringData.length(); 91 } 92 93 102 public java.io.InputStream getAsciiStream() throws SQLException 103 { 104 return new ByteArrayInputStream (stringData.getBytes()); 105 } 106 107 116 public java.io.Reader getCharacterStream() throws SQLException 117 { 118 return new StringReader (stringData); 119 } 120 121 133 public String getSubString(long pos, int length) throws SQLException 134 { 135 if (length > stringData.length()) 136 throw new SQLException ("Clob contains only " + stringData.length() 137 + " characters (asking for " + length + ")."); 138 return stringData.substring((int) pos, length); 139 } 140 141 155 public long position(String searchstr, long start) throws SQLException 156 { 157 return stringData.indexOf(searchstr, (int) start); 158 } 159 160 174 public long position(java.sql.Clob searchstr, long start) throws SQLException 175 { 176 return position(searchstr.getSubString(0, (int) searchstr.length()), 177 (int) start); 178 } 179 180 182 190 public OutputStream setAsciiStream(long pos) throws SQLException 191 { 192 throw new NotImplementedException("setAsciiStream"); 193 } 194 195 203 public Writer setCharacterStream(long pos) throws SQLException 204 { 205 throw new NotImplementedException("setCharacterStream"); 206 } 207 208 217 public int setString(long pos, String str) throws SQLException 218 { 219 throw new NotImplementedException("setString"); 220 } 221 222 233 public int setString(long pos, String str, int offset, int len) 234 throws SQLException 235 { 236 throw new NotImplementedException("setString"); 237 } 238 239 246 public void truncate(long len) throws SQLException 247 { 248 throw new NotImplementedException("truncate"); 249 } 250 } | Popular Tags |