org.h2.util
Class ObjectUtils

java.lang.Object
  extended by org.h2.util.ObjectUtils

public class ObjectUtils
extends java.lang.Object

Utility class for object creation and serialization. Starting with Java 1.5, some objects are re-used.


Method Summary
static void arrayCopy(java.lang.Object[] source, java.lang.Object[] target, int size)
          Copy the elements of the source array to the target array.
static java.lang.Object deserialize(byte[] data)
          De-serialize the byte array to an object.
static int hashCode(java.lang.Object o)
          Calculate the hash code of the given object.
static byte[] serialize(java.lang.Object obj)
          Serialize the object to a byte array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

serialize

public static byte[] serialize(java.lang.Object obj)
                        throws java.sql.SQLException
Serialize the object to a byte array.

Parameters:
obj - the object to serialize
Returns:
the byte array
Throws:
java.sql.SQLException

deserialize

public static java.lang.Object deserialize(byte[] data)
                                    throws java.sql.SQLException
De-serialize the byte array to an object.

Parameters:
data - the byte array
Returns:
the object
Throws:
java.sql.SQLException

arrayCopy

public static void arrayCopy(java.lang.Object[] source,
                             java.lang.Object[] target,
                             int size)
Copy the elements of the source array to the target array. System.arraycopy is used for larger arrays, but for very small arrays it is faster to use a regular loop.

Parameters:
source - the source array
target - the target array
size - the number of elements to copy

hashCode

public static int hashCode(java.lang.Object o)
Calculate the hash code of the given object. The object may be null.

Parameters:
o - the object
Returns:
the hash code, or 0 if the object is null