|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.commons.id.uuid.UUID
public class UUID
UUID
represents a Universally Unique Identifier per RFC 4122.
See the RFC 4122:
A Universally Unique IDentifier (UUID) URN Namespace
for more information.
Field Summary |
---|
Constructor Summary | |
---|---|
UUID()
Constructs a nil UUID |
|
UUID(byte[] byteArray)
Constructs a UUID from a 16 byte array. |
|
UUID(java.io.DataInput input)
Constructs a UUID from a DataInput. |
|
UUID(long mostSignificant,
long leastSignificant)
Constructs a UUID from two long values in most significant byte, and least significant bytes order. |
|
UUID(java.lang.String uuidString)
Constructs a UUID from a UUID formatted String. |
|
UUID(UUID copyFrom)
Copy constructor. |
Method Summary | |
---|---|
int |
clockSequence()
Returns the clock sequence value in the UUID. |
int |
compareTo(java.lang.Object compareTo)
Compares two UUID's for equality. |
boolean |
equals(java.lang.Object obj)
Compares two UUID for equality. |
static UUID |
fromString(java.lang.String uuidString)
Parses a string for a UUID. |
byte[] |
getRawBytes()
Returns a copy of the byte values contained in this UUID. |
int |
hashCode()
Returns a hash code value for the object. |
static UUID |
nameUUIDFromString(java.lang.String name,
UUID namespace)
Returns a new version three UUID given a name and the namespace's UUID. |
static UUID |
nameUUIDFromString(java.lang.String name,
UUID namespace,
java.lang.String encoding)
Returns a new version three (MD5) or five (SHA-1) UUID, using the specified encoding given a name and the namespace's UUID. |
long |
node()
Returns the node identifier found in this UUID. |
static UUID |
randomUUID()
Returns a new version 4 UUID, based upon Random bits. |
long |
timestamp()
Returns the timestamp value of the UUID as 100-nano second intervals since the Gregorian change offset (00:00:00.00, 15 October 1582 ). |
static UUID |
timeUUID()
Returns a new version 1 UUID, based upon node identifier and time stamp. |
java.lang.String |
toString()
Returns a string representation of the UUID. |
java.lang.String |
toUrn()
Returns a urn representation of the UUID. |
int |
variant()
Returns the variant field of the UUID. |
int |
version()
Returns the version of the UUID. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public UUID()
public UUID(UUID copyFrom)
Copy constructor.
copyFrom
- the UUID to copy to create this UUID.public UUID(byte[] byteArray) throws java.lang.IllegalArgumentException
Constructs a UUID from a 16 byte array.
byteArray
- the 16 byte array to construct this UUID from.
java.lang.IllegalArgumentException
- argument must be 16 bytespublic UUID(java.io.DataInput input) throws java.io.IOException
Constructs a UUID from a DataInput. Note if 16 bytes are not available this method will block.
input
- the datainput with 16 bytes to read in from.
java.io.IOException
- exception if there is an IO problem also argument must contain 16 bytes.public UUID(long mostSignificant, long leastSignificant)
Constructs a UUID from two long values in most significant byte, and least significant bytes order.
mostSignificant
- - the most significant 8 bytes of the uuid to be constructed.leastSignificant
- - the least significant 8 bytes of the uuid to be constructed.public UUID(java.lang.String uuidString) throws UUIDFormatException
Constructs a UUID from a UUID formatted String.
uuidString
- the String representing a UUID to construct this UUID
UUIDFormatException
- String must be a properly formatted UUID stringMethod Detail |
---|
public static UUID fromString(java.lang.String uuidString) throws UUIDFormatException
Parses a string for a UUID.
uuidString
- the UUID formatted String to parse.
UUIDFormatException
- the String must be a properly formatted UUID String.public java.lang.String toString()
Returns a string representation of the UUID.
toString
in class java.lang.Object
public java.lang.String toUrn()
Returns a urn representation of the UUID. This is same as the
toString() value prefixed with urn:uuid:
public boolean equals(java.lang.Object obj)
Compares two UUID for equality.
equals
in class java.lang.Object
Object.equals(Object)
public int hashCode()
Returns a hash code value for the object.
hashCode
in class java.lang.Object
Object.hashCode()
public int compareTo(java.lang.Object compareTo) throws java.lang.ClassCastException
Compares two UUID's for equality.
compareTo
in interface java.lang.Comparable
java.lang.ClassCastException
Comparable.compareTo(Object)
public int clockSequence() throws java.lang.UnsupportedOperationException
Returns the clock sequence value in the UUID. The clock sequence is a random assigned to a particular clock instance that generated the time in the timestamp of a time based UUID.
java.lang.UnsupportedOperationException
- thrown if this is not a IETF variant or not a time-based UUID.public int version()
Returns the version of the UUID.
public int variant()
Returns the variant field of the UUID.
Constants.VARIANT_NCS_COMPAT
,
Constants.VARIANT_IETF_DRAFT
,
Constants.VARIANT_MS
,
Constants.VARIANT_FUTURE
public long node() throws java.lang.UnsupportedOperationException
Returns the node identifier found in this UUID. The specification was written such that this value holds the IEEE 802 MAC address. The specification permits this value to be calculated from other sources other than the MAC.
java.lang.UnsupportedOperationException
- thrown if this is not a IETF variant or not a time-based UUID.public long timestamp() throws java.lang.UnsupportedOperationException
Returns the timestamp value of the UUID as 100-nano second intervals since the Gregorian change offset (00:00:00.00, 15 October 1582 ).
java.lang.UnsupportedOperationException
- thrown if this is not a IETF variant or not a time-based UUID.public byte[] getRawBytes()
Returns a copy of the byte values contained in this UUID.
public static UUID randomUUID()
Returns a new version 4 UUID, based upon Random bits.
public static UUID timeUUID()
Returns a new version 1 UUID, based upon node identifier and time stamp.
public static UUID nameUUIDFromString(java.lang.String name, UUID namespace, java.lang.String encoding)
Returns a new version three (MD5) or five (SHA-1) UUID, using the specified encoding given a name and the namespace's UUID.
name
- String the name to calculate the UUID for.namespace
- UUID assigned to this namespace.encoding
- The encoding to use, either #{link UUID.MD5_ENCODING} or #{link UUID.SHA1_ENCODING}
public static UUID nameUUIDFromString(java.lang.String name, UUID namespace)
Returns a new version three UUID given a name and the namespace's UUID.
name
- String the name to calculate the UUID for.namespace
- UUID assigned to this namespace.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |