net.sourceforge.jtds.jdbc
Class ClobImpl

java.lang.Object
  |
  +--net.sourceforge.jtds.jdbc.ClobImpl
All Implemented Interfaces:
java.sql.Clob

public class ClobImpl
extends java.lang.Object
implements java.sql.Clob

An in-memory, disk or database representation of character data.

Implementation note:

  1. Mostly Brian's original code but modified to include the ability to convert a stream into a String when required.
  2. SQLException messages loaded from properties file.

Version:
$Id: ClobImpl.java,v 1.34 2005/04/13 15:56:21 alin_sinpalean Exp $
Author:
Brian Heineman, Mike Hutchinson

Inner Class Summary
(package private)  class ClobImpl.ClobFileWriter
          Class to manage Clob file writes.
(package private)  class ClobImpl.ClobWriter
          Class to manage any Clob write.
 
Field Summary
private  java.lang.String _clob
           
private  java.io.File _clobFile
           
private  ConnectionJDBC2 _connection
           
private  JtdsReader _jtdsReader
           
private static java.lang.String EMPTY_CLOB
           
 
Constructor Summary
(package private) ClobImpl(java.lang.Object callerReference)
          Constructs a new Clob instance.
(package private) ClobImpl(java.lang.Object callerReference, ResponseStream in, boolean ntext, boolean readTextMode, CharsetInfo charsetInfo)
          Constructs a new Clob instance.
(package private) ClobImpl(java.lang.Object callerReference, java.lang.String clob)
          Constructs a new Clob instance.
 
Method Summary
protected  void finalize()
           
 java.io.InputStream getAsciiStream()
          Returns a new ascii stream for the CLOB data.
 java.io.Reader getCharacterStream()
          Returns a new reader for the CLOB data.
 java.lang.String getSubString(long pos, int length)
           
 long length()
          Returns the length of the value.
 long position(java.sql.Clob searchStr, long start)
           
 long position(java.lang.String searchStr, long start)
           
 java.io.OutputStream setAsciiStream(long pos)
           
 java.io.Writer setCharacterStream(long pos)
           
 int setString(long pos, java.lang.String str)
           
 int setString(long pos, java.lang.String str, int offset, int len)
           
private  void skip(java.io.Reader reader, long skip)
           
 void truncate(long len)
          Truncates the value to the length specified.
 
Methods inherited from class java.lang.Object
, clone, equals, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

EMPTY_CLOB

private static final java.lang.String EMPTY_CLOB

_connection

private final ConnectionJDBC2 _connection

_clob

private java.lang.String _clob

_clobFile

private java.io.File _clobFile

_jtdsReader

private JtdsReader _jtdsReader
Constructor Detail

ClobImpl

ClobImpl(java.lang.Object callerReference)
Constructs a new Clob instance.
Parameters:
callerReference - an object reference to the caller of this method; must be a Connection, Statement or ResultSet

ClobImpl

ClobImpl(java.lang.Object callerReference,
         java.lang.String clob)
Constructs a new Clob instance.
Parameters:
callerReference - an object reference to the caller of this method; must be a Connection, Statement or ResultSet
clob - the clob object to encapsulate

ClobImpl

ClobImpl(java.lang.Object callerReference,
         ResponseStream in,
         boolean ntext,
         boolean readTextMode,
         CharsetInfo charsetInfo)
   throws java.io.IOException
Constructs a new Clob instance.
Parameters:
callerReference - an object reference to the caller of this method; must be a Connection, Statement or ResultSet
in - the clob object to encapsulate
ntext - true if the data type is NTEXT (i.e. Unicode)
readTextMode - true if READTEXT should be used to retrieve the value false if the value is directly available from in
charsetInfo - the character set to be used for reading if the value is not Unicode encoded (i.e. TEXT)
Method Detail

getAsciiStream

public java.io.InputStream getAsciiStream()
                                   throws java.sql.SQLException
Returns a new ascii stream for the CLOB data.
Specified by:
getAsciiStream in interface java.sql.Clob

getCharacterStream

public java.io.Reader getCharacterStream()
                                  throws java.sql.SQLException
Returns a new reader for the CLOB data.
Specified by:
getCharacterStream in interface java.sql.Clob

getSubString

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

length

public long length()
            throws java.sql.SQLException
Returns the length of the value.
Specified by:
length in interface java.sql.Clob

position

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

position

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

setAsciiStream

public java.io.OutputStream setAsciiStream(long pos)
                                    throws java.sql.SQLException

setCharacterStream

public java.io.Writer setCharacterStream(long pos)
                                  throws java.sql.SQLException

setString

public int setString(long pos,
                     java.lang.String str)
              throws java.sql.SQLException

setString

public int setString(long pos,
                     java.lang.String str,
                     int offset,
                     int len)
              throws java.sql.SQLException

truncate

public void truncate(long len)
              throws java.sql.SQLException
Truncates the value to the length specified.
Parameters:
len - the length to truncate the value to

skip

private void skip(java.io.Reader reader,
                  long skip)
           throws java.sql.SQLException

finalize

protected void finalize()
Overrides:
finalize in class java.lang.Object


Generated on April 15 2005