Package virtuoso.jdbc4

## Class VirtuosoBlob

- java.lang.Object
- - virtuoso.jdbc4.VirtuosoBlob

All Implemented Interfaces:
  `java.sql.Blob`, `java.sql.Clob`, `java.sql.NClob`

Direct Known Subclasses:
  `VirtuosoClob`

    public class VirtuosoBlob
    extends java.lang.Object
    implements java.sql.Blob, java.sql.Clob, java.sql.NClob

The VirtuosoBlob class is an implementation of the Blob interface in the JDBC API that represents a Blob object in SQL.

See Also:
  `Blob`

### Field Summary

Fields
`protected long` `bh_timestamp`
`protected long` `dir_page`
`protected int` `dtp`
`protected long` `frag_no`
`protected long` `key_id`
`protected java.lang.Object` `pages`

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `free​()` This method frees the `Blob` object and releases the resources that it holds.
`java.io.InputStream` `getAsciiStream​()` Gets the `CLOB` value designated by this `Clob` object as a stream of Ascii bytes.
`java.io.InputStream` `getBinaryStream​()` Retrieves the `BLOB` designated by this `Blob` instance as a stream.
`java.io.InputStream` `getBinaryStream​(long pos, long len)` 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)` Returns as an array of bytes part or all of the `BLOB` value that this `Blob` object designates.
`java.io.Reader` `getCharacterStream​()` Gets the `Clob` contents as a Unicode stream.
`java.io.Reader` `getCharacterStream​(long pos, long len)`
`java.lang.String` `getSubString​(long pos, int length)` Returns a copy of the specified substring in the `CLOB` value designated by this `Clob` object.
`int` `hashCode​()` Returns a hash code value for the object.
`long` `length​()` Returns the number of bytes in the BLOB value designated by this Blob object.
`long` `position​(byte[] pattern, long start)` Determines the byte position at which the specified byte `pattern` begins within the `BLOB` value that this `Blob` object represents.
`long` `position​(java.lang.String searchstr, long start)` Determines the character position at which the specified substring `searchstr` appears in the `CLOB`.
`long` `position​(java.sql.Blob pattern, long start)` Determines the byte position in the `BLOB` value designated by this `Blob` object at which `pattern` begins.
`long` `position​(java.sql.Clob searchstr, long start)` Determines the character position at which the specified `Clob` object `searchstr` appears in this `Clob` object.
`java.io.OutputStream` `setAsciiStream​(long pos)`
`java.io.OutputStream` `setBinaryStream​(long pos)`
`int` `setBytes​(long pos, byte[] bytes)`
`int` `setBytes​(long pos, byte[] bytes, int offset, int len)`
`java.io.Writer` `setCharacterStream​(long pos)`
`protected void` `setInputStream​(java.io.InputStream is, long length)` Set the input stream.
`protected void` `setObject​(java.lang.Object obj)` Set the object.
`protected void` `setReader​(java.io.Reader rd, long length)` Set the reader.
`int` `setString​(long pos, java.lang.String str)`
`int` `setString​(long pos, java.lang.String str, int offset, int len)`
`java.lang.String` `toString​()` Returns th String of the object.
`void` `truncate​(long len)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait`

### Field Detail

#### dtp

    protected int dtp

#### key_id

    protected long key_id

#### frag_no

    protected long frag_no

#### dir_page

    protected long dir_page

#### bh_timestamp

    protected long bh_timestamp

#### pages

    protected java.lang.Object pages

### Method Detail

#### setInputStream

    protected void setInputStream​(java.io.InputStream is,
                                  long length)

Set the input stream.

Parameters:
  `is` - The new InputStream to consider.
  `length` - And its new length.

#### setReader

    protected void setReader​(java.io.Reader rd,
                             long length)

Set the reader.

Parameters:
  `rd` - The new Reader to consider.
  `length` - And its new length.

#### setObject

    protected void setObject​(java.lang.Object obj)

Set the object.

Parameters:
  `obj` - The new Object to consider.

#### getBytes

    public byte[] getBytes​(long pos,
                           int length)
                    throws VirtuosoException

Returns as an array of bytes part or all of the `BLOB` value that this `Blob` object designates. The byte array contains up to `length` consecutive bytes starting at position `pos`.

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
  `length` - is the number of consecutive bytes to be copied
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:
  `VirtuosoException` - An internal error occurred.

#### getSubString

    public java.lang.String getSubString​(long pos,
                                         int length)
                                  throws VirtuosoException

Returns a copy of the specified substring in the `CLOB` value designated by this `Clob` object. The substring begins at position `pos` and has up to `length` consecutive characters.

Specified by:
  `getSubString` in interface `java.sql.Clob`
Parameters:
  `pos` - the first character of the substring to be extracted. The first character is at position 1.
  `length` - the number of consecutive characters to be copied
Returns:
  a `String` that is the specified substring in the `CLOB` value designated by this `Clob` object
Throws:
  `VirtuosoException` - An internal error occurred.

#### length

    public long length​()
                throws VirtuosoException

Returns the number of bytes in the BLOB value designated by this Blob object.

Specified by:
  `length` in interface `java.sql.Blob`
Specified by:
  `length` in interface `java.sql.Clob`
Returns:
  long The length of the BLOB in bytes.
Throws:
  `VirtuosoException` - An internal error occurred.

#### getBinaryStream

    public java.io.InputStream getBinaryStream​()
                                        throws VirtuosoException

Retrieves the `BLOB` designated by this `Blob` instance as a stream.

Specified by:
  `getBinaryStream` in interface `java.sql.Blob`
Returns:
  a stream containing the `BLOB` data
Throws:
  `VirtuosoException` - An internal error occurred.

#### getCharacterStream

    public java.io.Reader getCharacterStream​()
                                      throws VirtuosoException

Gets the `Clob` contents as a Unicode stream.

Specified by:
  `getCharacterStream` in interface `java.sql.Clob`
Returns:
  a Unicode stream containing the `CLOB` data
Throws:
  `VirtuosoException` - An internal error occurred.

#### getAsciiStream

    public java.io.InputStream getAsciiStream​()
                                       throws VirtuosoException

Gets the `CLOB` value designated by this `Clob` object as a stream of Ascii bytes.

Specified by:
  `getAsciiStream` in interface `java.sql.Clob`
Returns:
  an ascii stream containing the `CLOB` data
Throws:
  `VirtuosoException` - An internal error occurred.

#### position

    public long position​(byte[] pattern,
                         long start)
                  throws VirtuosoException

Determines the byte position at which the specified byte `pattern` begins within the `BLOB` value that this `Blob` object represents. The search for `pattern`. begins at position `start`.

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:
  `VirtuosoException` - An internal error occurred.

#### position

    public long position​(java.sql.Blob pattern,
                         long start)
                  throws VirtuosoException

Determines the byte position in the `BLOB` value designated by this `Blob` object at which `pattern` begins. The search begins at position `start`.

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:
  `VirtuosoException` - An internal error occurred.

#### position

    public long position​(java.lang.String searchstr,
                         long start)
                  throws VirtuosoException

Determines the character position at which the specified substring `searchstr` appears in the `CLOB`. The search begins at position `start`.

Specified by:
  `position` in interface `java.sql.Clob`
Parameters:
  `searchstr` - the substring for which to search
  `start` - the position at which to begin searching; the first position is 1
Returns:
  the position at which the substring appears, else -1; the first position is 1
Throws:
  `VirtuosoException` - An internal error occurred.

#### position

    public long position​(java.sql.Clob searchstr,
                         long start)
                  throws VirtuosoException

Determines the character position at which the specified `Clob` object `searchstr` appears in this `Clob` object. The search begins at position `start`.

Specified by:
  `position` in interface `java.sql.Clob`
Parameters:
  `searchstr` - the `Clob` object for which to search
  `start` - the position at which to begin searching; the first position is 1
Returns:
  the position at which the `Clob` object appears, else -1; the first position is 1
Throws:
  `VirtuosoException` - An internal error occurred.

#### hashCode

    public int hashCode​()

Returns a hash code value for the object.

Overrides:
  `hashCode` in class `java.lang.Object`
Returns:
  int The hash code value.

#### toString

    public java.lang.String toString​()

Returns th String of the object.

Overrides:
  `toString` in class `java.lang.Object`
Returns:
  String The string value.

#### setString

    public int setString​(long pos,
                         java.lang.String str,
                         int offset,
                         int len)
                  throws java.sql.SQLException

Specified by:
  `setString` in interface `java.sql.Clob`
Throws:
  `java.sql.SQLException`

#### setString

    public int setString​(long pos,
                         java.lang.String str)
                  throws java.sql.SQLException

Specified by:
  `setString` in interface `java.sql.Clob`
Throws:
  `java.sql.SQLException`

#### setAsciiStream

    public java.io.OutputStream setAsciiStream​(long pos)
                                        throws java.sql.SQLException

Specified by:
  `setAsciiStream` in interface `java.sql.Clob`
Throws:
  `java.sql.SQLException`

#### setCharacterStream

    public java.io.Writer setCharacterStream​(long pos)
                                      throws java.sql.SQLException

Specified by:
  `setCharacterStream` in interface `java.sql.Clob`
Throws:
  `java.sql.SQLException`

#### truncate

    public void truncate​(long len)
                  throws java.sql.SQLException

Specified by:
  `truncate` in interface `java.sql.Blob`
Specified by:
  `truncate` in interface `java.sql.Clob`
Throws:
  `java.sql.SQLException`

#### setBytes

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

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

#### setBytes

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

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

#### setBinaryStream

    public java.io.OutputStream setBinaryStream​(long pos)
                                         throws java.sql.SQLException

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

#### getBinaryStream

    public java.io.InputStream getBinaryStream​(long pos,
                                               long len)
                                        throws java.sql.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 `java.sql.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
  `len` - the length in bytes of the partial value to be retrieved
Returns:
  `InputStream` through which the partial `Blob` value can be read.
Throws:
  `java.sql.SQLException` - if pos is less than 1 or if pos is greater than the number of bytes in the `Blob` or if pos + length is greater than the number of bytes in the `Blob`
  `java.sql.SQLFeatureNotSupportedException` - if the JDBC driver does not support this method
Since:
  1.6

#### free

    public void free​()
              throws java.sql.SQLException

This method frees the `Blob` object and releases the resources that it holds. The object is invalid once the `free` method is called.

After `free` has been called, any attempt to invoke a method other than `free` will result in a `SQLException` being thrown. If `free` is called multiple times, the subsequent calls to `free` are treated as a no-op.

Specified by:
  `free` in interface `java.sql.Blob`
Specified by:
  `free` in interface `java.sql.Clob`
Throws:
  `java.sql.SQLException` - if an error occurs releasing the Blob's resources
  `java.sql.SQLFeatureNotSupportedException` - if the JDBC driver does not support this method
Since:
  1.6

#### getCharacterStream

    public java.io.Reader getCharacterStream​(long pos,
                                             long len)
                                      throws java.sql.SQLException

Specified by:
  `getCharacterStream` in interface `java.sql.Clob`
Throws:
  `java.sql.SQLException`