Class HarmonySerialBlob

java.lang.Object
org.apache.derby.iapi.types.HarmonySerialBlob
All Implemented Interfaces:
Serializable, Cloneable, Blob

public class HarmonySerialBlob extends Object implements Blob, Serializable, Cloneable
Copied from the Harmony project's implementation of javax.sql.rowset.serial.SerialBlob at subversion revision 946981.
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private Blob
     
    private byte[]
     
    private long
     
    private long
     
    private static final long
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    HarmonySerialBlob(byte[] buf)
    Constructs an instance by the given buf
    Constructs an instance by the given blob
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    Returns an input stream of this SerialObject.
    getBinaryStream(long pos, long length)
     
    byte[]
    getBytes(long pos, int length)
    Returns a copied array of this SerialObject, starting at the pos with the given length number.
    long
    Gets the number of bytes in this SerialBlob object.
    makeSQLException(String messageID, 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(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.
    setBinaryStream(long pos)
     
    int
    setBytes(long pos, byte[] theBytes)
     
    int
    setBytes(long pos, byte[] theBytes, int offset, int length)
     
    void
    truncate(long length)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • buf

      private byte[] buf
    • blob

      private Blob blob
    • len

      private long len
    • origLen

      private long origLen
  • Constructor Details

    • HarmonySerialBlob

      public HarmonySerialBlob(Blob blob) throws SQLException
      Constructs an instance by the given blob
      Parameters:
      blob - the given blob
      Throws:
      SQLException - if an error is encountered during serialization, or if blob is null
    • HarmonySerialBlob

      public HarmonySerialBlob(byte[] buf)
      Constructs an instance by the given buf
      Parameters:
      buf - the given buffer
  • Method Details

    • getBinaryStream

      public InputStream getBinaryStream() throws SQLException
      Returns an input stream of this SerialObject.
      Specified by:
      getBinaryStream in interface Blob
      Throws:
      SQLException - if an error is encountered
    • getBytes

      public byte[] getBytes(long pos, int length) throws SQLException
      Returns a copied array of this SerialObject, starting at the pos with the given length number. If pos + length - 1 is larger than the length of this SerialObject array, the length will be shortened to the length of array - pos + 1.
      Specified by:
      getBytes in interface Blob
      Parameters:
      pos - the starting position of the array to be copied.
      length - the total length of bytes to be copied
      Throws:
      SQLException - if an error is encountered
    • length

      public long length() throws SQLException
      Gets the number of bytes in this SerialBlob object.
      Specified by:
      length in interface Blob
      Returns:
      an long value with the length of the SerialBlob in bytes
      Throws:
      SQLException - if an error is encoutnered
    • position

      public long position(Blob pattern, long start) throws 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 interface Blob
      Parameters:
      pattern - a Blob containing the pattern of data to search for in this Blob
      start - 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:
      SQLException - if an error occurs accessing the Blob, or if an error is encountered
    • position

      public long position(byte[] pattern, long start) throws 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 interface Blob
      Parameters:
      pattern - a byte array containing the pattern of data to search for in this Blob
      start - 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:
      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 OutputStream setBinaryStream(long pos) throws SQLException
      Specified by:
      setBinaryStream in interface Blob
      Throws:
      SQLException
    • setBytes

      public int setBytes(long pos, byte[] theBytes) throws SQLException
      Specified by:
      setBytes in interface Blob
      Throws:
      SQLException
    • setBytes

      public int setBytes(long pos, byte[] theBytes, int offset, int length) throws SQLException
      Specified by:
      setBytes in interface Blob
      Throws:
      SQLException
    • truncate

      public void truncate(long length) throws SQLException
      Specified by:
      truncate in interface Blob
      Throws:
      SQLException
    • free

      public void free() throws SQLException
      Specified by:
      free in interface Blob
      Throws:
      SQLException
    • getBinaryStream

      public InputStream getBinaryStream(long pos, long length) throws SQLException
      Specified by:
      getBinaryStream in interface Blob
      Throws:
      SQLException
    • makeSQLException

      public static SQLException makeSQLException(String messageID, Object[] args)
      Create a SQLException from Derby message arguments.