1 package com.daffodilwoods.daffodildb.server.serversystem; 2 3 import java.io.*; 4 import java.sql.*; 5 6 import com.daffodilwoods.database.resource.*; 7 8 public class BlobSaveMode implements Blob { 9 10 private long start; 11 private int length; 12 private String savedlobFilePath; 13 14 public BlobSaveMode(long start0, int length0, String savedlobFilePath0) throws DException { 15 start = start0; 16 length = length0; 17 savedlobFilePath = savedlobFilePath0+"blob.lob"; 18 } 19 20 public long length() throws SQLException { 21 return length; 22 } 23 24 public byte[] getBytes(long pos, int length0) throws SQLException { 25 26 long start1 = start + pos; 27 length0 = ( start1 + length0) < (start + length) ? 28 length0 + (int)start1 : (int)(length - pos ); 29 byte[] buf = new byte[ length0]; 30 int lengthRead =0; 31 long skip = -1; 32 try { 33 InputStream is = new FileInputStream(new File(savedlobFilePath)); 34 if(start1!=0) 35 skip = is.skip(start1); 36 lengthRead = is.read(buf,0,length0); 37 } 38 catch (IOException ex) { 39 throw new SQLException(ex.getMessage()); 40 } 41 return buf; 42 } 43 44 public InputStream getBinaryStream() throws SQLException { 45 return new ByteArrayInputStream(getBytes(0,length)); 46 } 47 public long position(byte[] pattern, long start) throws SQLException { 48 49 throw new java.lang.UnsupportedOperationException ("Method position() not yet implemented."); 50 } 51 public long position(Blob pattern, long start) throws SQLException { 52 53 throw new java.lang.UnsupportedOperationException ("Method position() not yet implemented."); 54 } 55 public int setBytes(long pos, byte[] bytes) throws SQLException { 56 57 throw new java.lang.UnsupportedOperationException ("Method setBytes() not yet implemented."); 58 } 59 public int setBytes(long pos, byte[] bytes, int offset, int len) throws SQLException { 60 61 throw new java.lang.UnsupportedOperationException ("Method setBytes() not yet implemented."); 62 } 63 public OutputStream setBinaryStream(long pos) throws SQLException { 64 65 throw new java.lang.UnsupportedOperationException ("Method setBinaryStream() not yet implemented."); 66 } 67 public void truncate(long len) throws SQLException { 68 69 throw new java.lang.UnsupportedOperationException ("Method truncate() not yet implemented."); 70 } 71 } 72 | Popular Tags |