Package org.apache.derby.iapi.types
Class HarmonySerialBlob
- java.lang.Object
-
- org.apache.derby.iapi.types.HarmonySerialBlob
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,java.sql.Blob
public class HarmonySerialBlob extends java.lang.Object implements java.sql.Blob, java.io.Serializable, java.lang.Cloneable
Copied from the Harmony project's implementation of javax.sql.rowset.serial.SerialBlob at subversion revision 946981.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private java.sql.Blob
blob
private byte[]
buf
private long
len
private long
origLen
private static long
serialVersionUID
-
Constructor Summary
Constructors Constructor Description HarmonySerialBlob(byte[] buf)
Constructs an instance by the givenbuf
HarmonySerialBlob(java.sql.Blob blob)
Constructs an instance by the givenblob
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
free()
java.io.InputStream
getBinaryStream()
Returns an input stream of this SerialObject.java.io.InputStream
getBinaryStream(long pos, long length)
byte[]
getBytes(long pos, int length)
Returns a copied array of this SerialObject, starting at thepos
with the givenlength
number.long
length()
Gets the number of bytes in this SerialBlob object.static java.sql.SQLException
makeSQLException(java.lang.String messageID, java.lang.Object[] args)
Create a SQLException from Derby message arguments.private boolean
match(byte[] bytes, int start, byte[] subBytes)
long
position(byte[] pattern, long start)
Search for the position in this Blob at which the specified pattern begins, starting at a specified position within the Blob.long
position(java.sql.Blob pattern, long start)
Search for the position in this Blob at which a specified pattern begins, starting at a specified position within the Blob.java.io.OutputStream
setBinaryStream(long pos)
int
setBytes(long pos, byte[] theBytes)
int
setBytes(long pos, byte[] theBytes, int offset, int length)
void
truncate(long length)
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
buf
private byte[] buf
-
blob
private java.sql.Blob blob
-
len
private long len
-
origLen
private long origLen
-
-
Constructor Detail
-
HarmonySerialBlob
public HarmonySerialBlob(java.sql.Blob blob) throws java.sql.SQLException
Constructs an instance by the givenblob
- Parameters:
blob
- the given blob- Throws:
java.sql.SQLException
- if an error is encountered during serialization, or ifblob
is null
-
HarmonySerialBlob
public HarmonySerialBlob(byte[] buf)
Constructs an instance by the givenbuf
- Parameters:
buf
- the given buffer
-
-
Method Detail
-
getBinaryStream
public java.io.InputStream getBinaryStream() throws java.sql.SQLException
Returns an input stream of this SerialObject.- Specified by:
getBinaryStream
in interfacejava.sql.Blob
- Throws:
java.sql.SQLException
- if an error is encountered
-
getBytes
public byte[] getBytes(long pos, int length) throws java.sql.SQLException
Returns a copied array of this SerialObject, starting at thepos
with the givenlength
number. Ifpos
+length
- 1 is larger than the length of this SerialObject array, thelength
will be shortened to the length of array -pos
+ 1.- Specified by:
getBytes
in interfacejava.sql.Blob
- Parameters:
pos
- the starting position of the array to be copied.length
- the total length of bytes to be copied- Throws:
java.sql.SQLException
- if an error is encountered
-
length
public long length() throws java.sql.SQLException
Gets the number of bytes in this SerialBlob object.- Specified by:
length
in interfacejava.sql.Blob
- Returns:
- an long value with the length of the SerialBlob in bytes
- Throws:
java.sql.SQLException
- if an error is encoutnered
-
position
public long position(java.sql.Blob pattern, long start) throws java.sql.SQLException
Search for the position in this Blob at which a specified pattern begins, starting at a specified position within the Blob.- Specified by:
position
in interfacejava.sql.Blob
- Parameters:
pattern
- a Blob containing the pattern of data to search for in this Blobstart
- the position within this Blob to start the search, where the first position in the Blob is 1- Returns:
- a long value with the position at which the pattern begins. -1 if the pattern is not found in this Blob.
- Throws:
java.sql.SQLException
- if an error occurs accessing the Blob, or if an error is encountered
-
position
public long position(byte[] pattern, long start) throws java.sql.SQLException
Search for the position in this Blob at which the specified pattern begins, starting at a specified position within the Blob.- Specified by:
position
in interfacejava.sql.Blob
- Parameters:
pattern
- a byte array containing the pattern of data to search for in this Blobstart
- the position within this Blob to start the search, where the first position in the Blob is 1- Returns:
- a long value with the position at which the pattern begins. -1 if the pattern is not found in this Blob.
- Throws:
java.sql.SQLException
- if an error is encountered, or if an error occurs accessing the Blob
-
match
private boolean match(byte[] bytes, int start, byte[] subBytes)
-
setBinaryStream
public java.io.OutputStream setBinaryStream(long pos) throws java.sql.SQLException
- Specified by:
setBinaryStream
in interfacejava.sql.Blob
- Throws:
java.sql.SQLException
-
setBytes
public int setBytes(long pos, byte[] theBytes) throws java.sql.SQLException
- Specified by:
setBytes
in interfacejava.sql.Blob
- Throws:
java.sql.SQLException
-
setBytes
public int setBytes(long pos, byte[] theBytes, int offset, int length) throws java.sql.SQLException
- Specified by:
setBytes
in interfacejava.sql.Blob
- Throws:
java.sql.SQLException
-
truncate
public void truncate(long length) throws java.sql.SQLException
- Specified by:
truncate
in interfacejava.sql.Blob
- Throws:
java.sql.SQLException
-
free
public void free() throws java.sql.SQLException
- Specified by:
free
in interfacejava.sql.Blob
- Throws:
java.sql.SQLException
-
getBinaryStream
public java.io.InputStream getBinaryStream(long pos, long length) throws java.sql.SQLException
- Specified by:
getBinaryStream
in interfacejava.sql.Blob
- Throws:
java.sql.SQLException
-
makeSQLException
public static java.sql.SQLException makeSQLException(java.lang.String messageID, java.lang.Object[] args)
Create a SQLException from Derby message arguments.
-
-