Class 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 given buf
      HarmonySerialBlob​(java.sql.Blob blob)
      Constructs an instance by the given blob
    • 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 the pos with the given length 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)  
      • Methods inherited from class java.lang.Object

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

      • 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 given blob
        Parameters:
        blob - the given blob
        Throws:
        java.sql.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 Detail

      • getBinaryStream

        public java.io.InputStream getBinaryStream()
                                            throws java.sql.SQLException
        Returns an input stream of this SerialObject.
        Specified by:
        getBinaryStream in interface java.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 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 java.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 interface java.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 interface java.sql.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:
        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 interface java.sql.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:
        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 interface java.sql.Blob
        Throws:
        java.sql.SQLException
      • setBytes

        public int setBytes​(long pos,
                            byte[] theBytes)
                     throws java.sql.SQLException
        Specified by:
        setBytes in interface java.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 interface java.sql.Blob
        Throws:
        java.sql.SQLException
      • truncate

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

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

        public java.io.InputStream getBinaryStream​(long pos,
                                                   long length)
                                            throws java.sql.SQLException
        Specified by:
        getBinaryStream in interface java.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.