Class ClobImpl

  • All Implemented Interfaces:
    java.sql.Clob

    public class ClobImpl
    extends java.lang.Object
    implements java.sql.Clob
    An in-memory or disk based representation of character data.

    Implementation note:

    1. This implementation stores the CLOB data in a byte array managed by the BlobBuffer class. Each character is stored in 2 sequential bytes using UTF-16LE encoding.
    2. As a consequence of using UTF-16LE, Unicode 3.1 supplementary characters may require an additional 2 bytes of storage. This implementation assumes that character position parameters supplied to getSubstring, position and the set methods refer to 16 bit characters only. The presence of supplementary characters will cause the wrong characters to be accessed.
    3. For the same reasons although the position method will return the correct start position for any given pattern in the array, the returned value may be different to that expected if supplementary characters exist in the text preceding the pattern.
    Version:
    $Id: ClobImpl.java,v 1.36.2.3 2009-12-30 08:45:34 ickzon Exp $
    Author:
    Brian Heineman, Mike Hutchinson
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private BlobBuffer blobBuffer
      The underlying BlobBuffer.
      private static java.lang.String EMPTY_CLOB
      0 length String as initial value for empty Clobs.
    • Constructor Summary

      Constructors 
      Constructor Description
      ClobImpl​(JtdsConnection connection)
      Constructs a new empty Clob instance.
      ClobImpl​(JtdsConnection connection, java.lang.String str)
      Constructs a new initialized Clob instance.
    • Field Detail

      • EMPTY_CLOB

        private static final java.lang.String EMPTY_CLOB
        0 length String as initial value for empty Clobs.
        See Also:
        Constant Field Values
      • blobBuffer

        private final BlobBuffer blobBuffer
        The underlying BlobBuffer.
    • Constructor Detail

      • ClobImpl

        ClobImpl​(JtdsConnection connection)
        Constructs a new empty Clob instance.
        Parameters:
        connection - a reference to the parent connection object
      • ClobImpl

        ClobImpl​(JtdsConnection connection,
                 java.lang.String str)
        Constructs a new initialized Clob instance.
        Parameters:
        connection - a reference to the parent connection object
        str - the String object to encapsulate
    • Method Detail

      • getBlobBuffer

        BlobBuffer getBlobBuffer()
        Obtain this object's backing BlobBuffer object.
        Returns:
        the underlying BlobBuffer
      • getAsciiStream

        public java.io.InputStream getAsciiStream()
                                           throws java.sql.SQLException
        Specified by:
        getAsciiStream in interface java.sql.Clob
        Throws:
        java.sql.SQLException
      • getCharacterStream

        public java.io.Reader getCharacterStream()
                                          throws java.sql.SQLException
        Specified by:
        getCharacterStream in interface java.sql.Clob
        Throws:
        java.sql.SQLException
      • getSubString

        public java.lang.String getSubString​(long pos,
                                             int length)
                                      throws java.sql.SQLException
        Specified by:
        getSubString in interface java.sql.Clob
        Throws:
        java.sql.SQLException
      • length

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

        public long position​(java.lang.String searchStr,
                             long start)
                      throws java.sql.SQLException
        Specified by:
        position in interface java.sql.Clob
        Throws:
        java.sql.SQLException
      • position

        public long position​(java.sql.Clob searchStr,
                             long start)
                      throws java.sql.SQLException
        Specified by:
        position in interface java.sql.Clob
        Throws:
        java.sql.SQLException
      • setAsciiStream

        public java.io.OutputStream setAsciiStream​(long pos)
                                            throws java.sql.SQLException
        Specified by:
        setAsciiStream in interface java.sql.Clob
        Throws:
        java.sql.SQLException
      • setCharacterStream

        public java.io.Writer setCharacterStream​(long pos)
                                          throws java.sql.SQLException
        Specified by:
        setCharacterStream in interface java.sql.Clob
        Throws:
        java.sql.SQLException
      • setString

        public int setString​(long pos,
                             java.lang.String str)
                      throws java.sql.SQLException
        Specified by:
        setString in interface java.sql.Clob
        Throws:
        java.sql.SQLException
      • setString

        public int setString​(long pos,
                             java.lang.String str,
                             int offset,
                             int len)
                      throws java.sql.SQLException
        Specified by:
        setString in interface java.sql.Clob
        Throws:
        java.sql.SQLException
      • truncate

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

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

        public java.io.Reader getCharacterStream​(long pos,
                                                 long length)
                                          throws java.sql.SQLException
        Specified by:
        getCharacterStream in interface java.sql.Clob
        Throws:
        java.sql.SQLException