KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > lob > SerializableClob


1 //$Id: SerializableClob.java,v 1.1 2005/03/02 11:43:35 oneovthafew Exp $
2
package org.hibernate.lob;
3
4 import java.io.InputStream JavaDoc;
5 import java.io.OutputStream JavaDoc;
6 import java.io.Reader JavaDoc;
7 import java.io.Serializable JavaDoc;
8 import java.io.Writer JavaDoc;
9 import java.sql.Clob JavaDoc;
10 import java.sql.SQLException JavaDoc;
11
12 /**
13  * @author Gavin King
14  */

15 public class SerializableClob implements Serializable JavaDoc, Clob JavaDoc {
16
17     private transient final Clob JavaDoc clob;
18     
19     public SerializableClob(Clob JavaDoc blob) {
20         this.clob = blob;
21     }
22
23     public Clob JavaDoc getWrappedClob() {
24         if ( clob==null ) {
25             throw new IllegalStateException JavaDoc("Clobs may not be accessed after serialization");
26         }
27         else {
28             return clob;
29         }
30     }
31     
32     public long length() throws SQLException JavaDoc {
33         return getWrappedClob().length();
34     }
35
36     public String JavaDoc getSubString(long pos, int length) throws SQLException JavaDoc {
37         return getWrappedClob().getSubString(pos, length);
38     }
39
40     public Reader JavaDoc getCharacterStream() throws SQLException JavaDoc {
41         return getWrappedClob().getCharacterStream();
42     }
43
44     public InputStream JavaDoc getAsciiStream() throws SQLException JavaDoc {
45         return getWrappedClob().getAsciiStream();
46     }
47
48     public long position(String JavaDoc searchstr, long start) throws SQLException JavaDoc {
49         return getWrappedClob().position(searchstr, start);
50     }
51
52     public long position(Clob JavaDoc searchstr, long start) throws SQLException JavaDoc {
53         return getWrappedClob().position(searchstr, start);
54     }
55
56     public int setString(long pos, String JavaDoc str) throws SQLException JavaDoc {
57         return getWrappedClob().setString(pos, str);
58     }
59
60     public int setString(long pos, String JavaDoc str, int offset, int len) throws SQLException JavaDoc {
61         return getWrappedClob().setString(pos, str, offset, len);
62     }
63
64     public OutputStream JavaDoc setAsciiStream(long pos) throws SQLException JavaDoc {
65         return getWrappedClob().setAsciiStream(pos);
66     }
67
68     public Writer JavaDoc setCharacterStream(long pos) throws SQLException JavaDoc {
69         return getWrappedClob().setCharacterStream(pos);
70     }
71
72     public void truncate(long len) throws SQLException JavaDoc {
73         getWrappedClob().truncate(len);
74     }
75
76 }
77
Popular Tags