org.apache.jackrabbit.core.id
Class NodeId

java.lang.Object
  extended by org.apache.jackrabbit.core.id.NodeId
All Implemented Interfaces:
Serializable, Comparable<NodeId>, ItemId

public class NodeId
extends Object
implements ItemId, Comparable<NodeId>

Node identifier, i.e. an immutable 128 bit UUID.

See Also:
Serialized Form

Field Summary
static int UUID_BYTE_LENGTH
          Number of bytes in a UUID (16).
static int UUID_FORMATTED_LENGTH
          Chars in a UUID String.
 
Constructor Summary
NodeId()
          Creates a random node identifier using a secure random number generator.
NodeId(byte[] bytes)
          Creates a node identifier from the given 16 bytes.
NodeId(long msb, long lsb)
          Creates a node identifier from the given 128 bits.
NodeId(Random random)
          Creates a node identifier using the given random number generator.
NodeId(String uuidString)
          Creates a node identifier from the given UUID string.
NodeId(UUID uuid)
          Creates a node identifier from the given UUID.
 
Method Summary
 int compareTo(NodeId that)
          Compares this identifier to the given other one.
 boolean denotesNode()
          Returns true to indicate that this is a node identifier.
 boolean equals(Object that)
          Compares two UUID for equality.
 long getLeastSignificantBits()
          Returns the 64 least significant bits of this identifier.
 long getMostSignificantBits()
          Returns the 64 most significant bits of this identifier.
 byte[] getRawBytes()
          Returns the 16 bytes of this identifier.
 int hashCode()
          Returns a hash code of this identifier.
 String toString()
          Returns the UUID string representation of this identifier.
static NodeId valueOf(String uuid)
          Returns a node identifier that is represented by the given UUID string.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

UUID_FORMATTED_LENGTH

public static final int UUID_FORMATTED_LENGTH
Chars in a UUID String.

See Also:
Constant Field Values

UUID_BYTE_LENGTH

public static final int UUID_BYTE_LENGTH
Number of bytes in a UUID (16).

See Also:
Constant Field Values
Constructor Detail

NodeId

public NodeId(long msb,
              long lsb)
Creates a node identifier from the given 128 bits.

Parameters:
msb - most significant 64 bits
lsb - least significant 64 bits

NodeId

public NodeId(byte[] bytes)
       throws NullPointerException,
              ArrayIndexOutOfBoundsException
Creates a node identifier from the given 16 bytes.

Parameters:
bytes - array of 16 bytes
Throws:
NullPointerException - if the given array is null
ArrayIndexOutOfBoundsException - if the given array is less than 16 bytes long

NodeId

public NodeId(UUID uuid)
Creates a node identifier from the given UUID.

Parameters:
uuid - UUID

NodeId

public NodeId(String uuidString)
       throws IllegalArgumentException
Creates a node identifier from the given UUID string.

Parameters:
uuid - UUID string
Throws:
IllegalArgumentException - if the UUID string is invalid
See Also:
#fromString(String)

NodeId

public NodeId(Random random)
Creates a node identifier using the given random number generator.

Parameters:
random - random number generator

NodeId

public NodeId()
Creates a random node identifier using a secure random number generator.

Method Detail

valueOf

public static NodeId valueOf(String uuid)
                      throws IllegalArgumentException
Returns a node identifier that is represented by the given UUID string.

Parameters:
uuid - the UUID string
Returns:
the node identifier
Throws:
IllegalArgumentException - if the given string is null or not a valid UUID

getMostSignificantBits

public long getMostSignificantBits()
Returns the 64 most significant bits of this identifier.

Returns:
64 most significant bits

getLeastSignificantBits

public long getLeastSignificantBits()
Returns the 64 least significant bits of this identifier.

Returns:
64 least significant bits

getRawBytes

public byte[] getRawBytes()
Returns the 16 bytes of this identifier.

Returns:
newly allocated array of 16 bytes

denotesNode

public boolean denotesNode()
Returns true to indicate that this is a node identifier.

Specified by:
denotesNode in interface ItemId
Returns:
always true
See Also:
PropertyId, NodeId

compareTo

public int compareTo(NodeId that)
Compares this identifier to the given other one.

Specified by:
compareTo in interface Comparable<NodeId>
Parameters:
that - other identifier
Returns:
-1, 0 or +1 if this identifier is less than, equal to, or greater than the given other identifier

toString

public String toString()
Returns the UUID string representation of this identifier.

Overrides:
toString in class Object
Returns:
UUID string
See Also:
UUID.toString()

equals

public boolean equals(Object that)
Compares two UUID for equality.

Overrides:
equals in class Object
See Also:
Object.equals(Object)

hashCode

public int hashCode()
Returns a hash code of this identifier.

Overrides:
hashCode in class Object
Returns:
hash code


Copyright © 2004-2010 The Apache Software Foundation. All Rights Reserved.