01: //$Id: SerializableClob.java 5986 2005-03-02 11:43:36Z oneovthafew $
02: package org.hibernate.lob;
03:
04: import java.io.InputStream;
05: import java.io.OutputStream;
06: import java.io.Reader;
07: import java.io.Serializable;
08: import java.io.Writer;
09: import java.sql.Clob;
10: import java.sql.SQLException;
11:
12: /**
13: * @author Gavin King
14: */
15: public class SerializableClob implements Serializable, Clob {
16:
17: private transient final Clob clob;
18:
19: public SerializableClob(Clob blob) {
20: this .clob = blob;
21: }
22:
23: public Clob getWrappedClob() {
24: if (clob == null) {
25: throw new IllegalStateException(
26: "Clobs may not be accessed after serialization");
27: } else {
28: return clob;
29: }
30: }
31:
32: public long length() throws SQLException {
33: return getWrappedClob().length();
34: }
35:
36: public String getSubString(long pos, int length)
37: throws SQLException {
38: return getWrappedClob().getSubString(pos, length);
39: }
40:
41: public Reader getCharacterStream() throws SQLException {
42: return getWrappedClob().getCharacterStream();
43: }
44:
45: public InputStream getAsciiStream() throws SQLException {
46: return getWrappedClob().getAsciiStream();
47: }
48:
49: public long position(String searchstr, long start)
50: throws SQLException {
51: return getWrappedClob().position(searchstr, start);
52: }
53:
54: public long position(Clob searchstr, long start)
55: throws SQLException {
56: return getWrappedClob().position(searchstr, start);
57: }
58:
59: public int setString(long pos, String str) throws SQLException {
60: return getWrappedClob().setString(pos, str);
61: }
62:
63: public int setString(long pos, String str, int offset, int len)
64: throws SQLException {
65: return getWrappedClob().setString(pos, str, offset, len);
66: }
67:
68: public OutputStream setAsciiStream(long pos) throws SQLException {
69: return getWrappedClob().setAsciiStream(pos);
70: }
71:
72: public Writer setCharacterStream(long pos) throws SQLException {
73: return getWrappedClob().setCharacterStream(pos);
74: }
75:
76: public void truncate(long len) throws SQLException {
77: getWrappedClob().truncate(len);
78: }
79:
80: }
|