Class ClientClob

java.lang.Object
org.apache.derby.client.am.Lob
org.apache.derby.client.am.ClientClob
All Implemented Interfaces:
Clob, UnitOfWorkListener

public class ClientClob extends Lob implements Clob
This class implements the JDBC java.sql.Clob interface.
  • Field Details

    • string_

      protected String string_
    • asciiStream_

      private InputStream asciiStream_
    • unicodeStream_

      private InputStream unicodeStream_
    • characterStream_

      private Reader characterStream_
    • utf8String_

      private byte[] utf8String_
  • Constructor Details

    • ClientClob

      public ClientClob(Agent agent, String string)
    • ClientClob

      public ClientClob(Agent agent, byte[] unconvertedBytes, Charset charset, int dataOffset) throws SqlException
      Throws:
      SqlException
    • ClientClob

      public ClientClob(Agent agent, InputStream inputStream, Charset encoding, int length)
    • ClientClob

      ClientClob(Agent agent, InputStream inputStream, Charset encoding) throws SqlException
      Create a ClientClob of unknown length with the specified encoding. This constructor was added to support the JDBC 4 length less overloads. Note that a ClientClob created with this constructor is made for input to the database only. Do not pass it out to the user!
      Parameters:
      agent -
      inputStream - the data to insert
      encoding - encoding to use for characters. Only "ISO-8859-1" is allowed.
      Throws:
      SqlException
    • ClientClob

      ClientClob(Agent agent, Reader reader, int length)
    • ClientClob

      public ClientClob(Agent agent, int locator)
      Create a ClientClob object for a Clob value stored on the server and indentified by locator.
      Parameters:
      agent - context for this Clob object (incl. connection).
      locator - reference id to Clob value on server.
    • ClientClob

      ClientClob(Agent agent, Reader reader)
      Create a ClientClob of unknown length. This constructor was added to support the JDBC 4 length less overloads. Note that a ClientClob created with this constructor is made for input to the database only. Do not pass it out to the user!
      Parameters:
      agent -
      reader - the data to insert
    • ClientClob

      private ClientClob(Agent agent, boolean willBeLayerBStreamed)
  • Method Details

    • length

      public long length() throws SQLException
      Specified by:
      length in interface Clob
      Specified by:
      length in class Lob
      Throws:
      SQLException
    • getSubString

      public String getSubString(long pos, int length) throws SQLException
      Returns a copy of the specified substring in the CLOB value designated by this ClientClob object. The substring begins at position pos and has up to length consecutive characters. The starting position must be between 1 and the length of the CLOB plus 1. This allows for zero-length CLOB values, from which only zero-length substrings can be returned. If a larger length is requested than there are characters available, characters to the end of the CLOB are returned.
      Specified by:
      getSubString in interface Clob
      Parameters:
      pos - the first character of the substring to be extracted. The first character is at position 1.
      length - the number of consecutive characters to be copied
      Returns:
      a String that is the specified substring in the CLOB value designated by this ClientClob object
      Throws:
      SQLException - if there is an error accessing the CLOB NOTE: If the starting position is the length of the CLOB plus 1, zero characters are returned regardless of the length requested.
    • getSubStringX

      private String getSubStringX(long pos, int length) throws SqlException
      Throws:
      SqlException
    • getCharacterStream

      public Reader getCharacterStream() throws SQLException
      Specified by:
      getCharacterStream in interface Clob
      Throws:
      SQLException
    • getCharacterStreamX

      Reader getCharacterStreamX() throws SqlException
      Throws:
      SqlException
    • getAsciiStream

      public InputStream getAsciiStream() throws SQLException
      Specified by:
      getAsciiStream in interface Clob
      Throws:
      SQLException
    • getAsciiStreamX

      InputStream getAsciiStreamX() throws SqlException
      Throws:
      SqlException
    • position

      public long position(String searchstr, long start) throws SQLException
      Specified by:
      position in interface Clob
      Throws:
      SQLException
    • positionX

      private long positionX(String searchstr, long start) throws SqlException
      Throws:
      SqlException
    • position

      public long position(Clob searchstr, long start) throws SQLException
      Specified by:
      position in interface Clob
      Throws:
      SQLException
    • positionX

      private long positionX(Clob searchstr, long start) throws SqlException
      Throws:
      SqlException
    • setString

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

      public int setString(long pos, String str, int offset, int len) throws SQLException
      Specified by:
      setString in interface Clob
      Throws:
      SQLException
    • setStringX

      int setStringX(long pos, String str, int offset, int len) throws SqlException
      Throws:
      SqlException
    • setAsciiStream

      public OutputStream setAsciiStream(long pos) throws SQLException
      Specified by:
      setAsciiStream in interface Clob
      Throws:
      SQLException
    • setCharacterStream

      public Writer setCharacterStream(long pos) throws SQLException
      Specified by:
      setCharacterStream in interface Clob
      Throws:
      SQLException
    • truncate

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

      public void free() throws SQLException
      This method frees the Clob object and releases the resources the resources that it holds. The object is invalid once the free method is called. If free is called multiple times, the subsequent calls to free are treated as a no-op.
      Specified by:
      free in interface Clob
      Throws:
      SQLException - if an error occurs releasing the Clob's resources
    • getCharacterStream

      public Reader getCharacterStream(long pos, long length) throws 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 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:
      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 Clob.length() +1
    • isString

      public boolean isString()
    • isAsciiStream

      public boolean isAsciiStream()
    • isCharacterStream

      public boolean isCharacterStream()
    • isUnicodeStream

      public boolean isUnicodeStream()
    • getUnicodeStream

      public InputStream getUnicodeStream()
    • getString

      public String getString()
    • getUtf8String

      public byte[] getUtf8String()
    • getUTF8Length

      public int getUTF8Length()
    • reInitForNonLocator

      void reInitForNonLocator(String newString)
      Reinitialize the value of this CLOB. This is legacy code, only used when talking to servers that don't support locators.
      Parameters:
      newString - the new value
    • materializeStream

      protected void materializeStream() throws SqlException
      Materialize the stream used for input to the database.
      Specified by:
      materializeStream in class Lob
      Throws:
      SqlException
    • getLocatorLength

      long getLocatorLength() throws SqlException
      Get the length in bytes of the Clob value represented by this locator based Clob object. A stored procedure call will be made to get it from the server.
      Overrides:
      getLocatorLength in class Lob
      Returns:
      length of Clob in bytes
      Throws:
      SqlException