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

public abstract Class Lob

extends Object
implements UnitOfWorkListener
Class Inheritance
All Implemented Interfaces
org.apache.derby.client.am.UnitOfWorkListener
Known Direct Subclasses
org.apache.derby.client.am.ClientBlob, org.apache.derby.client.am.ClientClob
Imports
java.io.InputStream, .IOException, java.sql.SQLException, java.util.ArrayList, .Iterator, org.apache.derby.client.net.NetConfiguration, .NetConnection, org.apache.derby.shared.common.reference.SQLState

Field Summary

Modifier and TypeField and Description
protected Agent
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
protected int
public static final int
protected boolean
isValid_

This boolean variable indicates whether the Lob object has been invalidated by calling free() on it

private boolean
private static final ClientMessageId
pack-priv static final int
protected int
private long
pack-priv static final int
private int
transactionID_

This integer identifies which transaction the Lob is associated with

pack-priv static final int
private long
private final boolean

Constructor Summary

AccessConstructor and Description
protected
Lob(Agent agent, boolean willBeLayerBStreamed)

Method Summary

Modifier and TypeMethod and Description
pack-priv void
pack-priv void
checkForLocatorValidity()

Calls SqlLength() to check if the Locator associated with the underlying Lob is valid.

protected void
checkPosAndLength(long
a long that contains the position that needs to be checked
pos
,
long
a long that contains the length that needs to be checked
length
)

Checks the pos and length.

protected void
checkValidity()

Checks if isValid is true and whether the transaction that created the Lob is still active.

public void
public void
public Agent
public int

Returns:

locator for this Lob, INVALID_LOCATOR if Lob is not based on locator
getLocator
()

Get locator for this Lob

pack-priv long

Returns:

length of Lob
getLocatorLength
()

Get the length of locator based Lob from the server.

pack-priv long
getUpdateCount()

Returns the current updateCount of the Clob.

protected synchronized void
incrementUpdateCount()

Increments and returns the new updateCount of this Lob.

protected static boolean
public boolean

Returns:

true if Lob is based on locator, false otherwise
isLocator
()

Check whether this Lob is based on a locator

public abstract long
public void
protected abstract void
materializeStream()

Method to be implemented by subclasses, so that #materializedStream(InputStream, String) can be called with subclass specific parameters and the result assigned to the right stream.

protected InputStream

Returns:

a stream whose source is the materialized data
materializeStream
(InputStream
stream to use for input
is
,
String
description of the data type we are inserting, for instance java.sql.Clob
typeDesc
)

Materialize the given stream into memory and update the internal length variable.

pack-priv void
setSqlLength(long
the new length of the Lob value
length
)

Update the registered length of the Lob value.

pack-priv long

Returns:

length of Lob value
sqlLength
()

Return the length of the Lob value represented by this Lob object.

public boolean
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

agent_back to summary
protected Agent agent_
ASCII_STREAMback to summary
pack-priv static final int ASCII_STREAM
BINARY_STREAMback to summary
pack-priv static final int BINARY_STREAM
BINARY_STRINGback to summary
pack-priv static final int BINARY_STRING
CHARACTER_STREAMback to summary
pack-priv static final int CHARACTER_STREAM
dataType_back to summary
protected int dataType_
INVALID_LOCATORback to summary
public static final int INVALID_LOCATOR
isValid_back to summary
protected boolean isValid_

This boolean variable indicates whether the Lob object has been invalidated by calling free() on it

lengthObtained_back to summary
private boolean lengthObtained_
LOB_OBJECT_LENGTH_UNKNOWN_YETback to summary
private static final ClientMessageId LOB_OBJECT_LENGTH_UNKNOWN_YET
LOCATORback to summary
pack-priv static final int LOCATOR
locator_back to summary
protected int locator_
sqlLength_back to summary
private long sqlLength_
STRINGback to summary
pack-priv static final int STRING
transactionID_back to summary
private int transactionID_

This integer identifies which transaction the Lob is associated with

UNICODE_STREAMback to summary
pack-priv static final int UNICODE_STREAM
updateCountback to summary
private long updateCount
willBeLayerBStreamed_back to summary
private final boolean willBeLayerBStreamed_

Constructor Detail

Lobback to summary
protected Lob(Agent agent, boolean willBeLayerBStreamed)

Method Detail

checkForClosedConnectionback to summary
pack-priv void checkForClosedConnection() throws SqlException
checkForLocatorValidityback to summary
pack-priv void checkForLocatorValidity() throws SqlException

Calls SqlLength() to check if the Locator associated with the underlying Lob is valid. If it is not it throws an exception.

checkPosAndLengthback to summary
protected void checkPosAndLength(long pos, long length) throws SQLException

Checks the pos and length.

Parameters
pos:long

a long that contains the position that needs to be checked

length:long

a long that contains the length that needs to be checked

Exceptions
SQLException:
if a) pos <= 0 b) pos > (length of LOB) c) length < 0 d) (pos -1) + length > (length of LOB)
checkValidityback to summary
protected void checkValidity() throws SQLException

Checks if isValid is true and whether the transaction that created the Lob is still active. If any of which is not true throws a SQLException stating that a method has been called on an invalid LOB object.

Exceptions
SQLException:
if isValid is not true or the transaction that created the Lob is not active
completeLocalCommitback to summary
public void completeLocalCommit(Iterator<E> listenerIterator)

Implements org.apache.derby.client.am.UnitOfWorkListener.completeLocalCommit.

completeLocalRollbackback to summary
public void completeLocalRollback(Iterator<E> listenerIterator)

Implements org.apache.derby.client.am.UnitOfWorkListener.completeLocalRollback.

getAgentback to summary
public Agent getAgent()
getLocatorback to summary
public int getLocator()

Get locator for this Lob

Returns:int

locator for this Lob, INVALID_LOCATOR if Lob is not based on locator

getLocatorLengthback to summary
pack-priv long getLocatorLength() throws SqlException

Get the length of locator based Lob from the server. This is a dummy implementation that is supposed to be overridden by subclasses. A stored procedure call will be made to get the length from the server.

Returns:long

length of Lob

getUpdateCountback to summary
pack-priv long getUpdateCount()

Returns the current updateCount of the Clob.

incrementUpdateCountback to summary
protected synchronized void incrementUpdateCount()

Increments and returns the new updateCount of this Lob. The method needs to be synchronized since multiple updates can happen on this Lob simultaneously. It will be called from the 1) Locator Writers 2) Locator OutputStreams 3) From the update methods within the Lobs like setString, truncate. since all of the above acesses are inside the am package, this method will have default access. We do not need to worry about the non-locator streams since non-locator InputStreams would not depend on updateCount for invalidation

isLayerBStreamingPossibleback to summary
protected static boolean isLayerBStreamingPossible(Agent agent)
isLocatorback to summary
public boolean isLocator()

Check whether this Lob is based on a locator

Returns:boolean

true if Lob is based on locator, false otherwise

lengthback to summary
public abstract long length() throws SQLException
listenToUnitOfWorkback to summary
public void listenToUnitOfWork()

Implements org.apache.derby.client.am.UnitOfWorkListener.listenToUnitOfWork.

materializeStreamback to summary
protected abstract void materializeStream() throws SqlException

Method to be implemented by subclasses, so that #materializedStream(InputStream, String) can be called with subclass specific parameters and the result assigned to the right stream.

Exceptions
SqlException:
on error
materializeStreamback to summary
protected InputStream materializeStream(InputStream is, String typeDesc) throws SqlException

Materialize the given stream into memory and update the internal length variable.

Parameters
is:InputStream

stream to use for input

typeDesc:String

description of the data type we are inserting, for instance java.sql.Clob

Returns:InputStream

a stream whose source is the materialized data

Exceptions
SqlException:
if the stream exceeds 2 GB, or an error happens while reading from the stream
setSqlLengthback to summary
pack-priv void setSqlLength(long length)

Update the registered length of the Lob value. To be called by methods that make changes to the length of the Lob.

Note

The caller needs to deal with synchronization.

Parameters
length:long

the new length of the Lob value

sqlLengthback to summary
pack-priv long sqlLength() throws SqlException

Return the length of the Lob value represented by this Lob object. If length is not already known, and Lob is locator based, length will be retrieved from the server. If not, locator based, Lob will first be materialized.

Note

The caller needs to deal with synchronization.

Returns:long

length of Lob value

Exceptions
SqlException:
on execution errors while materializing the stream, or if Layer B streaming is used and length not yet obtained.
willBeLayerBStreamedback to summary
public boolean willBeLayerBStreamed()