Package org.apache.derby.client.am
Class ClientClob
java.lang.Object
org.apache.derby.client.am.Lob
org.apache.derby.client.am.ClientClob
- All Implemented Interfaces:
Clob
,UnitOfWorkListener
This class implements the JDBC
java.sql.Clob
interface.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate InputStream
private Reader
protected String
private InputStream
private byte[]
Fields inherited from class org.apache.derby.client.am.Lob
agent_, ASCII_STREAM, BINARY_STREAM, BINARY_STRING, CHARACTER_STREAM, dataType_, INVALID_LOCATOR, isValid_, LOCATOR, locator_, STRING, UNICODE_STREAM
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
ClientClob
(Agent agent, boolean willBeLayerBStreamed) ClientClob
(Agent agent, byte[] unconvertedBytes, Charset charset, int dataOffset) ClientClob
(Agent agent, int locator) Create aClientClob
object for a Clob value stored on the server and indentified bylocator
.(package private)
ClientClob
(Agent agent, InputStream inputStream, Charset encoding) Create aClientClob
of unknown length with the specified encoding.ClientClob
(Agent agent, InputStream inputStream, Charset encoding, int length) (package private)
ClientClob
(Agent agent, Reader reader) Create aClientClob
of unknown length.(package private)
ClientClob
(Agent agent, Reader reader, int length) ClientClob
(Agent agent, String string) -
Method Summary
Modifier and TypeMethodDescriptionvoid
free()
This method frees theClob
object and releases the resources the resources that it holds.(package private) InputStream
getCharacterStream
(long pos, long length) Returns aReader
object that contains a partialClob
value, starting with the character specified by pos, which is length characters in length.(package private) Reader
(package private) long
Get the length in bytes of theClob
value represented by this locator basedClob
object.getSubString
(long pos, int length) Returns a copy of the specified substring in theCLOB
value designated by thisClientClob
object.private String
getSubStringX
(long pos, int length) int
byte[]
boolean
boolean
boolean
isString()
boolean
long
length()
protected void
Materialize the stream used for input to the database.long
long
private long
private long
(package private) void
reInitForNonLocator
(String newString) Reinitialize the value of this CLOB.setAsciiStream
(long pos) setCharacterStream
(long pos) int
int
(package private) int
setStringX
(long pos, String str, int offset, int len) void
truncate
(long len) Methods inherited from class org.apache.derby.client.am.Lob
checkForClosedConnection, checkForLocatorValidity, checkPosAndLength, checkValidity, completeLocalCommit, completeLocalRollback, getAgent, getLocator, getUpdateCount, incrementUpdateCount, isLayerBStreamingPossible, isLocator, listenToUnitOfWork, materializeStream, setSqlLength, sqlLength, willBeLayerBStreamed
-
Field Details
-
string_
-
asciiStream_
-
unicodeStream_
-
characterStream_
-
utf8String_
private byte[] utf8String_
-
-
Constructor Details
-
ClientClob
-
ClientClob
public ClientClob(Agent agent, byte[] unconvertedBytes, Charset charset, int dataOffset) throws SqlException - Throws:
SqlException
-
ClientClob
-
ClientClob
ClientClob(Agent agent, InputStream inputStream, Charset encoding) throws SqlException Create aClientClob
of unknown length with the specified encoding. This constructor was added to support the JDBC 4 length less overloads. Note that aClientClob
created with this constructor is made for input to the database only. Do not pass it out to the user!- Parameters:
agent
-inputStream
- the data to insertencoding
- encoding to use for characters. Only "ISO-8859-1" is allowed.- Throws:
SqlException
-
ClientClob
-
ClientClob
Create aClientClob
object for a Clob value stored on the server and indentified bylocator
.- Parameters:
agent
- context for thisClob
object (incl. connection).locator
- reference id toClob
value on server.
-
ClientClob
Create aClientClob
of unknown length. This constructor was added to support the JDBC 4 length less overloads. Note that aClientClob
created with this constructor is made for input to the database only. Do not pass it out to the user!- Parameters:
agent
-reader
- the data to insert
-
ClientClob
-
-
Method Details
-
length
- Specified by:
length
in interfaceClob
- Specified by:
length
in classLob
- Throws:
SQLException
-
getSubString
Returns a copy of the specified substring in theCLOB
value designated by thisClientClob
object. The substring begins at positionpos
and has up tolength
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.- Specified by:
getSubString
in interfaceClob
- Parameters:
pos
- the first character of the substring to be extracted. The first character is at position 1.length
- the number of consecutive characters to be copied- Returns:
- a
String
that is the specified substring in theCLOB
value designated by thisClientClob
object - Throws:
SQLException
- if there is an error accessing theCLOB
NOTE: If the starting position is the length of the CLOB plus 1, zero characters are returned regardless of the length requested.
-
getSubStringX
- Throws:
SqlException
-
getCharacterStream
- Specified by:
getCharacterStream
in interfaceClob
- Throws:
SQLException
-
getCharacterStreamX
- Throws:
SqlException
-
getAsciiStream
- Specified by:
getAsciiStream
in interfaceClob
- Throws:
SQLException
-
getAsciiStreamX
- Throws:
SqlException
-
position
- Specified by:
position
in interfaceClob
- Throws:
SQLException
-
positionX
- Throws:
SqlException
-
position
- Specified by:
position
in interfaceClob
- Throws:
SQLException
-
positionX
- Throws:
SqlException
-
setString
- Specified by:
setString
in interfaceClob
- Throws:
SQLException
-
setString
- Specified by:
setString
in interfaceClob
- Throws:
SQLException
-
setStringX
- Throws:
SqlException
-
setAsciiStream
- Specified by:
setAsciiStream
in interfaceClob
- Throws:
SQLException
-
setCharacterStream
- Specified by:
setCharacterStream
in interfaceClob
- Throws:
SQLException
-
truncate
- Specified by:
truncate
in interfaceClob
- Throws:
SQLException
-
free
This method frees theClob
object and releases the resources the resources that it holds. The object is invalid once thefree
method is called. Iffree
is called multiple times, the subsequent calls tofree
are treated as a no-op.- Specified by:
free
in interfaceClob
- Throws:
SQLException
- if an error occurs releasing the Clob's resources
-
getCharacterStream
Returns aReader
object that contains a partialClob
value, starting with the character specified by pos, which is length characters in length.- Specified by:
getCharacterStream
in interfaceClob
- Parameters:
pos
- the offset to the first character of the partial value to be retrieved. The first character in the Clob is at position 1.length
- the length in characters of the partial value to be retrieved.- Returns:
Reader
through which the partialClob
value can be read.- Throws:
SQLException
- if pos is less than 1 or if pos is greater than the number of characters in theClob
or ifpos + length
is greater thanClob.length() +1
-
isString
public boolean isString() -
isAsciiStream
public boolean isAsciiStream() -
isCharacterStream
public boolean isCharacterStream() -
isUnicodeStream
public boolean isUnicodeStream() -
getUnicodeStream
-
getString
-
getUtf8String
public byte[] getUtf8String() -
getUTF8Length
public int getUTF8Length() -
reInitForNonLocator
Reinitialize the value of this CLOB. This is legacy code, only used when talking to servers that don't support locators.- Parameters:
newString
- the new value
-
materializeStream
Materialize the stream used for input to the database.- Specified by:
materializeStream
in classLob
- Throws:
SqlException
-
getLocatorLength
Get the length in bytes of theClob
value represented by this locator basedClob
object. A stored procedure call will be made to get it from the server.- Overrides:
getLocatorLength
in classLob
- Returns:
- length of
Clob
in bytes - Throws:
SqlException
-