Class ClobProxy

  • All Implemented Interfaces:
    java.lang.reflect.InvocationHandler
    Direct Known Subclasses:
    NClobProxy

    public class ClobProxy
    extends java.lang.Object
    implements java.lang.reflect.InvocationHandler
    Manages aspects of proxying Clobs for non-contextual creation, including proxy creation and handling proxy invocations. We use proxies here solely to avoid JDBC version incompatibilities.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected ClobProxy​(java.io.Reader reader, long length)
      Constructor used to build Clob from a reader.
      protected ClobProxy​(java.lang.String string)
      Constructor used to build Clob from string data.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static java.sql.Clob generateProxy​(java.io.Reader reader, long length)
      Generates a Clob proxy using a character reader of given length.
      static java.sql.Clob generateProxy​(java.lang.String string)
      Generates a Clob proxy using the string data.
      protected java.io.InputStream getAsciiStream()  
      protected java.io.Reader getCharacterStream()  
      protected long getLength()  
      protected static java.lang.ClassLoader getProxyClassLoader()
      Determines the appropriate class loader to which the generated proxy should be scoped.
      protected java.lang.String getSubString​(long start, int length)  
      protected CharacterStream getUnderlyingStream()  
      java.lang.Object invoke​(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args)
      protected void resetIfNeeded()  
      • Methods inherited from class java.lang.Object

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

      • ClobProxy

        protected ClobProxy​(java.lang.String string)
        Constructor used to build Clob from string data.
        Parameters:
        string - The byte array
        See Also:
        generateProxy(String)
      • ClobProxy

        protected ClobProxy​(java.io.Reader reader,
                            long length)
        Constructor used to build Clob from a reader.
        Parameters:
        reader - The character reader.
        length - The length of the reader stream.
        See Also:
        generateProxy(java.io.Reader, long)
    • Method Detail

      • getLength

        protected long getLength()
      • getAsciiStream

        protected java.io.InputStream getAsciiStream()
                                              throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • getCharacterStream

        protected java.io.Reader getCharacterStream()
                                             throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • getUnderlyingStream

        protected CharacterStream getUnderlyingStream()
                                               throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • getSubString

        protected java.lang.String getSubString​(long start,
                                                int length)
      • invoke

        public java.lang.Object invoke​(java.lang.Object proxy,
                                       java.lang.reflect.Method method,
                                       java.lang.Object[] args)
                                throws java.lang.Throwable
        Specified by:
        invoke in interface java.lang.reflect.InvocationHandler
        Throws:
        java.lang.UnsupportedOperationException - if any methods other than Clob.length(), Clob.getAsciiStream(), Clob.getCharacterStream(), ClobImplementer.getUnderlyingStream(), Clob.getSubString(long, int), Clob.free(), or toString/equals/hashCode are invoked.
        java.lang.Throwable
      • resetIfNeeded

        protected void resetIfNeeded()
                              throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • generateProxy

        public static java.sql.Clob generateProxy​(java.lang.String string)
        Generates a Clob proxy using the string data.
        Parameters:
        string - The data to be wrapped as a Clob.
        Returns:
        The generated proxy.
      • generateProxy

        public static java.sql.Clob generateProxy​(java.io.Reader reader,
                                                  long length)
        Generates a Clob proxy using a character reader of given length.
        Parameters:
        reader - The character reader
        length - The length of the character reader
        Returns:
        The generated proxy.
      • getProxyClassLoader

        protected static java.lang.ClassLoader getProxyClassLoader()
        Determines the appropriate class loader to which the generated proxy should be scoped.
        Returns:
        The class loader appropriate for proxy construction.