KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > daffodilwoods > daffodildb > server > serversystem > ClobSaveMode


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 JavaDoc 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 JavaDoc 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 JavaDoc 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 JavaDoc(buf);
47     /*
48     long start1 = start + pos;
49     length0 = ( start1 + length0) < (start + length) ?
50               length0 + (int)start1 : (int)(length - pos );
51     byte[] buf = new byte[ length0];
52     int lengthRead =0;
53     long skip = -1;
54     try {
55       InputStream is = new FileInputStream(new File(savedlobFilePath));
56       if(start1!=0)
57         skip = is.skip(start1);
58       lengthRead = is.read(buf,0,length0);
59     }
60     catch (IOException ex) {
61       throw new SQLException(ex.getMessage());
62     }
63     return new String(buf);*/

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 JavaDoc searchstr, long start) throws SQLException {
73     /**@todo Implement this java.sql.Clob method*/
74     throw new java.lang.UnsupportedOperationException JavaDoc("Method position() not yet implemented.");
75   }
76   public long position(Clob searchstr, long start) throws SQLException {
77     /**@todo Implement this java.sql.Clob method*/
78     throw new java.lang.UnsupportedOperationException JavaDoc("Method position() not yet implemented.");
79   }
80   public int setString(long pos, String JavaDoc str) throws SQLException {
81     /**@todo Implement this java.sql.Clob method*/
82     throw new java.lang.UnsupportedOperationException JavaDoc("Method setString() not yet implemented.");
83   }
84   public int setString(long pos, String JavaDoc str, int offset, int len) throws SQLException {
85     /**@todo Implement this java.sql.Clob method*/
86     throw new java.lang.UnsupportedOperationException JavaDoc("Method setString() not yet implemented.");
87   }
88   public OutputStream setAsciiStream(long pos) throws SQLException {
89     /**@todo Implement this java.sql.Clob method*/
90     throw new java.lang.UnsupportedOperationException JavaDoc("Method setAsciiStream() not yet implemented.");
91   }
92   public Writer setCharacterStream(long pos) throws SQLException {
93     /**@todo Implement this java.sql.Clob method*/
94     throw new java.lang.UnsupportedOperationException JavaDoc("Method setCharacterStream() not yet implemented.");
95   }
96   public void truncate(long len) throws SQLException {
97     /**@todo Implement this java.sql.Clob method*/
98     throw new java.lang.UnsupportedOperationException JavaDoc("Method truncate() not yet implemented.");
99   }
100 }
101
Popular Tags