## org.h2.value
Class ValueLob

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

    public class ValueLob

extends Value

Implementation of the BLOB and CLOB data types. Small objects are kept in memory and stored in the record. Large objects are stored in their own files. When large objects are set in a prepared statement, they are first stored as 'temporary' files. Later, when they are used in a record, and when the record is stored, the lob files are linked: the file is renamed using the file format (tableId).(objectId). There is one exception: large variables are stored in the file (-1).(objectId). When lobs are deleted, they are first renamed to a temp file, and if the delete operation is committed the file is deleted. Data compression is supported.

Nested Class Summary

Nested classes/interfaces inherited from class org.h2.value.Value
`Value.ValueBlob, Value.ValueClob`

Field Summary

Fields inherited from class org.h2.value.Value
`ARRAY, BLOB, BOOLEAN, BYTE, BYTES, CLOB, DATE, DECIMAL, DOUBLE, FLOAT, INT, JAVA_OBJECT, LONG, NULL, RESULT_SET, SHORT, STRING, STRING_FIXED, STRING_IGNORECASE, TIME, TIMESTAMP, TYPE_COUNT, UNKNOWN, UUID`

Method Summary
`void` `close()` Close the underlying resource, if any.
`protected int` `compareSecure(Value v, CompareMode mode)` Compare the value with another value of the same type.
`Value` `convertPrecision(long precision, boolean force)` Convert the precision to the requested value.
`Value` `convertTo(int t)` Convert a lob to another data type.
`void` `convertToFileIfRequired(DataHandler h)` Store the lob data to a file if the size of the buffer it larger than the maximum size for an in-place lob.
`ValueLob` `copyToTemp()` Create an independent copy of this temporary value.
`static ValueLob` `createBlob(java.io.InputStream in, long length, DataHandler handler)` Create a BLOB value from a stream.
`static ValueLob` `createClob(java.io.Reader in, long length, DataHandler handler)` Create a CLOB value from a stream.
`static ValueLob` `createSmallLob(int type, byte[] small)` Create a small lob using the given byte array.
`boolean` `equals(java.lang.Object other)` Check if the two values have the same hash code.
`byte[]` `getBytes()`
`byte[]` `getBytesNoCopy()`
`int` `getDisplaySize()` Get the display size in characters.
`java.lang.String` `getFileName()` Get the current file name where the lob is saved.
`java.io.InputStream` `getInputStream()`
`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.
`long` `getPrecision()` Get the precision.
`java.io.Reader` `getReader()`
`byte[]` `getSmall()` Get the data if this a small lob value.
`java.lang.String` `getSQL()` Get the SQL expression for this value.
`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.
`int` `getType()` Get the value type.
`int` `hashCode()`
`boolean` `isFileBased()` Check if this value is stored in it's own file.
`boolean` `isLinked()` Check if this value is linked to a specific table.
`Value` `link(DataHandler h, int tabId)` Link a large value to a given table.
`static ValueLob` `open(int type, DataHandler handler, int tableId, int objectId, long precision, boolean compression)` Create a LOB value with the given parameters.
`static void` `removeAllForTable(DataHandler handler, int tableId)` Remove all lobs for a given table id.
`static void` `resetDirCounter()` Reset the directory counter as if the process was stopped.
`void` `set(java.sql.PreparedStatement prep, int parameterIndex)` Set the value as a parameter in a prepared statement.
`void` `setFileName(java.lang.String fileName, boolean linked)` Set the file name of this lob value.
`void` `unlink()` Mark any underlying resource as 'not linked to any table'.
`boolean` `useCompression()` Check if this lob value is compressed.

Methods inherited from class org.h2.value.Value
`add, checkPrecision, clearCache, compareTo, compareTypeSave, convertScale, divide, getBigDecimal, getBoolean, getByte, getDate, getDateNoCopy, getDouble, getFloat, getHigherOrder, getInt, getLong, getScale, getShort, getSignum, getTime, getTimeNoCopy, getTimestamp, getTimestampNoCopy, modulus, multiply, negate, subtract, throwUnsupportedExceptionForType, toString`

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

Method Detail

### createSmallLob

    public static ValueLob createSmallLob(int type,
                                          byte[] small)

  Create a small lob using the given byte array.

  Parameters:
    `type` - the type (Value.BLOB or CLOB)
    `small` - the byte array
  Returns:
    the lob value

### open

    public static ValueLob open(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
    `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

### createClob

    public static ValueLob createClob(java.io.Reader in,
                                      long length,
                                      DataHandler handler)

  Create a CLOB value from a stream.

  Parameters:
    `in` - the reader
    `length` - the number of characters to read, or -1 for no limit
    `handler` - the data handler
  Returns:
    the lob value

### resetDirCounter

    public static void resetDirCounter()

  Reset the directory counter as if the process was stopped. This method is for debugging only (to simulate stopping a process).

### createBlob

    public static ValueLob createBlob(java.io.InputStream in,
                                      long length,
                                      DataHandler handler)

  Create a BLOB value from a stream.

  Parameters:
    `in` - the input stream
    `length` - the number of characters to read, or -1 for no limit
    `handler` - the data handler
  Returns:
    the lob value

### convertTo

    public Value convertTo(int t)

  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
  Returns:
    the converted value

### isLinked

    public boolean isLinked()

  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:
    `isLinked` 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

### close

    public void close()

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

  Overrides:
    `close` in class `Value`

### unlink

    public void unlink()

  Description copied from class: `Value`
  Mark any underlying resource as 'not linked to any table'. For values that are kept fully in memory this method has no effect.

  Overrides:
    `unlink` in class `Value`

### link

    public Value link(DataHandler h,
                      int tabId)

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

  Overrides:
    `link` in class `Value`
  Parameters:
    `h` - the data handler
    `tabId` - the table to link to
  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 int getType()

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

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

### getPrecision

    public long getPrecision()

  Description copied from class: `Value`
  Get the precision.

  Specified by:
    `getPrecision` in class `Value`
  Returns:
    the precision

### 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`

### compareSecure

    protected int compareSecure(Value v,
                                CompareMode mode)

  Description copied from class: `Value`
  Compare the value with another value of the same type.

  Specified by:
    `compareSecure` 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`

### getInputStream

    public java.io.InputStream getInputStream()

  Overrides:
    `getInputStream` in class `Value`

### 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.String getSQL()

  Description copied from class: `Value`
  Get the SQL expression for this value.

  Specified by:
    `getSQL` in class `Value`
  Returns:
    the SQL expression

### 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

### getDisplaySize

    public int getDisplaySize()

  Description copied from class: `Value`
  Get the display size in characters.

  Specified by:
    `getDisplaySize` in class `Value`
  Returns:
    the display size

### 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

### convertToFileIfRequired

    public void convertToFileIfRequired(DataHandler h)

  Store the lob data to a file if the size of the buffer it larger than the maximum size for an in-place lob.

  Parameters:
    `h` - the data handler

### removeAllForTable

    public static void removeAllForTable(DataHandler handler,
                                         int tableId)

  Remove all lobs for a given table id.

  Parameters:
    `handler` - the data handler
    `tableId` - the table id

### useCompression

    public boolean useCompression()

  Check if this lob value is compressed.

  Returns:
    true if it is

### isFileBased

    public boolean isFileBased()

  Description copied from class: `Value`
  Check if this value is stored in it's own file. For values that are kept fully in memory, this method returns false.

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

### setFileName

    public void setFileName(java.lang.String fileName,
                            boolean linked)

  Set the file name of this lob value.

  Parameters:
    `fileName` - the file name
    `linked` - if the lob is linked

### 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 ValueLob 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