Package 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 or disk based representation of character data. Implementation note:- 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. - 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 theset
methods refer to 16 bit characters only. The presence of supplementary characters will cause the wrong characters to be accessed. - 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 underlyingBlobBuffer
.private static java.lang.String
EMPTY_CLOB
0 lengthString
as initial value for emptyClob
s.
-
Constructor Summary
Constructors Constructor Description ClobImpl(JtdsConnection connection)
Constructs a new emptyClob
instance.ClobImpl(JtdsConnection connection, java.lang.String str)
Constructs a new initializedClob
instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
free()
java.io.InputStream
getAsciiStream()
(package private) BlobBuffer
getBlobBuffer()
Obtain this object's backingBlobBuffer
object.java.io.Reader
getCharacterStream()
java.io.Reader
getCharacterStream(long pos, long length)
java.lang.String
getSubString(long pos, int length)
long
length()
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)
int
setString(long pos, java.lang.String str)
int
setString(long pos, java.lang.String str, int offset, int len)
void
truncate(long len)
-
-
-
Field Detail
-
EMPTY_CLOB
private static final java.lang.String EMPTY_CLOB
0 lengthString
as initial value for emptyClob
s.- See Also:
- Constant Field Values
-
blobBuffer
private final BlobBuffer blobBuffer
The underlyingBlobBuffer
.
-
-
Constructor Detail
-
ClobImpl
ClobImpl(JtdsConnection connection)
Constructs a new emptyClob
instance.- Parameters:
connection
- a reference to the parent connection object
-
ClobImpl
ClobImpl(JtdsConnection connection, java.lang.String str)
Constructs a new initializedClob
instance.- Parameters:
connection
- a reference to the parent connection objectstr
- theString
object to encapsulate
-
-
Method Detail
-
getBlobBuffer
BlobBuffer getBlobBuffer()
Obtain this object's backingBlobBuffer
object.- Returns:
- the underlying
BlobBuffer
-
getAsciiStream
public java.io.InputStream getAsciiStream() throws java.sql.SQLException
- Specified by:
getAsciiStream
in interfacejava.sql.Clob
- Throws:
java.sql.SQLException
-
getCharacterStream
public java.io.Reader getCharacterStream() throws java.sql.SQLException
- Specified by:
getCharacterStream
in interfacejava.sql.Clob
- Throws:
java.sql.SQLException
-
getSubString
public java.lang.String getSubString(long pos, int length) throws java.sql.SQLException
- Specified by:
getSubString
in interfacejava.sql.Clob
- Throws:
java.sql.SQLException
-
length
public long length() throws java.sql.SQLException
- Specified by:
length
in interfacejava.sql.Clob
- Throws:
java.sql.SQLException
-
position
public long position(java.lang.String searchStr, long start) throws java.sql.SQLException
- Specified by:
position
in interfacejava.sql.Clob
- Throws:
java.sql.SQLException
-
position
public long position(java.sql.Clob searchStr, long start) throws java.sql.SQLException
- Specified by:
position
in interfacejava.sql.Clob
- Throws:
java.sql.SQLException
-
setAsciiStream
public java.io.OutputStream setAsciiStream(long pos) throws java.sql.SQLException
- Specified by:
setAsciiStream
in interfacejava.sql.Clob
- Throws:
java.sql.SQLException
-
setCharacterStream
public java.io.Writer setCharacterStream(long pos) throws java.sql.SQLException
- Specified by:
setCharacterStream
in interfacejava.sql.Clob
- Throws:
java.sql.SQLException
-
setString
public int setString(long pos, java.lang.String str) throws java.sql.SQLException
- Specified by:
setString
in interfacejava.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 interfacejava.sql.Clob
- Throws:
java.sql.SQLException
-
truncate
public void truncate(long len) throws java.sql.SQLException
- Specified by:
truncate
in interfacejava.sql.Clob
- Throws:
java.sql.SQLException
-
free
public void free() throws java.sql.SQLException
- Specified by:
free
in interfacejava.sql.Clob
- Throws:
java.sql.SQLException
-
getCharacterStream
public java.io.Reader getCharacterStream(long pos, long length) throws java.sql.SQLException
- Specified by:
getCharacterStream
in interfacejava.sql.Clob
- Throws:
java.sql.SQLException
-
-