Class BlobProxy

  • All Implemented Interfaces:
    java.sql.Blob, BlobImplementer

    public final class BlobProxy
    extends java.lang.Object
    implements java.sql.Blob, BlobImplementer
    Manages aspects of representing Blob objects. In previous versions this used to be implemented by using a java.lang.reflect.Proxy to deal with incompatibilities across various JDBC versions, hence the class name, but using a real Proxy is no longer necessary. The class name could be updated to reflect this but that would break APIs, so this operation is deferred.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void free()  
      static java.sql.Blob generateProxy​(byte[] bytes)
      Generates a BlobImpl using byte data.
      static java.sql.Blob generateProxy​(java.io.InputStream stream, long length)
      Generates a BlobImpl proxy using a given number of bytes from an InputStream.
      java.io.InputStream getBinaryStream()  
      java.io.InputStream getBinaryStream​(long start, long length)  
      byte[] getBytes​(long start, int length)  
      BinaryStream getUnderlyingStream()
      Gets access to the data underlying this BLOB.
      long length()  
      long position​(byte[] pattern, long start)  
      long position​(java.sql.Blob pattern, long start)  
      java.io.OutputStream setBinaryStream​(long pos)  
      int setBytes​(long pos, byte[] bytes)  
      int setBytes​(long pos, byte[] bytes, int offset, int len)  
      void truncate​(long len)  
      • Methods inherited from class java.lang.Object

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

      • getUnderlyingStream

        public BinaryStream getUnderlyingStream()
                                         throws java.sql.SQLException
        Description copied from interface: BlobImplementer
        Gets access to the data underlying this BLOB.
        Specified by:
        getUnderlyingStream in interface BlobImplementer
        Returns:
        Access to the underlying data.
        Throws:
        java.sql.SQLException
      • generateProxy

        public static java.sql.Blob generateProxy​(byte[] bytes)
        Generates a BlobImpl using byte data.
        Parameters:
        bytes - The data to be created as a Blob.
        Returns:
        The BlobProxy instance to represent this data.
      • generateProxy

        public static java.sql.Blob generateProxy​(java.io.InputStream stream,
                                                  long length)
        Generates a BlobImpl proxy using a given number of bytes from an InputStream.
        Parameters:
        stream - The input stream of bytes to be created as a Blob.
        length - The number of bytes from stream to be written to the Blob.
        Returns:
        The BlobProxy instance to represent this data.
      • length

        public long length()
                    throws java.sql.SQLException
        Specified by:
        length in interface java.sql.Blob
        Throws:
        java.sql.SQLException
      • getBytes

        public byte[] getBytes​(long start,
                               int length)
                        throws java.sql.SQLException
        Specified by:
        getBytes in interface java.sql.Blob
        Throws:
        java.sql.SQLException
      • getBinaryStream

        public java.io.InputStream getBinaryStream()
                                            throws java.sql.SQLException
        Specified by:
        getBinaryStream in interface java.sql.Blob
        Throws:
        java.sql.SQLException
      • position

        public long position​(byte[] pattern,
                             long start)
        Specified by:
        position in interface java.sql.Blob
      • position

        public long position​(java.sql.Blob pattern,
                             long start)
        Specified by:
        position in interface java.sql.Blob
      • setBytes

        public int setBytes​(long pos,
                            byte[] bytes)
        Specified by:
        setBytes in interface java.sql.Blob
      • setBytes

        public int setBytes​(long pos,
                            byte[] bytes,
                            int offset,
                            int len)
        Specified by:
        setBytes in interface java.sql.Blob
      • setBinaryStream

        public java.io.OutputStream setBinaryStream​(long pos)
        Specified by:
        setBinaryStream in interface java.sql.Blob
      • truncate

        public void truncate​(long len)
        Specified by:
        truncate in interface java.sql.Blob
      • free

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

        public java.io.InputStream getBinaryStream​(long start,
                                                   long length)
                                            throws java.sql.SQLException
        Specified by:
        getBinaryStream in interface java.sql.Blob
        Throws:
        java.sql.SQLException