~ubuntu-branches/ubuntu/oneiric/libpgjava/oneiric

« back to all changes in this revision

Viewing changes to src/interfaces/jdbc/org/postgresql/jdbc2/AbstractJdbc2Blob.java

  • Committer: Bazaar Package Importer
  • Author(s): Arnaud Vandyck
  • Date: 2005-04-21 14:25:11 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20050421142511-wibh5vc31fkrorx7
Tags: 7.4.7-3
Built with sources...

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package org.postgresql.jdbc2;
 
2
 
 
3
import org.postgresql.PGConnection;
 
4
import org.postgresql.largeobject.LargeObject;
 
5
import org.postgresql.largeobject.LargeObjectManager;
 
6
import java.io.InputStream;
 
7
import java.sql.Blob;
 
8
import java.sql.SQLException;
 
9
 
 
10
public abstract class AbstractJdbc2Blob
 
11
{
 
12
        private int oid;
 
13
        private LargeObject lo;
 
14
 
 
15
        public AbstractJdbc2Blob(PGConnection conn, int oid) throws SQLException
 
16
        {
 
17
                this.oid = oid;
 
18
                LargeObjectManager lom = conn.getLargeObjectAPI();
 
19
                this.lo = lom.open(oid);
 
20
        }
 
21
 
 
22
        public long length() throws SQLException
 
23
        {
 
24
                return lo.size();
 
25
        }
 
26
 
 
27
        public InputStream getBinaryStream() throws SQLException
 
28
        {
 
29
                return lo.getInputStream();
 
30
        }
 
31
 
 
32
        public byte[] getBytes(long pos, int length) throws SQLException
 
33
        {
 
34
                lo.seek((int)pos, LargeObject.SEEK_SET);
 
35
                return lo.read(length);
 
36
        }
 
37
 
 
38
        /*
 
39
         * For now, this is not implemented.
 
40
         */
 
41
        public long position(byte[] pattern, long start) throws SQLException
 
42
        {
 
43
                throw org.postgresql.Driver.notImplemented();
 
44
        }
 
45
 
 
46
        /*
 
47
         * This should be simply passing the byte value of the pattern Blob
 
48
         */
 
49
        public long position(Blob pattern, long start) throws SQLException
 
50
        {
 
51
                return position(pattern.getBytes(0, (int)pattern.length()), start);
 
52
        }
 
53
 
 
54
}