org.datanucleus.store.rdbms.datatype
Class BlobImpl

java.lang.Object
  extended by org.datanucleus.store.rdbms.datatype.BlobImpl
All Implemented Interfaces:
Blob

public class BlobImpl
extends Object
implements Blob

The representation (mapping) in the Java TM programming language of an SQL BLOB value. An SQL BLOB is a built-in type that stores a Binary Large Object as a column value in a row of a database table. The driver implements Blob using an SQL locator(BLOB), which means that a Blob object contains a logical pointer to the SQL BLOB data rather than the data itself. A Blob object is valid for the duration of the transaction in which is was created.

Methods in the interfaces ResultSet, CallableStatement, and PreparedStatement, such as getBlob and setBlob allow a programmer to access an SQL BLOB value. The Blob interface provides methods for getting the length of an SQL BLOB (Binary Large Object) value, for materializing a BLOB value on the client, and for determining the position of a pattern of bytes within a BLOB value.

This class is new in the JDBC 2.0 API.


Constructor Summary
BlobImpl(byte[] bytes)
          Constructor taking a byte array.
BlobImpl(InputStream stream)
          Constructor taking an InputStream.
BlobImpl(Object obj)
          Constructor taking a serialised object.
 
Method Summary
 void free()
          Free the Blob object and releases the resources that it holds.
 InputStream getBinaryStream()
           
 InputStream getBinaryStream(long pos, long length)
          Returns an InputStream object that contains a partial Blob value, starting with the byte specified by pos, which is length bytes in length.
 byte[] getBytes(long pos, int length)
           
 Object getObject()
          Accessor for the Object.
 long length()
           
 long position(Blob pattern, long start)
           
 long position(byte[] pattern, long start)
           
 OutputStream setBinaryStream(long value)
           
 int setBytes(long value, byte[] bytes)
           
 int setBytes(long value, byte[] bytes, int pos, int length)
           
 void truncate(long value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BlobImpl

public BlobImpl(Object obj)
         throws IOException
Constructor taking a serialised object.

Parameters:
obj - The serialised object.
Throws:
IOException

BlobImpl

public BlobImpl(byte[] bytes)
Constructor taking a byte array.

Parameters:
bytes - The byte array

BlobImpl

public BlobImpl(InputStream stream)
Constructor taking an InputStream.

Parameters:
stream - The InputStream
Method Detail

getObject

public Object getObject()
                 throws SQLException
Accessor for the Object.

Returns:
The object.
Throws:
SQLException

length

public long length()
            throws SQLException
Specified by:
length in interface Blob
Throws:
SQLException

getBytes

public byte[] getBytes(long pos,
                       int length)
                throws SQLException
Specified by:
getBytes in interface Blob
Throws:
SQLException

setBytes

public int setBytes(long value,
                    byte[] bytes,
                    int pos,
                    int length)
             throws SQLException
Specified by:
setBytes in interface Blob
Throws:
SQLException

truncate

public void truncate(long value)
              throws SQLException
Specified by:
truncate in interface Blob
Throws:
SQLException

setBytes

public int setBytes(long value,
                    byte[] bytes)
             throws SQLException
Specified by:
setBytes in interface Blob
Throws:
SQLException

getBinaryStream

public InputStream getBinaryStream()
                            throws SQLException
Specified by:
getBinaryStream in interface Blob
Throws:
SQLException

getBinaryStream

public InputStream getBinaryStream(long pos,
                                   long length)
                            throws SQLException
Returns an InputStream object that contains a partial Blob value, starting with the byte specified by pos, which is length bytes in length.

Specified by:
getBinaryStream in interface Blob
Parameters:
pos - the offset to the first byte of the partial value to be retrieved. The first byte in the Blob is at position 1
length - the length in bytes of the partial value to be retrieved
Throws:
SQLException

setBinaryStream

public OutputStream setBinaryStream(long value)
                             throws SQLException
Specified by:
setBinaryStream in interface Blob
Throws:
SQLException

free

public void free()
          throws SQLException
Free the Blob object and releases the resources that it holds. The object is invalid once the free method is called.

Specified by:
free in interface Blob
Throws:
SQLException

position

public long position(byte[] pattern,
                     long start)
              throws SQLException
Specified by:
position in interface Blob
Throws:
SQLException

position

public long position(Blob pattern,
                     long start)
              throws SQLException
Specified by:
position in interface Blob
Throws:
SQLException


Copyright © 2012. All Rights Reserved.