com.pivotal.gemfirexd.internal.client.am

## Class Lob

- java.lang.Object
- - com.pivotal.gemfirexd.internal.client.am.Lob

All Implemented Interfaces:
  UnitOfWorkListener

Direct Known Subclasses:
  Blob, Clob

    public abstract class Lob
    extends Object
    implements UnitOfWorkListener

### Field Summary

Fields
`protected Agent` `agent_`
`static int` `ASCII_STREAM`
`static int` `BINARY_STREAM`
`static int` `BINARY_STRING`
`static int` `CHARACTER_STREAM`
`protected String` `columnName`
`protected int` `dataType_`
`static int` `INVALID_LOCATOR`
`protected boolean` `isValid_` This boolean variable indicates whether the Lob object has been invalidated by calling free() on it
`protected static ClientMessageId` `LOB_OBJECT_LENGTH_UNKNOWN_YET`
`static int` `LOCATOR`
`protected int` `locator_`
`protected CallableLocatorProcedures` `locatorProcs_`
`static int` `STRING`
`static int` `UNICODE_STREAM`

### Constructor Summary

Constructors
`protected` `Lob(Agent agent, boolean willBeLayerBStreamed, String columnName)`

### Method Summary

Methods
`protected void` `checkPosAndLength(long pos, long 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.
`void` `completeLocalCommit(Iterator listenerIterator)`
`void` `completeLocalRollback(Iterator listenerIterator)`
`protected void` `finalize()`
`Agent` `getAgent()`
`int` `getLocator()` Get locator for this Lob
`protected void` `incrementUpdateCount()` Increments and returns the new updateCount of this `Lob`.
`protected static boolean` `isLayerBStreamingPossible(Agent agent)`
`static boolean` `isLengthObtained(Lob l)`
`boolean` `isLocator()` Check whether this Lob is based on a locator
`abstract long` `length()`
`void` `listenToUnitOfWork()`
`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` `materializeStream(InputStream is, String typeDesc)` Materialize the given stream into memory and update the internal length variable.
`boolean` `willBeLayerBStreamed()`

### Methods inherited from class java.lang.Object

`clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### STRING

    public static final int STRING

See Also:
  Constant Field Values

#### ASCII_STREAM

    public static final int ASCII_STREAM

See Also:
  Constant Field Values

#### UNICODE_STREAM

    public static final int UNICODE_STREAM

See Also:
  Constant Field Values

#### CHARACTER_STREAM

    public static final int CHARACTER_STREAM

See Also:
  Constant Field Values

#### BINARY_STREAM

    public static final int BINARY_STREAM

See Also:
  Constant Field Values

#### BINARY_STRING

    public static final int BINARY_STRING

See Also:
  Constant Field Values

#### LOCATOR

    public static final int LOCATOR

See Also:
  Constant Field Values

#### INVALID_LOCATOR

    public static final int INVALID_LOCATOR

See Also:
  Constant Field Values

#### agent_

    protected Agent agent_

#### dataType_

    protected int dataType_

#### locator_

    protected int locator_

#### isValid_

    protected boolean isValid_

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

#### LOB_OBJECT_LENGTH_UNKNOWN_YET

    protected static final ClientMessageId LOB_OBJECT_LENGTH_UNKNOWN_YET

#### locatorProcs_

    protected final CallableLocatorProcedures locatorProcs_

#### columnName

    protected final String columnName

### Constructor Detail

#### Lob

    protected Lob(Agent agent,
       boolean willBeLayerBStreamed,
       String columnName)

### Method Detail

#### finalize

    protected void finalize()
                     throws Throwable

Overrides:
  `finalize` in class `Object`
Throws:
  `Throwable`

#### listenToUnitOfWork

    public void listenToUnitOfWork()

Specified by:
  `listenToUnitOfWork` in interface `UnitOfWorkListener`

#### completeLocalCommit

    public void completeLocalCommit(Iterator listenerIterator)

Specified by:
  `completeLocalCommit` in interface `UnitOfWorkListener`

#### completeLocalRollback

    public void completeLocalRollback(Iterator listenerIterator)

Specified by:
  `completeLocalRollback` in interface `UnitOfWorkListener`

#### getAgent

    public Agent getAgent()

#### materializeStream

    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.

Throws:
  `SqlException`

#### materializeStream

    protected InputStream materializeStream(InputStream is,
                                String typeDesc)
                                     throws SqlException

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

Parameters:
  `is` - stream to use for input
  `typeDesc` - description of the data type we are inserting, for instance `java.sql.Clob`
Returns:
  a stream whose source is the materialized data
Throws:
  `SqlException` - if the stream exceeds 2 GB, or an error happens while reading from the stream

#### isLengthObtained

    public static boolean isLengthObtained(Lob l)

#### length

    public abstract long length()
                         throws SQLException

Throws:
  `SQLException`

#### isLayerBStreamingPossible

    protected static boolean isLayerBStreamingPossible(Agent agent)

#### willBeLayerBStreamed

    public boolean willBeLayerBStreamed()

#### isLocator

    public boolean isLocator()

Check whether this Lob is based on a locator

Returns:
  true if Lob is based on locator, false otherwise

#### getLocator

    public int getLocator()

Get locator for this Lob

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

#### checkPosAndLength

    protected void checkPosAndLength(long pos,
                         long length)
                              throws SQLException

Checks the `pos` and `length`.

Parameters:
  `pos` - a long that contains the position that needs to be checked
  `length` - a long that contains the length that needs to be checked
Throws:
  `SQLException` - if a) pos <= 0 b) pos > (length of LOB) c) length < 0 d) pos + length > (length of LOB)

#### incrementUpdateCount

    protected 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

#### checkValidity

    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.

Throws:
  `SQLException` - if isValid is not true or the transaction that created the Lob is not active