org.sqlite.jdbc
Class JdbcBlob

java.lang.Object
  extended by org.sqlite.jdbc.JdbcBlob
All Implemented Interfaces:
java.sql.Blob

public class JdbcBlob
extends java.lang.Object
implements java.sql.Blob


Constructor Summary
JdbcBlob(Statement stmt, int columnIndex)
          default constructor.
 
Method Summary
 void close()
          Closes this BLOB object.
 BlobInputStream getBinaryStream()
          Retrieves the BLOB value designated by this Blob instance as a stream.
 byte[] getBytes(long pos, int len)
          Retrieves all or part of the BLOB value that this Blob object represents, as an array of bytes.
 boolean isClosed()
          Retrieves whether this BLOB object has been closed.
 long length()
          Returns the number of bytes in the BLOB value designated by this Blob object.
 long position(java.sql.Blob pattern, long start)
          invoke position(byte[], long) method.
 long position(byte[] pattern, long start)
          Retrieves by the Boyer-Moore algorithm.
 java.io.OutputStream setBinaryStream(long pos)
          Not supporetd yet.
 int setBytes(long pos, byte[] bytes)
          Not supporetd yet.
 int setBytes(long pos, byte[] bytes, int offset, int len)
          Not supporetd yet.
 void truncate(long len)
          Not supporetd yet.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JdbcBlob

public JdbcBlob(Statement stmt,
                int columnIndex)
         throws java.sql.SQLException
default constructor.

Parameters:
stmt - the owner Statement object
columnIndex - the first column is 1, the second is 2, ...
Throws:
java.sql.SQLException - When the columnIndex is not valid. When this method is called on a closed connection.
See Also:
Statement.getBlob(int), Statement.getByteLength(int)
Method Detail

length

public long length()
            throws java.sql.SQLException
Returns the number of bytes in the BLOB value designated by this Blob object.

Specified by:
length in interface java.sql.Blob
Returns:
length of the BLOB in bytes
Throws:
java.sql.SQLException - SQLException is not generated.

getBytes

public byte[] getBytes(long pos,
                       int len)
                throws java.sql.SQLException
Retrieves all or part of the BLOB value that this Blob object represents, as an array of bytes.

Specified by:
getBytes in interface java.sql.Blob
Parameters:
pos - the ordinal position of the first byte in the BLOB value to be extracted; the first byte is at position 1
len - the number of consecutive bytes to be copied; the value for length must be 0 or greater
Returns:
a byte array containing up to length consecutive bytes from the BLOB value designated by this Blob object, starting with the byte at position pos
Throws:
java.sql.SQLException - When this method is called on a closed connection. When pos is less than 1 or length is less than 0

getBinaryStream

public BlobInputStream getBinaryStream()
                                throws java.sql.SQLException
Retrieves the BLOB value designated by this Blob instance as a stream.

Specified by:
getBinaryStream in interface java.sql.Blob
Returns:
a stream containing the BLOB data
Throws:
java.sql.SQLException - SQLException is not generated.

position

public long position(byte[] pattern,
                     long start)
              throws java.sql.SQLException
Retrieves by the Boyer-Moore algorithm.

Specified by:
position in interface java.sql.Blob
Parameters:
pattern - the byte array for which to search
start - the position at which to begin searching; the first position is 1
Returns:
the position at which the pattern appears, else -1
Throws:
java.sql.SQLException - When this method is called on a closed connection.
See Also:
Boyer-Moore algorithm, getBytes(long, int)

position

public long position(java.sql.Blob pattern,
                     long start)
              throws java.sql.SQLException
invoke position(byte[], long) method.

Specified by:
position in interface java.sql.Blob
Parameters:
pattern - the Blob object designating the BLOB value for which to search
start - the position in the BLOB value at which to begin searching; the first position is 1
Returns:
the position at which the pattern begins, else -1
Throws:
java.sql.SQLException - When this method is called on a closed connection.
See Also:
position(byte[], long)

setBytes

public int setBytes(long pos,
                    byte[] bytes)
             throws java.sql.SQLException
Not supporetd yet.

Specified by:
setBytes in interface java.sql.Blob
Throws:
java.lang.UnsupportedOperationException
java.sql.SQLException

setBytes

public int setBytes(long pos,
                    byte[] bytes,
                    int offset,
                    int len)
             throws java.sql.SQLException
Not supporetd yet.

Specified by:
setBytes in interface java.sql.Blob
Throws:
java.lang.UnsupportedOperationException
java.sql.SQLException

setBinaryStream

public java.io.OutputStream setBinaryStream(long pos)
                                     throws java.sql.SQLException
Not supporetd yet.

Specified by:
setBinaryStream in interface java.sql.Blob
Throws:
java.lang.UnsupportedOperationException
java.sql.SQLException

truncate

public void truncate(long len)
              throws java.sql.SQLException
Not supporetd yet.

Specified by:
truncate in interface java.sql.Blob
Throws:
java.lang.UnsupportedOperationException
java.sql.SQLException

close

public void close()
Closes this BLOB object.


isClosed

public boolean isClosed()
Retrieves whether this BLOB object has been closed.

Returns:
true if this BLOB object is closed. false if it is still open.