KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > db > sql > ClobImpl


1 /*
2  * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  *
23  * Free Software Foundation, Inc.
24  * 59 Temple Place, Suite 330
25  * Boston, MA 02111-1307 USA
26  *
27  * @author Scott Ferguson
28  */

29 package com.caucho.db.sql;
30
31 import com.caucho.db.store.BlobInputStream;
32 import com.caucho.db.store.Store;
33 import com.caucho.util.L10N;
34
35 import java.io.InputStream JavaDoc;
36 import java.io.OutputStream JavaDoc;
37 import java.io.Reader JavaDoc;
38 import java.io.Writer JavaDoc;
39 import java.sql.Clob JavaDoc;
40 import java.sql.SQLException JavaDoc;
41
42 /**
43  * The JDBC clob implementation.
44  */

45 public class ClobImpl implements java.sql.Clob JavaDoc {
46   private static final L10N L = new L10N(ClobImpl.class);
47
48   private Store _store;
49   private byte []_inode = new byte[128];
50     
51   ClobImpl()
52   {
53   }
54
55   void setStore(Store store)
56   {
57     _store = store;
58   }
59
60   byte []getInode()
61   {
62     return _inode;
63   }
64
65   /**
66    * Returns the clob as a stream.
67    */

68   public InputStream getAsciiStream()
69     throws SQLException JavaDoc
70   {
71     // XXX: lie, since this is utf8
72
return new BlobInputStream(_store, _inode, 0);
73   }
74
75   /**
76    * Returns a subset of the bytes.
77    */

78   public Reader JavaDoc getCharacterStream()
79     throws SQLException JavaDoc
80   {
81     throw new UnsupportedOperationException JavaDoc();
82   }
83
84   /**
85    * Returns a copy of the specified substring.
86    */

87   public String JavaDoc getSubString(long pos, int length)
88     throws SQLException JavaDoc
89   {
90     throw new UnsupportedOperationException JavaDoc();
91   }
92
93   /**
94    * Returns the length of the clob
95    */

96   public long length()
97     throws SQLException JavaDoc
98   {
99     return BlobInputStream.readLong(_inode, 0);
100   }
101
102   /**
103    * Returns the position in the clob where the pattern starts.
104    */

105   public long position(Clob JavaDoc pattern, long start)
106     throws SQLException JavaDoc
107   {
108     throw new UnsupportedOperationException JavaDoc();
109   }
110
111   /**
112    * Returns the position in the clob where the pattern starts.
113    */

114   public long position(String JavaDoc pattern, long start)
115     throws SQLException JavaDoc
116   {
117     throw new UnsupportedOperationException JavaDoc();
118   }
119
120   /**
121    * Returns a stream to write to the clob.
122    */

123   public OutputStream JavaDoc setAsciiStream(long pos)
124     throws SQLException JavaDoc
125   {
126     throw new UnsupportedOperationException JavaDoc();
127   }
128
129   /**
130    * Returns a stream to write to the clob.
131    */

132   public Writer JavaDoc setCharacterStream(long pos)
133     throws SQLException JavaDoc
134   {
135     throw new UnsupportedOperationException JavaDoc();
136   }
137
138   /**
139    * Sets a subset of bytes.
140    */

141   public int setString(long pos, String JavaDoc string)
142     throws SQLException JavaDoc
143   {
144     throw new UnsupportedOperationException JavaDoc();
145   }
146
147   /**
148    * Sets a subset of bytes.
149    */

150   public int setString(long pos, String JavaDoc string, int offset, int len)
151     throws SQLException JavaDoc
152   {
153     throw new UnsupportedOperationException JavaDoc();
154   }
155
156   /**
157    * Truncates the clob
158    */

159   public void truncate(long length)
160     throws SQLException JavaDoc
161   {
162     throw new UnsupportedOperationException JavaDoc();
163   }
164
165   public String JavaDoc toString()
166   {
167     return "ClobImpl[]";
168   }
169 }
170
Popular Tags