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
BLOB
value. An SQLBLOB
is a built-in type that stores a Binary Large Object as a column value in a row of a database table. The driver implementsBlob
using an SQLlocator(BLOB)
, which means that aBlob
object contains a logical pointer to the SQLBLOB
data rather than the data itself. ABlob
object is valid for the duration of the transaction in which is was created.Methods in the interfaces
ResultSet
,CallableStatement
, andPreparedStatement
, such asgetBlob
andsetBlob
allow a programmer to access an SQLBLOB
value. TheBlob
interface provides methods for getting the length of an SQLBLOB
(Binary Large Object) value, for materializing aBLOB
value on the client, and for determining the position of a pattern of bytes within aBLOB
value.
-
-
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 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(byte[] pattern, long start)
long
position(Blob 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)
-
-
-
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:
length
in interfaceBlob
- Throws:
SQLException
-
getBytes
public byte[] getBytes(long pos, int length) throws SQLException
- Specified by:
getBytes
in interfaceBlob
- Throws:
SQLException
-
setBytes
public int setBytes(long value, byte[] bytes, int pos, int length) throws SQLException
- Specified by:
setBytes
in interfaceBlob
- Throws:
SQLException
-
truncate
public void truncate(long value) throws SQLException
- Specified by:
truncate
in interfaceBlob
- Throws:
SQLException
-
setBytes
public int setBytes(long value, byte[] bytes) throws SQLException
- Specified by:
setBytes
in interfaceBlob
- Throws:
SQLException
-
getBinaryStream
public InputStream getBinaryStream() throws SQLException
- Specified by:
getBinaryStream
in 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:
getBinaryStream
in 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:
setBinaryStream
in interfaceBlob
- 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 interfaceBlob
- Throws:
SQLException
- if an error occurs
-
position
public long position(byte[] pattern, long start) throws SQLException
- Specified by:
position
in interfaceBlob
- Throws:
SQLException
-
position
public long position(Blob pattern, long start) throws SQLException
- Specified by:
position
in interfaceBlob
- Throws:
SQLException
-
-