org.h2.mvstore.type
Interface DataType

All Known Implementing Classes:
ObjectType, ObjectType.LongType, RowType, SpatialType, StringType

public interface DataType

A data type.


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

Method Detail

compare

int compare(java.lang.Object a,
            java.lang.Object b)
Compare two keys.

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

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

Parameters:
obj - the object
Returns:
the maximum length

getMemory

int getMemory(java.lang.Object obj)
Estimate the used memory in bytes.

Parameters:
obj - the object
Returns:
the used memory

write

void write(java.nio.ByteBuffer buff,
           java.lang.Object obj)
Write the object.

Parameters:
buff - the target buffer
obj - the value

read

java.lang.Object read(java.nio.ByteBuffer buff)
Read an object.

Parameters:
buff - the source buffer
Returns:
the object

asString

java.lang.String asString()
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.

Returns:
the string representation