public class MonetBlob extends Object implements Blob, Serializable, Comparable<MonetBlob>
Blob interface. Because
MonetDB/SQL currently has no support for streams, this class is a
shallow wrapper of a byte[]. It is more or less supplied to
enable an application that depends on it to run. It may be obvious
that it is a real resource expensive workaround that contradicts the
benefits for a Blob: avoidance of huge resource consumption.| Constructor and Description |
|---|
MonetBlob(byte[] buf) |
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(MonetBlob o) |
boolean |
equals(Object obj)
Overriding the equals method for the byte array.
|
void |
free()
This method frees the Blob object and releases the resources that it holds.
|
InputStream |
getBinaryStream()
Retrieves the BLOB value designated by this Blob instance as a stream.
|
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[] |
getBuffer() |
byte[] |
getBytes(long pos,
int length)
Retrieves all or part of the BLOB value that this Blob object represents, as an array of bytes.
|
int |
hashCode()
Overriding the hashCode method for the byte array.
|
long |
length()
Returns the number of bytes in the BLOB value designated by this Blob object.
|
long |
position(Blob pattern,
long start)
Retrieves the byte position in the BLOB value designated by this Blob object at which pattern begins.
|
long |
position(byte[] pattern,
long start)
Retrieves the byte position at which the specified byte array pattern begins within the BLOB value that this
Blob object represents.
|
OutputStream |
setBinaryStream(long pos)
Retrieves a stream that can be used to write to the BLOB value
that this Blob object represents.
|
int |
setBytes(long pos,
byte[] bytes)
Writes the given array of bytes to the BLOB value that this Blob
object represents, starting at position pos, and returns the
number of bytes written.
|
int |
setBytes(long pos,
byte[] bytes,
int offset,
int len)
Writes all or part of the given byte array to the BLOB value that
this Blob object represents and returns the number of bytes
written.
|
String |
toString()
Overriding the toString method for the byte array.
|
void |
truncate(long len)
Truncates the BLOB value that this Blob object represents to be len bytes in length.
|
public byte[] getBuffer()
public void free()
throws SQLException
free in interface BlobSQLExceptionpublic InputStream getBinaryStream() throws SQLException
getBinaryStream in interface BlobSQLException - if there is an error accessing the BLOB valuepublic InputStream getBinaryStream(long pos, long length) throws SQLException
getBinaryStream in interface Blobpos - 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 retrievedSQLException - 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 Blobpublic byte[] getBytes(long pos,
int length)
throws SQLException
getBytes in interface Blobpos - the ordinal position of the first byte in the BLOB value to be extracted; the first byte is at
position 1.length - the number of consecutive bytes to be copiedSQLException - if there is an error accessing the BLOB valuepublic long length()
throws SQLException
length in interface BlobSQLException - if there is an error accessing the length of the BLOB valuepublic long position(Blob pattern, long start) throws SQLException
position in interface Blobpattern - the Blob object designating the BLOB value for which to searchstart - the position in the BLOB value at which to begin searching; the first position is 1SQLException - if there is an error accessing the BLOB valuepublic long position(byte[] pattern,
long start)
throws SQLException
position in interface Blobpattern - the byte array for which to searchstart - the position at which to begin searching; the first position is 1SQLException - if there is an error accessing the BLOB valuepublic OutputStream setBinaryStream(long pos) throws SQLException
setBinaryStream in interface Blobpos - the position in the BLOB value at which to start writing; the first position is 1SQLException - if there is an error accessing the BLOB value or if pos is less than 1SQLFeatureNotSupportedException - if the JDBC driver does not support this methodpublic int setBytes(long pos,
byte[] bytes)
throws SQLException
setBytes in interface Blobpos - the position in the BLOB object at which to start writingbytes - the array of bytes to be written to the BLOB value that this Blob object representsSQLException - if there is an error accessing the BLOB valuepublic int setBytes(long pos,
byte[] bytes,
int offset,
int len)
throws SQLException
setBytes in interface Blobpos - the position in the BLOB object at which to start writingbytes - the array of bytes to be written to this BLOB objectoffset - the offset into the array bytes at which to start reading the bytes to be setlen - the number of bytes to be written to the BLOB value from the array of bytes bytesSQLException - if there is an error accessing the BLOB valuepublic void truncate(long len)
throws SQLException
truncate in interface Bloblen - the length, in bytes, to which the BLOB value should be truncatedSQLException - if there is an error accessing the BLOB valuepublic boolean equals(Object obj)
public int hashCode()
public String toString()
public int compareTo(MonetBlob o)
compareTo in interface Comparable<MonetBlob>Copyright © 2017. All rights reserved.