~ubuntu-branches/ubuntu/feisty/libpgjava/feisty

« back to all changes in this revision

Viewing changes to src/interfaces/jdbc/org/postgresql/largeobject/PGblob.java

  • Committer: Bazaar Package Importer
  • Author(s): Stefan Gybas
  • Date: 2002-02-06 23:43:06 UTC
  • Revision ID: james.westby@ubuntu.com-20020206234306-hsg7suqr8q56qg40
Tags: upstream-7.2
ImportĀ upstreamĀ versionĀ 7.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package org.postgresql.largeobject;
 
2
 
 
3
// IMPORTANT NOTE: This file implements the JDBC 2 version of the driver.
 
4
// If you make any modifications to this file, you must make sure that the
 
5
// changes are also made (if relevent) to the related JDBC 1 class in the
 
6
// org.postgresql.jdbc1 package.
 
7
 
 
8
 
 
9
import java.lang.*;
 
10
import java.io.*;
 
11
import java.math.*;
 
12
import java.text.*;
 
13
import java.util.*;
 
14
import java.sql.*;
 
15
import org.postgresql.Field;
 
16
import org.postgresql.largeobject.*;
 
17
import org.postgresql.largeobject.*;
 
18
 
 
19
/*
 
20
 * This implements the Blob interface, which is basically another way to
 
21
 * access a LargeObject.
 
22
 *
 
23
 * $Id: PGblob.java,v 1.3 2001/11/19 22:33:39 momjian Exp $
 
24
 *
 
25
 */
 
26
public class PGblob implements java.sql.Blob
 
27
{
 
28
        private org.postgresql.Connection conn;
 
29
        private int oid;
 
30
        private LargeObject lo;
 
31
 
 
32
        public PGblob(org.postgresql.Connection conn, int oid) throws SQLException
 
33
        {
 
34
                this.conn = conn;
 
35
                this.oid = oid;
 
36
                LargeObjectManager lom = conn.getLargeObjectAPI();
 
37
                this.lo = lom.open(oid);
 
38
        }
 
39
 
 
40
        public long length() throws SQLException
 
41
        {
 
42
                return lo.size();
 
43
        }
 
44
 
 
45
        public InputStream getBinaryStream() throws SQLException
 
46
        {
 
47
                return lo.getInputStream();
 
48
        }
 
49
 
 
50
        public byte[] getBytes(long pos, int length) throws SQLException
 
51
        {
 
52
                lo.seek((int)pos, LargeObject.SEEK_SET);
 
53
                return lo.read(length);
 
54
        }
 
55
 
 
56
        /*
 
57
         * For now, this is not implemented.
 
58
         */
 
59
        public long position(byte[] pattern, long start) throws SQLException
 
60
        {
 
61
                throw org.postgresql.Driver.notImplemented();
 
62
        }
 
63
 
 
64
        /*
 
65
         * This should be simply passing the byte value of the pattern Blob
 
66
         */
 
67
        public long position(Blob pattern, long start) throws SQLException
 
68
        {
 
69
                return position(pattern.getBytes(0, (int)pattern.length()), start);
 
70
        }
 
71
 
 
72
}