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.ClobAn in-memory or disk based representation of character data. Implementation note:- This implementation stores the CLOB data in a byte array managed by
the
BlobBufferclass. 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,positionand thesetmethods 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 BlobBufferblobBufferThe underlyingBlobBuffer.private static java.lang.StringEMPTY_CLOB0 lengthStringas initial value for emptyClobs.
-
Constructor Summary
Constructors Constructor Description ClobImpl(JtdsConnection connection)Constructs a new emptyClobinstance.ClobImpl(JtdsConnection connection, java.lang.String str)Constructs a new initializedClobinstance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidfree()java.io.InputStreamgetAsciiStream()(package private) BlobBuffergetBlobBuffer()Obtain this object's backingBlobBufferobject.java.io.ReadergetCharacterStream()java.io.ReadergetCharacterStream(long pos, long length)java.lang.StringgetSubString(long pos, int length)longlength()longposition(java.lang.String searchStr, long start)longposition(java.sql.Clob searchStr, long start)java.io.OutputStreamsetAsciiStream(long pos)java.io.WritersetCharacterStream(long pos)intsetString(long pos, java.lang.String str)intsetString(long pos, java.lang.String str, int offset, int len)voidtruncate(long len)
-
-
-
Field Detail
-
EMPTY_CLOB
private static final java.lang.String EMPTY_CLOB
0 lengthStringas initial value for emptyClobs.- See Also:
- Constant Field Values
-
blobBuffer
private final BlobBuffer blobBuffer
The underlyingBlobBuffer.
-
-
Constructor Detail
-
ClobImpl
ClobImpl(JtdsConnection connection)
Constructs a new emptyClobinstance.- Parameters:
connection- a reference to the parent connection object
-
ClobImpl
ClobImpl(JtdsConnection connection, java.lang.String str)
Constructs a new initializedClobinstance.- Parameters:
connection- a reference to the parent connection objectstr- theStringobject to encapsulate
-
-
Method Detail
-
getBlobBuffer
BlobBuffer getBlobBuffer()
Obtain this object's backingBlobBufferobject.- Returns:
- the underlying
BlobBuffer
-
getAsciiStream
public java.io.InputStream getAsciiStream() throws java.sql.SQLException- Specified by:
getAsciiStreamin interfacejava.sql.Clob- Throws:
java.sql.SQLException
-
getCharacterStream
public java.io.Reader getCharacterStream() throws java.sql.SQLException- Specified by:
getCharacterStreamin interfacejava.sql.Clob- Throws:
java.sql.SQLException
-
getSubString
public java.lang.String getSubString(long pos, int length) throws java.sql.SQLException- Specified by:
getSubStringin interfacejava.sql.Clob- Throws:
java.sql.SQLException
-
length
public long length() throws java.sql.SQLException- Specified by:
lengthin interfacejava.sql.Clob- Throws:
java.sql.SQLException
-
position
public long position(java.lang.String searchStr, long start) throws java.sql.SQLException- Specified by:
positionin interfacejava.sql.Clob- Throws:
java.sql.SQLException
-
position
public long position(java.sql.Clob searchStr, long start) throws java.sql.SQLException- Specified by:
positionin interfacejava.sql.Clob- Throws:
java.sql.SQLException
-
setAsciiStream
public java.io.OutputStream setAsciiStream(long pos) throws java.sql.SQLException- Specified by:
setAsciiStreamin interfacejava.sql.Clob- Throws:
java.sql.SQLException
-
setCharacterStream
public java.io.Writer setCharacterStream(long pos) throws java.sql.SQLException- Specified by:
setCharacterStreamin interfacejava.sql.Clob- Throws:
java.sql.SQLException
-
setString
public int setString(long pos, java.lang.String str) throws java.sql.SQLException- Specified by:
setStringin 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:
setStringin interfacejava.sql.Clob- Throws:
java.sql.SQLException
-
truncate
public void truncate(long len) throws java.sql.SQLException- Specified by:
truncatein interfacejava.sql.Clob- Throws:
java.sql.SQLException
-
free
public void free() throws java.sql.SQLException- Specified by:
freein interfacejava.sql.Clob- Throws:
java.sql.SQLException
-
getCharacterStream
public java.io.Reader getCharacterStream(long pos, long length) throws java.sql.SQLException- Specified by:
getCharacterStreamin interfacejava.sql.Clob- Throws:
java.sql.SQLException
-
-