Class MariaDbClob

  • All Implemented Interfaces:
    java.io.Serializable, java.sql.Blob, java.sql.Clob, java.sql.NClob

    public class MariaDbClob
    extends MariaDbBlob
    implements java.sql.Clob, java.sql.NClob, java.io.Serializable
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      MariaDbClob()
      Creates an empty Clob.
      MariaDbClob​(byte[] bytes)
      Creates a Clob with content.
      MariaDbClob​(byte[] bytes, int offset, int length)
      Creates a Clob with content.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.io.InputStream getAsciiStream()  
      java.io.Reader getCharacterStream()  
      java.io.Reader getCharacterStream​(long pos, long length)
      Returns a Reader object that contains a partial Clob value, starting with the character specified by pos, which is length characters in length.
      java.lang.String getSubString​(long pos, int length)
      Get sub string.
      long length()
      Return character length of the Clob.
      long position​(java.lang.String searchStr, long start)  
      long position​(java.sql.Clob searchStr, long start)  
      java.io.OutputStream setAsciiStream​(long pos)  
      java.io.Writer setCharacterStream​(long pos)
      Set character stream.
      int setString​(long pos, java.lang.String str)
      Set String.
      int setString​(long pos, java.lang.String str, int offset, int len)  
      java.lang.String toString()
      ToString implementation.
      void truncate​(long truncateLen)
      Truncates the BLOB value that this Blob object represents to be len bytes in length.
      private int utf8Position​(int charPosition)
      Convert character position into byte position in UTF8 byte array.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.sql.Clob

        free
    • Constructor Detail

      • MariaDbClob

        public MariaDbClob​(byte[] bytes)
        Creates a Clob with content.
        Parameters:
        bytes - the content for the Clob.
      • MariaDbClob

        public MariaDbClob​(byte[] bytes,
                           int offset,
                           int length)
        Creates a Clob with content.
        Parameters:
        bytes - the content for the Clob.
        offset - offset
        length - length
      • MariaDbClob

        public MariaDbClob()
        Creates an empty Clob.
    • Method Detail

      • toString

        public java.lang.String toString()
        ToString implementation.
        Overrides:
        toString in class java.lang.Object
        Returns:
        string value of blob content.
      • getSubString

        public java.lang.String getSubString​(long pos,
                                             int length)
                                      throws java.sql.SQLException
        Get sub string.
        Specified by:
        getSubString in interface java.sql.Clob
        Parameters:
        pos - position
        length - length of sub string
        Returns:
        substring
        Throws:
        java.sql.SQLException - if pos is less than 1 or length is less than 0
      • getCharacterStream

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

        public java.io.Reader getCharacterStream​(long pos,
                                                 long length)
                                          throws java.sql.SQLException
        Returns a Reader object that contains a partial Clob value, starting with the character specified by pos, which is length characters in length.
        Specified by:
        getCharacterStream in interface java.sql.Clob
        Parameters:
        pos - the offset to the first character of the partial value to be retrieved. The first character in the Clob is at position 1.
        length - the length in characters of the partial value to be retrieved.
        Returns:
        Reader through which the partial Clob value can be read.
        Throws:
        java.sql.SQLException - if pos is less than 1 or if pos is greater than the number of characters in the Clob or if pos + length is greater than the number of characters in the Clob
      • setCharacterStream

        public java.io.Writer setCharacterStream​(long pos)
                                          throws java.sql.SQLException
        Set character stream.
        Specified by:
        setCharacterStream in interface java.sql.Clob
        Parameters:
        pos - position
        Returns:
        writer
        Throws:
        java.sql.SQLException - if position is invalid
      • getAsciiStream

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

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

        public long position​(java.sql.Clob searchStr,
                             long start)
        Specified by:
        position in interface java.sql.Clob
      • utf8Position

        private int utf8Position​(int charPosition)
        Convert character position into byte position in UTF8 byte array.
        Parameters:
        charPosition - charPosition
        Returns:
        byte position
      • setString

        public int setString​(long pos,
                             java.lang.String str)
                      throws java.sql.SQLException
        Set String.
        Specified by:
        setString in interface java.sql.Clob
        Parameters:
        pos - position
        str - string
        Returns:
        string length
        Throws:
        java.sql.SQLException - if UTF-8 conversion failed
      • 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
      • setAsciiStream

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

        public long length()
        Return character length of the Clob. Assume UTF8 encoding.
        Specified by:
        length in interface java.sql.Blob
        Specified by:
        length in interface java.sql.Clob
        Overrides:
        length in class MariaDbBlob
        Returns:
        length of the BLOB in bytes
      • truncate

        public void truncate​(long truncateLen)
        Description copied from class: MariaDbBlob
        Truncates the BLOB value that this Blob object represents to be len bytes in length.
        Specified by:
        truncate in interface java.sql.Blob
        Specified by:
        truncate in interface java.sql.Clob
        Overrides:
        truncate in class MariaDbBlob
        Parameters:
        truncateLen - the length, in bytes, to which the BLOB value that this Blob object represents should be truncated