Package org.apache.jackrabbit.core.id
Class NodeId
- java.lang.Object
-
- 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
Fields Modifier and Type Field Description static int
UUID_BYTE_LENGTH
Number of bytes in a UUID (16).static int
UUID_FORMATTED_LENGTH
Chars in a UUID String.
-
Constructor Summary
Constructors Constructor Description 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(String uuidString)
Creates a node identifier from the given UUID string.NodeId(UUID uuid)
Creates a node identifier from the given UUID.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(NodeId that)
Compares this identifier to the given other one.boolean
denotesNode()
Returnstrue
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.static NodeId
randomId()
Creates a random node identifier using a secure random number generator.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.
-
-
-
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 bitslsb
- 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 isnull
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:
uuidString
- UUID string- Throws:
IllegalArgumentException
- if the UUID string is invalid
-
-
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 isnull
or not a valid UUID
-
randomId
public static NodeId randomId()
Creates a random node identifier using a secure random number generator.
-
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()
Returnstrue
to indicate that this is a node identifier.- Specified by:
denotesNode
in interfaceItemId
- 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 interfaceComparable<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 classObject
- Returns:
- UUID string
- See Also:
UUID.toString()
-
equals
public boolean equals(Object that)
Compares two UUID for equality.- Overrides:
equals
in classObject
- See Also:
Object.equals(Object)
-
-