org.h2.mvstore.type

## Class ObjectDataType

- java.lang.Object
- - org.h2.mvstore.type.ObjectDataType

All Implemented Interfaces:
  DataType

    public class ObjectDataType
    extends java.lang.Object
    implements DataType

A data type implementation for the most common data types, including serializable objects.

### Constructor Summary

Constructors
Constructor and Description
`ObjectDataType()`

### Method Summary

Methods
`int` `compare(java.lang.Object a, java.lang.Object b)` Compare two keys.
`static int` `compareNotNull(byte[] data1, byte[] data2)` Compare the contents of two byte arrays.
`static java.lang.Object` `deserialize(byte[] data)` De-serialize the byte array to an object.
`int` `getMemory(java.lang.Object obj)` Estimate the used memory in bytes.
`java.lang.Object` `read(java.nio.ByteBuffer buff)` Read an object.
`void` `read(java.nio.ByteBuffer buff, java.lang.Object[] obj, int len, boolean key)` Read a list of objects.
`static byte[]` `serialize(java.lang.Object obj)` Serialize the object to a byte array.
`void` `write(WriteBuffer buff, java.lang.Object obj)` Write an object.
`void` `write(WriteBuffer buff, java.lang.Object[] obj, int len, boolean key)` Write a list of objects.

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

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

### Constructor Detail

#### ObjectDataType

    public ObjectDataType()

### Method Detail

#### compare

    public int compare(java.lang.Object a,
              java.lang.Object b)

Description copied from interface: `DataType`
Compare two keys.

Specified by:
  `compare` in interface `DataType`
Parameters:
  `a` - the first key
  `b` - the second key
Returns:
  -1 if the first key is smaller, 1 if larger, and 0 if equal

#### getMemory

    public int getMemory(java.lang.Object obj)

Description copied from interface: `DataType`
Estimate the used memory in bytes.

Specified by:
  `getMemory` in interface `DataType`
Parameters:
  `obj` - the object
Returns:
  the used memory

#### read

    public void read(java.nio.ByteBuffer buff,
            java.lang.Object[] obj,
            int len,
            boolean key)

Description copied from interface: `DataType`
Read a list of objects.

Specified by:
  `read` in interface `DataType`
Parameters:
  `buff` - the target buffer
  `obj` - the objects
  `len` - the number of objects to read
  `key` - whether the objects are keys

#### write

    public void write(WriteBuffer buff,
             java.lang.Object[] obj,
             int len,
             boolean key)

Description copied from interface: `DataType`
Write a list of objects.

Specified by:
  `write` in interface `DataType`
Parameters:
  `buff` - the target buffer
  `obj` - the objects
  `len` - the number of objects to write
  `key` - whether the objects are keys

#### write

    public void write(WriteBuffer buff,
             java.lang.Object obj)

Description copied from interface: `DataType`
Write an object.

Specified by:
  `write` in interface `DataType`
Parameters:
  `buff` - the target buffer
  `obj` - the value

#### read

    public java.lang.Object read(java.nio.ByteBuffer buff)

Description copied from interface: `DataType`
Read an object.

Specified by:
  `read` in interface `DataType`
Parameters:
  `buff` - the source buffer
Returns:
  the object

#### serialize

    public static byte[] serialize(java.lang.Object obj)

Serialize the object to a byte array.

Parameters:
  `obj` - the object to serialize
Returns:
  the byte array

#### deserialize

    public static java.lang.Object deserialize(byte[] data)

De-serialize the byte array to an object.

Parameters:
  `data` - the byte array
Returns:
  the object

#### compareNotNull

    public static int compareNotNull(byte[] data1,
                     byte[] data2)

Compare the contents of two byte arrays. If the content or length of the first array is smaller than the second array, -1 is returned. If the content or length of the second array is smaller than the first array, 1 is returned. If the contents and lengths are the same, 0 is returned.

This method interprets bytes as unsigned.

Parameters:
  `data1` - the first byte array (must not be null)
  `data2` - the second byte array (must not be null)
Returns:
  the result of the comparison (-1, 1 or 0)