net.sourceforge.jtds.jdbc

Class ClobImpl

Implemented Interfaces:
Clob

public class ClobImpl
extends java.lang.Object
implements 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 2007/07/08 21:38:13 bheineman Exp $
Authors:
Brian Heineman
Mike Hutchinson

Field Summary

private static String
EMPTY_CLOB
0 length String as initial value for empty Clobs.
private BlobBuffer
blobBuffer
The underlying BlobBuffer.

Constructor Summary

ClobImpl(ConnectionJDBC2 connection)
Constructs a new empty Clob instance.
ClobImpl(ConnectionJDBC2 connection, String str)
Constructs a new initialized Clob instance.

Method Summary

InputStream
getAsciiStream()
(package private) BlobBuffer
getBlobBuffer()
Obtain this object's backing BlobBuffer object.
Reader
getCharacterStream()
String
getSubString(long pos, int length)
long
length()
long
position(Clob searchStr, long start)
long
position(String searchStr, long start)
OutputStream
setAsciiStream(long pos)
Writer
setCharacterStream(long pos)
int
setString(long pos, String str)
int
setString(long pos, String str, int offset, int len)
void
truncate(long len)

Field Details

EMPTY_CLOB

private static final String EMPTY_CLOB
0 length String as initial value for empty Clobs.

blobBuffer

private final BlobBuffer blobBuffer
The underlying BlobBuffer.

Constructor Details

ClobImpl

(package private)  ClobImpl(ConnectionJDBC2 connection)
Constructs a new empty Clob instance.
Parameters:
connection - a reference to the parent connection object

ClobImpl

(package private)  ClobImpl(ConnectionJDBC2 connection,
                            String str)
Constructs a new initialized Clob instance.
Parameters:
connection - a reference to the parent connection object
str - the String object to encapsulate

Method Details

getAsciiStream

public InputStream getAsciiStream()
            throws SQLException

getBlobBuffer

(package private)  BlobBuffer getBlobBuffer()
Obtain this object's backing BlobBuffer object.
Returns:
the underlying BlobBuffer

getCharacterStream

public Reader getCharacterStream()
            throws SQLException

getSubString

public String getSubString(long pos,
                           int length)
            throws SQLException

length

public long length()
            throws SQLException

position

public long position(Clob searchStr,
                     long start)
            throws SQLException

position

public long position(String searchStr,
                     long start)
            throws SQLException

setAsciiStream

public OutputStream setAsciiStream(long pos)
            throws SQLException

setCharacterStream

public Writer setCharacterStream(long pos)
            throws SQLException

setString

public int setString(long pos,
                     String str)
            throws SQLException

setString

public int setString(long pos,
                     String str,
                     int offset,
                     int len)
            throws SQLException

truncate

public void truncate(long len)
            throws SQLException

Generated on June 12 2008