org.h2.mvstore.type
Class ObjectType

java.lang.Object
  extended by org.h2.mvstore.type.ObjectType
All Implemented Interfaces:
DataType

public class ObjectType
extends java.lang.Object
implements DataType

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


Nested Class Summary
 class ObjectType.LongType
          The type for long objects.
 
Constructor Summary
ObjectType()
           
 
Method Summary
 java.lang.String asString()
          Get the stable string representation that is used to build this data type.
 int compare(java.lang.Object a, java.lang.Object b)
          Compare two keys.
static int compareNotNull(char[] data1, char[] data2)
          Compare the contents of two arrays.
static int compareNotNull(int[] data1, int[] data2)
          Compare the contents of two arrays.
static int compareNotNull(long[] data1, long[] data2)
          Compare the contents of two arrays.
 int getMaxLength(java.lang.Object obj)
          Get the maximum length in bytes used to store 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 write(java.nio.ByteBuffer buff, java.lang.Object obj)
          Write the object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObjectType

public ObjectType()
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

getMaxLength

public int getMaxLength(java.lang.Object obj)
Description copied from interface: DataType
Get the maximum length in bytes used to store an object. In many cases, this method can be faster than calculating the exact length.

Specified by:
getMaxLength in interface DataType
Parameters:
obj - the object
Returns:
the maximum length

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

write

public void write(java.nio.ByteBuffer buff,
                  java.lang.Object obj)
Description copied from interface: DataType
Write the 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

asString

public java.lang.String asString()
Description copied from interface: DataType
Get the stable string representation that is used to build this data type.

To avoid conflict with the default factory, the returned string should start with the package name of the type factory.

Specified by:
asString in interface DataType
Returns:
the string representation

compareNotNull

public static int compareNotNull(char[] data1,
                                 char[] data2)
Compare the contents of two arrays.

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

compareNotNull

public static int compareNotNull(int[] data1,
                                 int[] data2)
Compare the contents of two arrays.

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

compareNotNull

public static int compareNotNull(long[] data1,
                                 long[] data2)
Compare the contents of two arrays.

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