Top Description Fields Constructors Methods
org.apache.derby.client.am

public Class ClientClob

extends Lob
implements Clob
Class Inheritance
All Implemented Interfaces
java.sql.Clob
Imports
java.io.IOException, .InputStream, .InputStreamReader, .OutputStream, .Reader, .StringReader, .Writer, java.nio.charset.Charset, java.sql.Clob, .SQLException, org.apache.derby.client.net.EncodedInputStream, org.apache.derby.shared.common.reference.SQLState

This class implements the JDBC java.sql.Clob interface.

Field Summary

Modifier and TypeField and Description
private InputStream
private Reader
protected String
private InputStream
private byte[]
Inherited from org.apache.derby.client.am.Lob:
agent_ASCII_STREAMBINARY_STREAMBINARY_STRINGCHARACTER_STREAMdataType_INVALID_LOCATORisValid_LOCATORlocator_STRINGUNICODE_STREAM

Constructor Summary

AccessConstructor and Description
public
ClientClob(Agent agent, String string)

public
ClientClob(Agent agent, byte[] unconvertedBytes, Charset charset, int dataOffset)

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

pack-priv
ClientClob(Agent agent, InputStream
the data to insert
inputStream
,
Charset
encoding to use for characters. Only "ISO-8859-1" is allowed.
encoding
)

Create a ClientClob of unknown length with the specified encoding.

pack-priv
ClientClob(Agent agent, Reader reader, int length)

public
ClientClob(Agent
context for this Clob object (incl. connection).
agent
,
int
reference id to Clob value on server.
locator
)

Create a ClientClob object for a Clob value stored on the server and indentified by locator.

pack-priv
ClientClob(Agent agent, Reader
the data to insert
reader
)

Create a ClientClob of unknown length.

private
ClientClob(Agent agent, boolean willBeLayerBStreamed)

Method Summary

Modifier and TypeMethod and Description
public void
free()

Implements java.sql.Clob.free.

This method frees the Clob object and releases the resources the resources that it holds.
public InputStream
getAsciiStream()

Implements java.sql.Clob.getAsciiStream.

Retrieves the CLOB value designated by this Clob object as an ascii stream.
pack-priv InputStream
public Reader
getCharacterStream()

Implements java.sql.Clob.getCharacterStream.

Retrieves the CLOB value designated by this Clob object as a java.io.Reader object (or as a stream of characters).
public Reader

Returns:

Reader through which the partial Clob value can be read.
getCharacterStream
(long
the offset to the first character of the partial value to be retrieved. The first character in the Clob is at position 1.
pos
,
long
the length in characters of the partial value to be retrieved.
length
)

Implements java.sql.Clob.getCharacterStream.

Returns a Reader object that contains a partial Clob value, starting with the character specified by pos, which is length characters in length.
pack-priv Reader
pack-priv long

Returns:

length of Clob in bytes
getLocatorLength
()

Overrides org.apache.derby.client.am.Lob.getLocatorLength.

Get the length in bytes of the Clob value represented by this locator based Clob object.
public String
public String

Returns:

a String that is the specified substring in the CLOB value designated by this ClientClob object
getSubString
(long
the first character of the substring to be extracted. The first character is at position 1.
pos
,
int
the number of consecutive characters to be copied
length
)

Implements java.sql.Clob.getSubString.

Returns a copy of the specified substring in the CLOB value designated by this ClientClob object.
private String
getSubStringX(long pos, int length)

public InputStream
public int
public byte[]
public boolean
public boolean
public boolean
public boolean
public long
length()

Implements abstract org.apache.derby.client.am.Lob.length.

Implements java.sql.Clob.length.

Retrieves the number of characters in the CLOB value designated by this Clob object.
protected void
materializeStream()

Implements abstract org.apache.derby.client.am.Lob.materializeStream.

Materialize the stream used for input to the database.
public long
position(String
the substring for which to search
searchstr
,
long
the position at which to begin searching; the first position is 1
start
)

Implements java.sql.Clob.position.

Retrieves the character position at which the specified substring searchstr appears in the SQL CLOB value represented by this Clob object.
public long
position(Clob
the Clob object for which to search
searchstr
,
long
the position at which to begin searching; the first position is 1
start
)

Implements java.sql.Clob.position.

Retrieves the character position at which the specified Clob object searchstr appears in this Clob object.
private long
positionX(String searchstr, long start)

private long
positionX(Clob searchstr, long start)

pack-priv void
reInitForNonLocator(String
the new value
newString
)

Reinitialize the value of this CLOB.

public OutputStream
setAsciiStream(long
the position at which to start writing to this CLOB object; The first position is 1
pos
)

Implements java.sql.Clob.setAsciiStream.

Retrieves a stream to be used to write Ascii characters to the CLOB value that this Clob object represents, starting at position pos.
public Writer
setCharacterStream(long
the position at which to start writing to the CLOB value; The first position is 1
pos
)

Implements java.sql.Clob.setCharacterStream.

Retrieves a stream to be used to write a stream of Unicode characters to the CLOB value that this Clob object represents, at position pos.
public int
setString(long
the position at which to start writing to the CLOB value that this Clob object represents; the first position is 1.
pos
,
String
the string to be written to the CLOB value that this Clob designates
str
)

Implements java.sql.Clob.setString.

Writes the given Java String to the CLOB value that this Clob object designates at the position pos.
public int
setString(long
the position at which to start writing to this CLOB object; The first position is 1
pos
,
String
the string to be written to the CLOB value that this Clob object represents
str
,
int
the offset into str to start reading the characters to be written
offset
,
int
the number of characters to be written
len
)

Implements java.sql.Clob.setString.

Writes len characters of str, starting at character offset, to the CLOB value that this Clob represents.
pack-priv int
setStringX(long pos, String str, int offset, int len)

public void
truncate(long
the length, in characters, to which the CLOB value should be truncated
len
)

Implements java.sql.Clob.truncate.

Truncates the CLOB value that this Clob designates to have a length of len characters.
Inherited from org.apache.derby.client.am.Lob:
checkForClosedConnectioncheckForLocatorValiditycheckPosAndLengthcheckValiditycompleteLocalCommitcompleteLocalRollbackgetAgentgetLocatorgetUpdateCountincrementUpdateCountisLayerBStreamingPossibleisLocatorlistenToUnitOfWorkmaterializeStreamsetSqlLengthsqlLengthwillBeLayerBStreamed

Field Detail

asciiStream_back to summary
private InputStream asciiStream_
characterStream_back to summary
private Reader characterStream_
string_back to summary
protected String string_
unicodeStream_back to summary
private InputStream unicodeStream_
utf8String_back to summary
private byte[] utf8String_

Constructor Detail

ClientClobback to summary
public ClientClob(Agent agent, String string)
ClientClobback to summary
public ClientClob(Agent agent, byte[] unconvertedBytes, Charset charset, int dataOffset) throws SqlException
ClientClobback to summary
public ClientClob(Agent agent, InputStream inputStream, Charset encoding, int length)
ClientClobback to summary
pack-priv 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
inputStream:InputStream

the data to insert

encoding:Charset

encoding to use for characters. Only "ISO-8859-1" is allowed.

ClientClobback to summary
pack-priv ClientClob(Agent agent, Reader reader, int length)
ClientClobback to summary
public ClientClob(Agent agent, int locator)

Create a ClientClob object for a Clob value stored on the server and indentified by locator.

Parameters
agent:Agent

context for this Clob object (incl. connection).

locator:int

reference id to Clob value on server.

ClientClobback to summary
pack-priv 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
reader:Reader

the data to insert

ClientClobback to summary
private ClientClob(Agent agent, boolean willBeLayerBStreamed)

Method Detail

freeback to summary
public void free() throws SQLException

Implements java.sql.Clob.free.

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.

Exceptions
SQLException:
if an error occurs releasing the Clob's resources
getAsciiStreamback to summary
public InputStream getAsciiStream() throws SQLException

Implements java.sql.Clob.getAsciiStream.

Doc from java.sql.Clob.getAsciiStream.

Retrieves the CLOB value designated by this Clob object as an ascii stream.

Returns:InputStream

a java.io.InputStream object containing the CLOB data

Exceptions
SQLException:
if there is an error accessing the CLOB value
getAsciiStreamXback to summary
pack-priv InputStream getAsciiStreamX() throws SqlException
getCharacterStreamback to summary
public Reader getCharacterStream() throws SQLException

Implements java.sql.Clob.getCharacterStream.

Doc from java.sql.Clob.getCharacterStream.

Retrieves the CLOB value designated by this Clob object as a java.io.Reader object (or as a stream of characters).

Returns:Reader

a java.io.Reader object containing the CLOB data

Exceptions
SQLException:
if there is an error accessing the CLOB value
getCharacterStreamback to summary
public Reader getCharacterStream(long pos, long length) throws SQLException

Implements java.sql.Clob.getCharacterStream.

Returns a Reader object that contains a partial Clob value, starting with the character specified by pos, which is length characters in length.

Parameters
pos:long

the offset to the first character of the partial value to be retrieved. The first character in the Clob is at position 1.

length:long

the length in characters of the partial value to be retrieved.

Returns:Reader

Reader through which the partial Clob value can be read.

Exceptions
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
getCharacterStreamXback to summary
pack-priv Reader getCharacterStreamX() throws SqlException
getLocatorLengthback to summary
pack-priv long getLocatorLength() throws SqlException

Overrides org.apache.derby.client.am.Lob.getLocatorLength.

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.

Returns:long

length of Clob in bytes

getStringback to summary
public String getString()
getSubStringback to summary
public String getSubString(long pos, int length) throws SQLException

Implements java.sql.Clob.getSubString.

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.

Parameters
pos:long

the first character of the substring to be extracted. The first character is at position 1.

length:int

the number of consecutive characters to be copied

Returns:String

a String that is the specified substring in the CLOB value designated by this ClientClob object

Exceptions
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.
getSubStringXback to summary
private String getSubStringX(long pos, int length) throws SqlException
getUnicodeStreamback to summary
public InputStream getUnicodeStream()
getUTF8Lengthback to summary
public int getUTF8Length()
getUtf8Stringback to summary
public byte[] getUtf8String()
isAsciiStreamback to summary
public boolean isAsciiStream()
isCharacterStreamback to summary
public boolean isCharacterStream()
isStringback to summary
public boolean isString()
isUnicodeStreamback to summary
public boolean isUnicodeStream()
lengthback to summary
public long length() throws SQLException

Implements abstract org.apache.derby.client.am.Lob.length.

Implements java.sql.Clob.length.

Doc from java.sql.Clob.length.

Retrieves the number of characters in the CLOB value designated by this Clob object.

Returns:long

length of the CLOB in characters

Exceptions
SQLException:
if there is an error accessing the length of the CLOB value
materializeStreamback to summary
protected void materializeStream() throws SqlException

Implements abstract org.apache.derby.client.am.Lob.materializeStream.

Materialize the stream used for input to the database.

Exceptions
SqlException:
on error
positionback to summary
public long position(String searchstr, long start) throws SQLException

Implements java.sql.Clob.position.

Doc from java.sql.Clob.position.

Retrieves the character position at which the specified substring searchstr appears in the SQL CLOB value represented by this Clob object. The search begins at position start.

Parameters
searchstr:String

the substring for which to search

start:long

the position at which to begin searching; the first position is 1

Returns:long

the position at which the substring appears or -1 if it is not present; the first position is 1

Exceptions
SQLException:
if there is an error accessing the CLOB value or if pos is less than 1
positionback to summary
public long position(Clob searchstr, long start) throws SQLException

Implements java.sql.Clob.position.

Doc from java.sql.Clob.position.

Retrieves the character position at which the specified Clob object searchstr appears in this Clob object. The search begins at position start.

Parameters
searchstr:Clob

the Clob object for which to search

start:long

the position at which to begin searching; the first position is 1

Returns:long

the position at which the Clob object appears or -1 if it is not present; the first position is 1

Exceptions
SQLException:
if there is an error accessing the CLOB value or if start is less than 1
positionXback to summary
private long positionX(String searchstr, long start) throws SqlException
positionXback to summary
private long positionX(Clob searchstr, long start) throws SqlException
reInitForNonLocatorback to summary
pack-priv 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:String

the new value

Annotations
@SuppressWarnings:deprecation
setAsciiStreamback to summary
public OutputStream setAsciiStream(long pos) throws SQLException

Implements java.sql.Clob.setAsciiStream.

Doc from java.sql.Clob.setAsciiStream.

Retrieves a stream to be used to write Ascii characters to the CLOB value that this Clob object represents, starting at position pos. Characters written to the stream will overwrite the existing characters in the Clob object starting at the position pos. If the end of the Clob value is reached while writing characters to the stream, then the length of the Clob value will be increased to accommodate the extra characters.

Note

If the value specified for pos is greater than the length+1 of the CLOB value then the behavior is undefined. Some JDBC drivers may throw an SQLException while other drivers may support this operation.

Parameters
pos:long

the position at which to start writing to this CLOB object; The first position is 1

Returns:OutputStream

the stream to which ASCII encoded characters can be written

Exceptions
SQLException:
if there is an error accessing the CLOB value or if pos is less than 1
setCharacterStreamback to summary
public Writer setCharacterStream(long pos) throws SQLException

Implements java.sql.Clob.setCharacterStream.

Doc from java.sql.Clob.setCharacterStream.

Retrieves a stream to be used to write a stream of Unicode characters to the CLOB value that this Clob object represents, at position pos. Characters written to the stream will overwrite the existing characters in the Clob object starting at the position pos. If the end of the Clob value is reached while writing characters to the stream, then the length of the Clob value will be increased to accommodate the extra characters.

Note

If the value specified for pos is greater than the length+1 of the CLOB value then the behavior is undefined. Some JDBC drivers may throw an SQLException while other drivers may support this operation.

Parameters
pos:long

the position at which to start writing to the CLOB value; The first position is 1

Returns:Writer

a stream to which Unicode encoded characters can be written

Exceptions
SQLException:
if there is an error accessing the CLOB value or if pos is less than 1
setStringback to summary
public int setString(long pos, String str) throws SQLException

Implements java.sql.Clob.setString.

Doc from java.sql.Clob.setString.

Writes the given Java String to the CLOB value that this Clob object designates at the position pos. The string will overwrite the existing characters in the Clob object starting at the position pos. If the end of the Clob value is reached while writing the given string, then the length of the Clob value will be increased to accommodate the extra characters.

Note

If the value specified for pos is greater than the length+1 of the CLOB value then the behavior is undefined. Some JDBC drivers may throw an SQLException while other drivers may support this operation.

Parameters
pos:long

the position at which to start writing to the CLOB value that this Clob object represents; the first position is 1.

str:String

the string to be written to the CLOB value that this Clob designates

Returns:int

the number of characters written

Exceptions
SQLException:
if there is an error accessing the CLOB value or if pos is less than 1
setStringback to summary
public int setString(long pos, String str, int offset, int len) throws SQLException

Implements java.sql.Clob.setString.

Doc from java.sql.Clob.setString.

Writes len characters of str, starting at character offset, to the CLOB value that this Clob represents. The string will overwrite the existing characters in the Clob object starting at the position pos. If the end of the Clob value is reached while writing the given string, then the length of the Clob value will be increased to accommodate the extra characters.

Note

If the value specified for pos is greater than the length+1 of the CLOB value then the behavior is undefined. Some JDBC drivers may throw an SQLException while other drivers may support this operation.

Parameters
pos:long

the position at which to start writing to this CLOB object; The first position is 1

str:String

the string to be written to the CLOB value that this Clob object represents

offset:int

the offset into str to start reading the characters to be written

len:int

the number of characters to be written

Returns:int

the number of characters written

Exceptions
SQLException:
if there is an error accessing the CLOB value or if pos is less than 1
setStringXback to summary
pack-priv int setStringX(long pos, String str, int offset, int len) throws SqlException
truncateback to summary
public void truncate(long len) throws SQLException

Implements java.sql.Clob.truncate.

Doc from java.sql.Clob.truncate.

Truncates the CLOB value that this Clob designates to have a length of len characters.

Note

If the value specified for pos is greater than the length+1 of the CLOB value then the behavior is undefined. Some JDBC drivers may throw an SQLException while other drivers may support this operation.

Parameters
len:long

the length, in characters, to which the CLOB value should be truncated

Exceptions
SQLException:
if there is an error accessing the CLOB value or if len is less than 0