Class BlobImpl
- java.lang.Object
-
- org.datanucleus.store.rdbms.mapping.column.BlobImpl
-
- All Implemented Interfaces:
Blob
public class BlobImpl extends Object implements Blob
The representation (mapping) in the Java programming language of an SQL
BLOBvalue. An SQLBLOBis a built-in type that stores a Binary Large Object as a column value in a row of a database table. The driver implementsBlobusing an SQLlocator(BLOB), which means that aBlobobject contains a logical pointer to the SQLBLOBdata rather than the data itself. ABlobobject is valid for the duration of the transaction in which is was created.Methods in the interfaces
ResultSet,CallableStatement, andPreparedStatement, such asgetBlobandsetBloballow a programmer to access an SQLBLOBvalue. TheBlobinterface provides methods for getting the length of an SQLBLOB(Binary Large Object) value, for materializing aBLOBvalue on the client, and for determining the position of a pattern of bytes within aBLOBvalue.
-
-
Constructor Summary
Constructors Constructor Description 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidfree()Free the Blob object and releases the resources that it holds.InputStreamgetBinaryStream()InputStreamgetBinaryStream(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)ObjectgetObject()Accessor for the Object.longlength()longposition(byte[] pattern, long start)longposition(Blob pattern, long start)OutputStreamsetBinaryStream(long value)intsetBytes(long value, byte[] bytes)intsetBytes(long value, byte[] bytes, int pos, int length)voidtruncate(long value)
-
-
-
Constructor Detail
-
BlobImpl
public BlobImpl(Object obj) throws IOException
Constructor taking a serialised object.- Parameters:
obj- The serialised object.- Throws:
IOException- if an error occurs
-
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- if an error occurs
-
length
public long length() throws SQLException- Specified by:
lengthin interfaceBlob- Throws:
SQLException
-
getBytes
public byte[] getBytes(long pos, int length) throws SQLException- Specified by:
getBytesin interfaceBlob- Throws:
SQLException
-
setBytes
public int setBytes(long value, byte[] bytes, int pos, int length) throws SQLException- Specified by:
setBytesin interfaceBlob- Throws:
SQLException
-
truncate
public void truncate(long value) throws SQLException- Specified by:
truncatein interfaceBlob- Throws:
SQLException
-
setBytes
public int setBytes(long value, byte[] bytes) throws SQLException- Specified by:
setBytesin interfaceBlob- Throws:
SQLException
-
getBinaryStream
public InputStream getBinaryStream() throws SQLException
- Specified by:
getBinaryStreamin interfaceBlob- 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:
getBinaryStreamin interfaceBlob- Parameters:
pos- the offset to the first byte of the partial value to be retrieved. The first byte in the Blob is at position 1length- the length in bytes of the partial value to be retrieved- Throws:
SQLException
-
setBinaryStream
public OutputStream setBinaryStream(long value) throws SQLException
- Specified by:
setBinaryStreamin interfaceBlob- Throws:
SQLException
-
free
public void free() throws SQLExceptionFree the Blob object and releases the resources that it holds. The object is invalid once the free method is called.- Specified by:
freein interfaceBlob- Throws:
SQLException- if an error occurs
-
position
public long position(byte[] pattern, long start) throws SQLException- Specified by:
positionin interfaceBlob- Throws:
SQLException
-
position
public long position(Blob pattern, long start) throws SQLException
- Specified by:
positionin interfaceBlob- Throws:
SQLException
-
-