org.h2.value

## Class ValueLob

- java.lang.Object
- - org.h2.value.VersionedValue
  - - org.h2.value.Value
    - - org.h2.value.ValueLob

    public class ValueLob
    extends Value

This is the legacy implementation of LOBs for PageStore databases where the LOB was stored in an external file.

### Field Summary

### Fields inherited from class org.h2.value.Value

`ARRAY, BLOB, BOOLEAN, BYTE, BYTES, CLOB, DATE, DECIMAL, DOUBLE, ENUM, FLOAT, GEOMETRY, INT, INTERVAL_DAY, INTERVAL_DAY_TO_HOUR, INTERVAL_DAY_TO_MINUTE, INTERVAL_DAY_TO_SECOND, INTERVAL_HOUR, INTERVAL_HOUR_TO_MINUTE, INTERVAL_HOUR_TO_SECOND, INTERVAL_MINUTE, INTERVAL_MINUTE_TO_SECOND, INTERVAL_MONTH, INTERVAL_SECOND, INTERVAL_YEAR, INTERVAL_YEAR_TO_MONTH, JAVA_OBJECT, LONG, MIN_LONG_DECIMAL, NULL, RESULT_SET, ROW, SHORT, STRING, STRING_FIXED, STRING_IGNORECASE, TIME, TIMESTAMP, TIMESTAMP_TZ, TYPE_COUNT, UNKNOWN, UUID`

### Fields inherited from class org.h2.value.VersionedValue

`DUMMY`

### Method Summary

Methods
`int` `compareTypeSafe(Value v, CompareMode mode)` Compare this value against another value given that the values are of the same data type.
`Value` `convertPrecision(long precision, boolean force)` Convert the precision to the requested value.
`protected Value` `convertTo(int t, Mode mode, java.lang.Object column, ExtTypeInfo extTypeInfo)` Convert a lob to another data type.
`Value` `copy(DataHandler h, int tabId)` Copy a large value, to be used in the given table.
`ValueLobDb` `copyToTemp()` Create an independent copy of this temporary value.
`boolean` `equals(java.lang.Object other)` Check if the two values have the same hash code.
`byte[]` `getBytes()`
`byte[]` `getBytesNoCopy()`
`java.lang.String` `getFileName()` Get the current file name where the lob is saved.
`java.io.InputStream` `getInputStream()`
`java.io.InputStream` `getInputStream(long oneBasedOffset, long length)` Get the input stream
`int` `getMemory()` Get the memory used by this object.
`java.lang.Object` `getObject()` Get the value as an object.
`int` `getObjectId()` Get the current object id of this lob.
`java.io.Reader` `getReader()`
`java.io.Reader` `getReader(long oneBasedOffset, long length)` Get the reader
`byte[]` `getSmall()` Get the data if this a small lob value.
`java.lang.StringBuilder` `getSQL(java.lang.StringBuilder builder)` Appends the SQL expression for this value to the specified builder.
`java.lang.String` `getString()` Get the value as a string.
`int` `getTableId()` Get the current table id of this lob.
`java.lang.String` `getTraceSQL()` Get a medium size SQL expression for debugging or tracing.
`TypeInfo` `getType()` Returns the data type.
`int` `getValueType()` Get the value type.
`int` `hashCode()`
`boolean` `isCompressed()` Check if this lob value is compressed.
`boolean` `isLinkedToTable()` Check if this value is linked to a specific table.
`static ValueLob` `openLinked(int type, DataHandler handler, int tableId, int objectId, long precision, boolean compression)` Create a LOB value with the given parameters.
`static ValueLob` `openUnlinked(int type, DataHandler handler, int tableId, int objectId, long precision, boolean compression, java.lang.String fileName)` Create a LOB value with the given parameters.
`void` `remove()` Remove the underlying resource, if any.
`void` `set(java.sql.PreparedStatement prep, int parameterIndex)` Set the value as a parameter in a prepared statement.

### Methods inherited from class org.h2.value.Value

`add, checkPrecision, clearCache, compareTo, compareWithNull, containsNull, convertScale, convertTo, convertTo, convertTo, convertToInt, copyToResult, divide, getBigDecimal, getBoolean, getByte, getDataHandler, getDate, getDouble, getFloat, getHigherOrder, getHigherType, getInt, getLong, getResult, getShort, getSignum, getSQL, getTime, getTimestamp, getUnsupportedExceptionForOperation, modulus, multiply, negate, subtract, toString`

### Methods inherited from class org.h2.value.VersionedValue

`getCommittedValue, getCurrentValue, getOperationId, isCommitted`

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

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

### Method Detail

#### openLinked

    public static ValueLob openLinked(int type,
                      DataHandler handler,
                      int tableId,
                      int objectId,
                      long precision,
                      boolean compression)

Create a LOB value with the given parameters.

Parameters:
  `type` - the data type, either Value.BLOB or Value.CLOB
  `handler` - the file handler
  `tableId` - the table object id
  `objectId` - the object id
  `precision` - the precision (length in elements)
  `compression` - if compression is used
Returns:
  the value object

#### openUnlinked

    public static ValueLob openUnlinked(int type,
                        DataHandler handler,
                        int tableId,
                        int objectId,
                        long precision,
                        boolean compression,
                        java.lang.String fileName)

Create a LOB value with the given parameters.

Parameters:
  `type` - the data type, either Value.BLOB or Value.CLOB
  `handler` - the file handler
  `tableId` - the table object id
  `objectId` - the object id
  `precision` - the precision (length in elements)
  `compression` - if compression is used
  `fileName` - the file name
Returns:
  the value object

#### convertTo

    protected Value convertTo(int t,
                  Mode mode,
                  java.lang.Object column,
                  ExtTypeInfo extTypeInfo)

Convert a lob to another data type. The data is fully read in memory except when converting to BLOB or CLOB.

Overrides:
  `convertTo` in class `Value`
Parameters:
  `t` - the new type
  `mode` - the database mode
  `column` - the column (if any), used for to improve the error message if conversion fails
  `extTypeInfo` - the extended data type information, or null
Returns:
  the converted value

#### isLinkedToTable

    public boolean isLinkedToTable()

Description copied from class: `Value`
Check if this value is linked to a specific table. For values that are kept fully in memory, this method returns false.

Overrides:
  `isLinkedToTable` in class `Value`
Returns:
  true if it is

#### getFileName

    public java.lang.String getFileName()

Get the current file name where the lob is saved.

Returns:
  the file name or null

#### remove

    public void remove()

Description copied from class: `Value`
Remove the underlying resource, if any. For values that are kept fully in memory this method has no effect.

Overrides:
  `remove` in class `Value`

#### copy

    public Value copy(DataHandler h,
             int tabId)

Description copied from class: `Value`
Copy a large value, to be used in the given table. For values that are kept fully in memory this method has no effect.

Overrides:
  `copy` in class `Value`
Parameters:
  `h` - the data handler
  `tabId` - the table where this object is used
Returns:
  the new value or itself

#### getTableId

    public int getTableId()

Get the current table id of this lob.

Overrides:
  `getTableId` in class `Value`
Returns:
  the table id

#### getObjectId

    public int getObjectId()

Get the current object id of this lob.

Returns:
  the object id

#### getType

    public TypeInfo getType()

Description copied from class: `Value`
Returns the data type.

Specified by:
  `getType` in class `Value`
Returns:
  the data type

#### getValueType

    public int getValueType()

Description copied from class: `Value`
Get the value type.

Specified by:
  `getValueType` in class `Value`
Returns:
  the value type

#### getString

    public java.lang.String getString()

Description copied from class: `Value`
Get the value as a string.

Specified by:
  `getString` in class `Value`
Returns:
  the string

#### getBytes

    public byte[] getBytes()

Overrides:
  `getBytes` in class `Value`

#### getBytesNoCopy

    public byte[] getBytesNoCopy()

Overrides:
  `getBytesNoCopy` in class `Value`

#### hashCode

    public int hashCode()

Specified by:
  `hashCode` in class `Value`

#### compareTypeSafe

    public int compareTypeSafe(Value v,
                      CompareMode mode)

Description copied from class: `Value`
Compare this value against another value given that the values are of the same data type.

Specified by:
  `compareTypeSafe` in class `Value`
Parameters:
  `v` - the other value
  `mode` - the compare mode
Returns:
  0 if both values are equal, -1 if the other value is smaller, and 1 otherwise

#### getObject

    public java.lang.Object getObject()

Description copied from class: `Value`
Get the value as an object.

Specified by:
  `getObject` in class `Value`
Returns:
  the object

#### getReader

    public java.io.Reader getReader()

Overrides:
  `getReader` in class `Value`

#### getReader

    public java.io.Reader getReader(long oneBasedOffset,
                           long length)

Description copied from class: `Value`
Get the reader

Overrides:
  `getReader` in class `Value`
Parameters:
  `oneBasedOffset` - the offset (1 means no offset)
  `length` - the requested length
Returns:
  the new reader

#### getInputStream

    public java.io.InputStream getInputStream()

Overrides:
  `getInputStream` in class `Value`

#### getInputStream

    public java.io.InputStream getInputStream(long oneBasedOffset,
                                     long length)

Description copied from class: `Value`
Get the input stream

Overrides:
  `getInputStream` in class `Value`
Parameters:
  `oneBasedOffset` - the offset (1 means no offset)
  `length` - the requested length
Returns:
  the new input stream

#### set

    public void set(java.sql.PreparedStatement prep,
           int parameterIndex)
             throws java.sql.SQLException

Description copied from class: `Value`
Set the value as a parameter in a prepared statement.

Specified by:
  `set` in class `Value`
Parameters:
  `prep` - the prepared statement
  `parameterIndex` - the parameter index
Throws:
  `java.sql.SQLException`

#### getSQL

    public java.lang.StringBuilder getSQL(java.lang.StringBuilder builder)

Description copied from class: `Value`
Appends the SQL expression for this value to the specified builder.

Specified by:
  `getSQL` in class `Value`
Parameters:
  `builder` - string builder
Returns:
  the specified string builder

#### getTraceSQL

    public java.lang.String getTraceSQL()

Description copied from class: `Value`
Get a medium size SQL expression for debugging or tracing. If the precision is too large, only a subset of the value is returned.

Overrides:
  `getTraceSQL` in class `Value`
Returns:
  the SQL expression

#### getSmall

    public byte[] getSmall()

Get the data if this a small lob value.

Overrides:
  `getSmall` in class `Value`
Returns:
  the data

#### equals

    public boolean equals(java.lang.Object other)

Description copied from class: `Value`
Check if the two values have the same hash code. No data conversion is made; this method returns false if the other object is not of the same class. For some values, compareTo may return 0 even if equals return false. Example: ValueDecimal 0.0 and 0.00.

Specified by:
  `equals` in class `Value`
Parameters:
  `other` - the other value
Returns:
  true if they are equal

#### isCompressed

    public boolean isCompressed()

Check if this lob value is compressed.

Returns:
  true if it is

#### getMemory

    public int getMemory()

Description copied from class: `Value`
Get the memory used by this object.

Overrides:
  `getMemory` in class `Value`
Returns:
  the memory used in bytes

#### copyToTemp

    public ValueLobDb copyToTemp()

Create an independent copy of this temporary value. The file will not be deleted automatically.

Overrides:
  `copyToTemp` in class `Value`
Returns:
  the value

#### convertPrecision

    public Value convertPrecision(long precision,
                         boolean force)

Description copied from class: `Value`
Convert the precision to the requested value. The precision of the returned value may be somewhat larger than requested, because values with a fixed precision are not truncated.

Overrides:
  `convertPrecision` in class `Value`
Parameters:
  `precision` - the new precision
  `force` - true if losing numeric precision is allowed
Returns:
  the new value