org.postgresql.jdbc2
Class AbstractJdbc2BlobClob

java.lang.Object
  extended by org.postgresql.jdbc2.AbstractJdbc2BlobClob
Direct Known Subclasses:
AbstractJdbc2Blob, AbstractJdbc2Clob

public class AbstractJdbc2BlobClob
extends java.lang.Object

This class holds all of the methods common to both Blobs and Clobs.

Author:
Michael Barker

Field Summary
protected  BaseConnection conn
           
protected  LargeObject lo
           
 
Constructor Summary
AbstractJdbc2BlobClob(BaseConnection conn, long oid)
           
 
Method Summary
protected  void assertPosition(long pos)
          Throws an exception if the pos value exceeds the max value by which the large object API can index.
protected  void assertPosition(long pos, long len)
          Throws an exception if the pos value exceeds the max value by which the large object API can index.
protected  void checkFreed()
          Checks that this LOB hasn't been free()d already.
 void free()
           
 java.io.InputStream getBinaryStream()
           
 byte[] getBytes(long pos, int length)
           
 long length()
           
 long position(java.sql.Blob pattern, long start)
          This is simply passing the byte value of the pattern Blob
 long position(byte[] pattern, long start)
          Iterate over the buffer looking for the specified pattern
 java.io.OutputStream setBinaryStream(long pos)
           
 void truncate(long len)
          For Blobs this should be in bytes while for Clobs it should be in characters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

conn

protected BaseConnection conn

lo

protected LargeObject lo
Constructor Detail

AbstractJdbc2BlobClob

public AbstractJdbc2BlobClob(BaseConnection conn,
                             long oid)
                      throws java.sql.SQLException
Throws:
java.sql.SQLException
Method Detail

free

public void free()
          throws java.sql.SQLException
Throws:
java.sql.SQLException

truncate

public void truncate(long len)
              throws java.sql.SQLException
For Blobs this should be in bytes while for Clobs it should be in characters. Since we really haven't figured out how to handle character sets for Clobs the current implementation uses bytes for both Blobs and Clobs.

Throws:
java.sql.SQLException

length

public long length()
            throws java.sql.SQLException
Throws:
java.sql.SQLException

getBytes

public byte[] getBytes(long pos,
                       int length)
                throws java.sql.SQLException
Throws:
java.sql.SQLException

getBinaryStream

public java.io.InputStream getBinaryStream()
                                    throws java.sql.SQLException
Throws:
java.sql.SQLException

setBinaryStream

public java.io.OutputStream setBinaryStream(long pos)
                                     throws java.sql.SQLException
Throws:
java.sql.SQLException

position

public long position(byte[] pattern,
                     long start)
              throws java.sql.SQLException
Iterate over the buffer looking for the specified pattern

Parameters:
pattern - A pattern of bytes to search the blob for.
start - The position to start reading from.
Throws:
java.sql.SQLException

position

public long position(java.sql.Blob pattern,
                     long start)
              throws java.sql.SQLException
This is simply passing the byte value of the pattern Blob

Throws:
java.sql.SQLException

assertPosition

protected void assertPosition(long pos)
                       throws java.sql.SQLException
Throws an exception if the pos value exceeds the max value by which the large object API can index.

Parameters:
pos - Position to write at.
Throws:
java.sql.SQLException

assertPosition

protected void assertPosition(long pos,
                              long len)
                       throws java.sql.SQLException
Throws an exception if the pos value exceeds the max value by which the large object API can index.

Parameters:
pos - Position to write at.
len - number of bytes to write.
Throws:
java.sql.SQLException

checkFreed

protected void checkFreed()
                   throws java.sql.SQLException
Checks that this LOB hasn't been free()d already.

Throws:
java.sql.SQLException - if LOB has been freed.