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 intUUID_BYTE_LENGTHNumber of bytes in a UUID (16).static intUUID_FORMATTED_LENGTHChars 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 intcompareTo(NodeId that)Compares this identifier to the given other one.booleandenotesNode()Returnstrueto indicate that this is a node identifier.booleanequals(Object that)Compares two UUID for equality.longgetLeastSignificantBits()Returns the 64 least significant bits of this identifier.longgetMostSignificantBits()Returns the 64 most significant bits of this identifier.byte[]getRawBytes()Returns the 16 bytes of this identifier.inthashCode()Returns a hash code of this identifier.static NodeIdrandomId()Creates a random node identifier using a secure random number generator.StringtoString()Returns the UUID string representation of this identifier.static NodeIdvalueOf(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, ArrayIndexOutOfBoundsExceptionCreates a node identifier from the given 16 bytes.- Parameters:
bytes- array of 16 bytes- Throws:
NullPointerException- if the given array isnullArrayIndexOutOfBoundsException- 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 isnullor 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()
Returnstrueto indicate that this is a node identifier.- Specified by:
denotesNodein interfaceItemId- Returns:
- always
true - See Also:
PropertyId,NodeId
-
compareTo
public int compareTo(NodeId that)
Compares this identifier to the given other one.- Specified by:
compareToin 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:
toStringin classObject- Returns:
- UUID string
- See Also:
UUID.toString()
-
equals
public boolean equals(Object that)
Compares two UUID for equality.- Overrides:
equalsin classObject- See Also:
Object.equals(Object)
-
-