public class UUID
extends java.lang.Object
implements java.lang.Comparable, java.io.Serializable
The UUID has the following fields:
Time is expressed as in VMS, i.e. 100's of nanoseconds since a base date, but the base dat is 10/15/1582, rather than VMS's 1858. Since 100 nanoseconds is probably much smaller than the system clock resolution, implementations are allowed to construct many UUIDs per clock tick by keeping track of a 'time adjustment', which is bumped for each UUID constructed during a clock tick and added into the UUID's time fields.
The intent of the UUID algorithm is to generate a globally unique ID. The reasoning goes:
Java has one large problem using this logic: the Ethernet address is not findable in any documented way. The DCE implementation on SunOS evidently has had the same problem, since they use the Internet address instead of the Ethernet address as four bytes of their node ID (they set the fifth and sixth bytes not to conflict with any true Ethernet address.)
Forte's version of UUID generation, implemented in the UUID.UUIDGenerator class, is:
| Modifier and Type | Field and Description |
|---|---|
static int |
STRING_LENGTH
the length of a UUID converted to a string
|
| Constructor and Description |
|---|
UUID()
Generate a new UUID
|
UUID(java.lang.String str)
Create a UUID from a string
|
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(java.lang.Object o)
Orders UUIDs by their field values
|
boolean |
equals(java.lang.Object o)
Two UUIDs are equal if all of their fields are equal
|
int |
hashCode()
Use timeLow for the hashCode, so equal UUIDs hash equal
|
java.lang.String |
toString()
Convert a UUID to a string in standard form:
|
public static final int STRING_LENGTH
public UUID()
public UUID(java.lang.String str)
throws java.lang.NumberFormatException
str - A string in standard UUID formatjava.lang.NumberFormatException - Thrown if the string isn't
a valid UUID.public java.lang.String toString()
XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
timeLow-timeMid-timeHiAndVersion-clockSeqAndReserved-nodeId
toString in class java.lang.Objectpublic boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int compareTo(java.lang.Object o)
compareTo in interface java.lang.Comparablepublic int hashCode()
hashCode in class java.lang.ObjectCopyright © 2005-2012 Apache Software Foundation. All Rights Reserved.