KickJava   Java API By Example, From Geeks To Geeks.

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


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.sql.Blob JavaDoc;
38 import java.sql.SQLException JavaDoc;
39
40 /**
41  * The JDBC blob implementation.
42  */

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

66   public InputStream getBinaryStream()
67     throws SQLException JavaDoc
68   {
69     return new BlobInputStream(_store, _inode, 0);
70   }
71
72   /**
73    * Returns a subset of the bytes.
74    */

75   public byte []getBytes(long pos, int length)
76     throws SQLException JavaDoc
77   {
78     throw new UnsupportedOperationException JavaDoc();
79   }
80
81   /**
82    * Returns the length of the blob
83    */

84   public long length()
85     throws SQLException JavaDoc
86   {
87     return BlobInputStream.readLong(_inode, 0);
88   }
89
90   /**
91    * Returns the position in the blob where the pattern starts.
92    */

93   public long position(Blob JavaDoc pattern, long start)
94     throws SQLException JavaDoc
95   {
96     throw new UnsupportedOperationException JavaDoc();
97   }
98
99   /**
100    * Returns the position in the blob where the pattern starts.
101    */

102   public long position(byte []pattern, long start)
103     throws SQLException JavaDoc
104   {
105     throw new UnsupportedOperationException JavaDoc();
106   }
107
108   /**
109    * Returns a stream to write to the blob.
110    */

111   public OutputStream JavaDoc setBinaryStream(long pos)
112     throws SQLException JavaDoc
113   {
114     throw new UnsupportedOperationException JavaDoc();
115   }
116
117   /**
118    * Sets a subset of bytes.
119    */

120   public int setBytes(long pos, byte []bytes)
121     throws SQLException JavaDoc
122   {
123     return setBytes(pos, bytes, 0, bytes.length);
124   }
125
126   /**
127    * Sets a subset of bytes.
128    */

129   public int setBytes(long pos, byte []bytes, int offset, int length)
130     throws SQLException JavaDoc
131   {
132     throw new UnsupportedOperationException JavaDoc();
133   }
134
135   /**
136    * Truncates the blob
137    */

138   public void truncate(long length)
139     throws SQLException JavaDoc
140   {
141     throw new UnsupportedOperationException JavaDoc();
142   }
143
144   public String JavaDoc toString()
145   {
146     return "BlobImpl[]";
147   }
148 }
149
Popular Tags