| 1 package com.daffodilwoods.daffodildb.server.serversystem; 2 3 import java.io.*; 4 import java.sql.*; 5 import com.daffodilwoods.database.resource.DException; 6 7 8 public class ClobSaveMode implements Clob { 9 10 private long start; 11 private int length; 12 private String savedlobFilePath; 13 14 public ClobSaveMode(long start0, int length0) throws DException { 15 start = start0; 16 length = length0; 17 } 18 19 public ClobSaveMode(long start0, int length0, String savedlobFilePath0) throws DException { 20 start = start0; 21 length = length0; 22 savedlobFilePath = savedlobFilePath0+"clob.lob"; 23 } 24 25 public long length() throws SQLException { 26 return length; 27 } 28 29 public String getSubString(long pos, int length0) throws SQLException { 30 31 long start1 = start + pos; 32 length0 = ( start1 + length0) < (start + length) ? 33 length0 + (int)start1 : (int)(length - pos ); 34 byte[] buf = new byte[ length0]; 35 long skip = -1; 36 try { 37 InputStream is = new FileInputStream(savedlobFilePath); 38 if(start1!=0) 39 skip = is.skip(start1); 40 is.read(buf,0,length0); 41 is.close() ; 42 } 43 catch (IOException ex) { 44 throw new SQLException(ex.getMessage()); 45 } 46 return new String (buf); 47 64 } 65 66 public Reader getCharacterStream() throws SQLException { 67 return new InputStreamReader(getAsciiStream()); 68 } 69 public InputStream getAsciiStream() throws SQLException { 70 return new ByteArrayInputStream(getSubString(0,(int)length).getBytes()); 71 } 72 public long position(String searchstr, long start) throws SQLException { 73 74 throw new java.lang.UnsupportedOperationException ("Method position() not yet implemented."); 75 } 76 public long position(Clob searchstr, long start) throws SQLException { 77 78 throw new java.lang.UnsupportedOperationException ("Method position() not yet implemented."); 79 } 80 public int setString(long pos, String str) throws SQLException { 81 82 throw new java.lang.UnsupportedOperationException ("Method setString() not yet implemented."); 83 } 84 public int setString(long pos, String str, int offset, int len) throws SQLException { 85 86 throw new java.lang.UnsupportedOperationException ("Method setString() not yet implemented."); 87 } 88 public OutputStream setAsciiStream(long pos) throws SQLException { 89 90 throw new java.lang.UnsupportedOperationException ("Method setAsciiStream() not yet implemented."); 91 } 92 public Writer setCharacterStream(long pos) throws SQLException { 93 94 throw new java.lang.UnsupportedOperationException ("Method setCharacterStream() not yet implemented."); 95 } 96 public void truncate(long len) throws SQLException { 97 98 throw new java.lang.UnsupportedOperationException ("Method truncate() not yet implemented."); 99 } 100 } 101 | Popular Tags |