|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.almworks.sqlite4java.SQLiteBlob
public final class SQLiteBlob
SQLiteBlob encapsulates sqlite3_blob*
handle, which represents an open BLOB
(binary large object), stored in a single cell of a table.
SQLiteBlob is created by SQLiteConnection.blob(java.lang.String, java.lang.String, java.lang.String, long, boolean)
method. After application is done using the instance
of SQLiteBlob, it should be disposed with dispose()
method.
You can read or write portions of the stored blob using read(int, byte[], int, int)
and write(int, byte[], int, int)
methods. Note that
you cannot change the size of the blob using this interface.
Methods of this class are not thread-safe and confined to the thread that opened the SQLite connection.
SQLiteConnection.blob(java.lang.String, java.lang.String, java.lang.String, long, boolean)
,
sqlite3_blob_openMethod Summary | |
---|---|
void |
dispose()
Disposes this blob and frees allocated resources. |
int |
getSize()
Returns the size of the open blob. |
boolean |
isDisposed()
Checks if this instance has been disposed |
boolean |
isWriteAllowed()
Returns true if this blob instance was opened for writing. |
void |
read(int blobOffset,
byte[] buffer,
int offset,
int length)
Read bytes from the blob into a buffer. |
void |
reopen(long rowid)
Repositions BLOB to another row in the table. |
java.lang.String |
toString()
|
void |
write(int blobOffset,
byte[] buffer,
int offset,
int length)
Writes bytes into the blob. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Method Detail |
---|
public void dispose()
After blob is disposed, it is no longer usable and holds no references to connection or sqlite db.
public boolean isDisposed()
public int getSize() throws SQLiteException
SQLiteException
- if SQLite returns an error, or if the call violates the contract of this classpublic void read(int blobOffset, byte[] buffer, int offset, int length) throws SQLiteException
blobOffset
and length
should define a sub-range within blob's content. If attempt is
made to read blob beyond its size, an exception is thrown and no data is read.
blobOffset
- the position in the blob where to start readingbuffer
- target bufferoffset
- starting offset in the bufferlength
- number of bytes to read
SQLiteException
- if SQLite returns an error, or if the call violates the contract of this classpublic void write(int blobOffset, byte[] buffer, int offset, int length) throws SQLiteException
Note that you cannot write beyond the current blob's size. The size of the blob
cannot be changed via incremental I/O API. To change the size, you need to use SQLiteStatement.bindZeroBlob(int, int)
method.
Bytes are written within the current transaction.
If blob was not open for writing, an error is thrown.
blobOffset
- the position in the blob where to start writingbuffer
- source bytes bufferoffset
- starting offset in the bufferlength
- number of bytes to write
SQLiteException
- if SQLite returns an error, or if the call violates the contract of this classpublic boolean isWriteAllowed()
write(int, byte[], int, int)
is allowedpublic void reopen(long rowid) throws SQLiteException
rowid
- row id to move to - it must exist and contain data
SQLiteException
- if SQLite returns an error, or if the call violates the contract of this classpublic java.lang.String toString()
toString
in class java.lang.Object
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |