1 23 24 package org.continuent.sequoia.common.protocol; 25 26 import java.io.ByteArrayInputStream ; 27 import java.io.OutputStream ; 28 import java.io.Serializable ; 29 import java.io.StringReader ; 30 import java.io.Writer ; 31 import java.sql.SQLException ; 32 33 import org.continuent.sequoia.common.exceptions.NotImplementedException; 34 35 60 public class StringClob implements java.sql.Clob , Serializable 61 { 62 private static final long serialVersionUID = 1832832422588968988L; 63 64 65 private String stringData = null; 66 67 72 public StringClob(String data) 73 { 74 stringData = data; 75 } 76 77 87 public long length() throws SQLException 88 { 89 return stringData.length(); 90 } 91 92 101 public java.io.InputStream getAsciiStream() throws SQLException 102 { 103 return new ByteArrayInputStream (stringData.getBytes()); 104 } 105 106 115 public java.io.Reader getCharacterStream() throws SQLException 116 { 117 return new StringReader (stringData); 118 } 119 120 123 public String getSubString(long sqlPos, int wantedLength) throws SQLException 124 { 125 ByteArrayBlob.checkSQLRangeIsSupported(sqlPos, wantedLength); 126 int endIndex = Math.min( 128 stringData.length() - 1, 130 (int) (sqlPos - 1) + wantedLength - 1); 132 return stringData.substring((int) sqlPos - 1, endIndex); 133 } 134 135 149 public long position(String searchstr, long start) throws SQLException 150 { 151 return stringData.indexOf(searchstr, (int) start); 152 } 153 154 168 public long position(java.sql.Clob searchstr, long start) throws SQLException 169 { 170 return position(searchstr.getSubString(0, (int) searchstr.length()), 171 (int) start); 172 } 173 174 176 184 public OutputStream setAsciiStream(long pos) throws SQLException 185 { 186 throw new NotImplementedException("setAsciiStream"); 187 } 188 189 197 public Writer setCharacterStream(long pos) throws SQLException 198 { 199 throw new NotImplementedException("setCharacterStream"); 200 } 201 202 211 public int setString(long pos, String str) throws SQLException 212 { 213 throw new NotImplementedException("setString"); 214 } 215 216 227 public int setString(long pos, String str, int offset, int len) 228 throws SQLException 229 { 230 throw new NotImplementedException("setString"); 231 } 232 233 240 public void truncate(long len) throws SQLException 241 { 242 throw new NotImplementedException("truncate"); 243 } 244 } | Popular Tags |