org.hypergraphdb.handle
Class UUIDPersistentHandle

java.lang.Object
  extended by org.hypergraphdb.handle.UUIDPersistentHandle
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<HGPersistentHandle>, HGHandle, HGPersistentHandle

public final class UUIDPersistentHandle
extends java.lang.Object
implements HGPersistentHandle

See Also:
Serialized Form

Field Summary
static int SIZE
          The number of bytes in the byte [] representation of a UUIDPersistentHandle.
static UUIDPersistentHandle UUID_NULL_HANDLE
           
 
Constructor Summary
UUIDPersistentHandle()
          Default constructor create a new UUID.
 
Method Summary
 int compareTo(HGHandle other)
           
 int compareTo(HGPersistentHandle other)
           
 boolean equals(java.lang.Object other)
           
 int hashCode()
           
static UUIDPersistentHandle makeHandle()
          Construct a brand new UUID-based handle.
static UUIDPersistentHandle makeHandle(byte[] value)
          Construct from an existing UUID.
static UUIDPersistentHandle makeHandle(byte[] value, int offset)
          Construct from an existing UUID.
static UUIDPersistentHandle makeHandle(java.lang.String value)
          Construct from an existing UUID.
static UUIDPersistentHandle nullHandle()
          Return the representation of a nil handle, that is a handle that does not refer to anything.
 byte[] toByteArray()
          Return a byte [] representation of this UUIDPersistentHandle.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

SIZE

public static final int SIZE
The number of bytes in the byte [] representation of a UUIDPersistentHandle.

See Also:
Constant Field Values

UUID_NULL_HANDLE

public static final UUIDPersistentHandle UUID_NULL_HANDLE
Constructor Detail

UUIDPersistentHandle

public UUIDPersistentHandle()

Default constructor create a new UUID.

Method Detail

nullHandle

public static UUIDPersistentHandle nullHandle()

Return the representation of a nil handle, that is a handle that does not refer to anything.


makeHandle

public static UUIDPersistentHandle makeHandle()

Construct a brand new UUID-based handle. A UUID will be generated based on the algorithm configured at application started.


makeHandle

public static UUIDPersistentHandle makeHandle(byte[] value)

Construct from an existing UUID.

Parameters:
value - An array of UUIDPersistentHandle.SIZE bytes representing the UUID. If this parameter is null or of size != UUIDPersistentHandle.SIZE, an IllegalArgumentException is thrown.

makeHandle

public static UUIDPersistentHandle makeHandle(byte[] value,
                                              int offset)

Construct from an existing UUID.

Parameters:
value - An array of offset + UUIDPersistentHandle.SIZE bytes representing the UUID. If this parameter is null or of size < offset + UUIDPersistentHandle.SIZE, an IllegalArgumentException is thrown.
offset - The starting position in value of the data holding the UUIDPersistentHandle representation.

makeHandle

public static UUIDPersistentHandle makeHandle(java.lang.String value)

Construct from an existing UUID.

Parameters:
value - A UTF-8 encoded string representation of the UUID

toByteArray

public byte[] toByteArray()

Return a byte [] representation of this UUIDPersistentHandle.

Specified by:
toByteArray in interface HGPersistentHandle

equals

public boolean equals(java.lang.Object other)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

compareTo

public int compareTo(HGHandle other)

compareTo

public int compareTo(HGPersistentHandle other)
Specified by:
compareTo in interface java.lang.Comparable<HGPersistentHandle>