org.hypergraphdb
Class HGHandleFactory

java.lang.Object
  extended by org.hypergraphdb.HGHandleFactory

public class HGHandleFactory
extends java.lang.Object

The HGHandleFactory class is used to construct unique (UUID) handle for hypergraph atoms.

Author:
Borislav Iordanov

Field Summary
static HGPersistentHandle anyHandle
           The anyHandle is a persistent handle constant that represents a "don't care" handle during querying and comparison operations.
 
Constructor Summary
HGHandleFactory()
           
 
Method Summary
static HGPersistentHandle anyHandle()
           
static HGPersistentHandle makeHandle()
          Construct and return a new, unique persistent handle.
static HGPersistentHandle makeHandle(byte[] buffer)
          Construct a persistent handle from its byte array representation.
static HGPersistentHandle makeHandle(byte[] buffer, int offset)
          Construct a persistent handle from its byte array representation where the byte array is part of a larger buffer and located at a particular offset.
static HGPersistentHandle makeHandle(java.lang.String handleAsString)
          Construct a persistent handle from its string representation.
static HGPersistentHandle nullHandle()
          Return the representation of a null persistent handle.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

anyHandle

public static final HGPersistentHandle anyHandle

The anyHandle is a persistent handle constant that represents a "don't care" handle during querying and comparison operations. It can abe used, for instance, when defining an OrdererLinkCondition in a query.

For efficiency reasons, the equals method of the various implementations of the HGHandle interface ignore this constant, even though it would be more consistent to for anyHandle.equals(x) and x.equals(anyHandle) to always return true.

Constructor Detail

HGHandleFactory

public HGHandleFactory()
Method Detail

makeHandle

public static HGPersistentHandle makeHandle()

Construct and return a new, unique persistent handle. The handle is permanently unique. It can be persistent (serialized) and restored without ever conflicting with another handle.


makeHandle

public static HGPersistentHandle makeHandle(java.lang.String handleAsString)

Construct a persistent handle from its string representation.


makeHandle

public static HGPersistentHandle makeHandle(byte[] buffer)

Construct a persistent handle from its byte array representation.

Parameters:
buffer - The byte array holding the handle value.

makeHandle

public static HGPersistentHandle makeHandle(byte[] buffer,
                                            int offset)

Construct a persistent handle from its byte array representation where the byte array is part of a larger buffer and located at a particular offset.

Parameters:
buffer - The byte array holding the handle value.
offset - The offset within buffer where the handle value starts.

nullHandle

public static HGPersistentHandle nullHandle()

Return the representation of a null persistent handle. A null handle is a single instance and therefore can be compared for equality by doing direct Java object reference comparison. A null handle can be recorded in storage as any other persistent handle - it refers to no value. Not that while HyperGraph's type system does not provide for null atom values or value projections, null references to values are permitted and supported through the null HGPersistentHandle


anyHandle

public static HGPersistentHandle anyHandle()