1 *java.util.UUID* *UUID* A class that represents an immutable universally unique
3 public final class UUID
4 extends |java.lang.Object|
5 implements |java.io.Serializable|
8 |java.util.UUID_Description|
9 |java.util.UUID_Fields|
10 |java.util.UUID_Constructors|
11 |java.util.UUID_Methods|
13 ================================================================================
15 *java.util.UUID_Constructors*
16 |java.util.UUID(long,long)|Constructs a new UUID using the specified data.
18 *java.util.UUID_Methods*
19 |java.util.UUID.clockSequence()|The clock sequence value associated with this U
20 |java.util.UUID.compareTo(UUID)|Compares this UUID with the specified UUID.
21 |java.util.UUID.equals(Object)|Compares this object to the specified object.
22 |java.util.UUID.fromString(String)|Creates a UUID from the string standard repr
23 |java.util.UUID.getLeastSignificantBits()|Returns the least significant 64 bits
24 |java.util.UUID.getMostSignificantBits()|Returns the most significant 64 bits o
25 |java.util.UUID.hashCode()|Returns a hash code for this UUID.
26 |java.util.UUID.nameUUIDFromBytes(byte[])|Static factory to retrieve a type 3 (
27 |java.util.UUID.node()|The node value associated with this UUID.
28 |java.util.UUID.randomUUID()|Static factory to retrieve a type 4 (pseudo random
29 |java.util.UUID.timestamp()|The timestamp value associated with this UUID.
30 |java.util.UUID.toString()|Returns a String object representing this UUID.
31 |java.util.UUID.variant()|The variant number associated with this UUID.
32 |java.util.UUID.version()|The version number associated with this UUID.
34 *java.util.UUID_Description*
36 A class that represents an immutable universally unique identifier (UUID). A
37 UUID represents a 128-bit value.
39 There exist different variants of these global identifiers. The methods of this
40 class are for manipulating the Leach-Salz variant, although the constructors
41 allow the creation of any variant of UUID (described below).
43 The layout of a variant 2 (Leach-Salz) UUID is as follows:
45 The most significant long consists of the following unsigned fields:
47 0xFFFFFFFF00000000 time_low 0x00000000FFFF0000 time_mid 0x000000000000F000
48 version 0x0000000000000FFF time_hi
50 The least significant long consists of the following unsigned fields:
52 0xC000000000000000 variant 0x3FFF000000000000 clock_seq 0x0000FFFFFFFFFFFF node
54 The variant field contains a value which identifies the layout of the UUID. The
55 bit layout described above is valid only for a UUID with a variant value of 2,
56 which indicates the Leach-Salz variant.
58 The version field holds a value that describes the type of this UUID. There are
59 four different basic types of UUIDs: time-based, DCE security, name-based, and
60 randomly generated UUIDs. These types have a version value of 1, 2, 3 and 4,
63 For more information including algorithms used to create UUIDs, see RFC4122: A
64 Universally Unique IDentifier (UUID) URN Namespace, section 4.2 Algorithms for
65 Creating a Time-Based UUID.
69 *java.util.UUID(long,long)*
75 Constructs a new UUID using the specified data. mostSigBits is used for the
76 most significant 64 bits of the UUID and leastSigBits becomes the least
77 significant 64 bits of the UUID.
82 *java.util.UUID.clockSequence()*
84 public int clockSequence()
86 The clock sequence value associated with this UUID.
88 The 14 bit clock sequence value is constructed from the clock sequence field of
89 this UUID. The clock sequence field is used to guarantee temporal uniqueness in
92 The clockSequence value is only meaningful in a time-based UUID, which has
93 version type 1. If this UUID is not a time-based UUID then this method throws
94 UnsupportedOperationException.
98 Returns: the clock sequence of this UUID.
100 *java.util.UUID.compareTo(UUID)*
102 public int compareTo(java.util.UUID val)
104 Compares this UUID with the specified UUID.
106 The first of two UUIDs follows the second if the most significant field in
107 which the UUIDs differ is greater for the first UUID.
110 val - UUID to which this UUID is to be compared.
112 Returns: -1, 0 or 1 as this UUID is less than, equal to, or greater than val.
114 *java.util.UUID.equals(Object)*
116 public boolean equals(java.lang.Object obj)
118 Compares this object to the specified object. The result is true if and only if
119 the argument is not null, is a UUID object, has the same variant, and contains
120 the same value, bit for bit, as this UUID.
123 obj - the object to compare with.
125 Returns: true if the objects are the same; false otherwise.
127 *java.util.UUID.fromString(String)*
129 public static |java.util.UUID| fromString(java.lang.String name)
131 Creates a UUID from the string standard representation as described in the
132 (|java.util.UUID|) method.
135 name - a string that specifies a UUID.
137 Returns: a UUID with the specified value.
139 *java.util.UUID.getLeastSignificantBits()*
141 public long getLeastSignificantBits()
143 Returns the least significant 64 bits of this UUID's 128 bit value.
147 Returns: the least significant 64 bits of this UUID's 128 bit value.
149 *java.util.UUID.getMostSignificantBits()*
151 public long getMostSignificantBits()
153 Returns the most significant 64 bits of this UUID's 128 bit value.
157 Returns: the most significant 64 bits of this UUID's 128 bit value.
159 *java.util.UUID.hashCode()*
161 public int hashCode()
163 Returns a hash code for this UUID.
167 Returns: a hash code value for this UUID.
169 *java.util.UUID.nameUUIDFromBytes(byte[])*
171 public static |java.util.UUID| nameUUIDFromBytes(byte[] name)
173 Static factory to retrieve a type 3 (name based) UUID based on the specified
177 name - a byte array to be used to construct a UUID.
179 Returns: a UUID generated from the specified array.
181 *java.util.UUID.node()*
185 The node value associated with this UUID.
187 The 48 bit node value is constructed from the node field of this UUID. This
188 field is intended to hold the IEEE 802 address of the machine that generated
189 this UUID to guarantee spatial uniqueness.
191 The node value is only meaningful in a time-based UUID, which has version type
192 1. If this UUID is not a time-based UUID then this method throws
193 UnsupportedOperationException.
197 Returns: the node value of this UUID.
199 *java.util.UUID.randomUUID()*
201 public static |java.util.UUID| randomUUID()
203 Static factory to retrieve a type 4 (pseudo randomly generated) UUID.
205 The UUID is generated using a cryptographically strong pseudo random number
210 Returns: a randomly generated UUID.
212 *java.util.UUID.timestamp()*
214 public long timestamp()
216 The timestamp value associated with this UUID.
218 The 60 bit timestamp value is constructed from the time_low, time_mid, and
219 time_hi fields of this UUID. The resulting timestamp is measured in
220 100-nanosecond units since midnight, October 15, 1582 UTC.
222 The timestamp value is only meaningful in a time-based UUID, which has version
223 type 1. If this UUID is not a time-based UUID then this method throws
224 UnsupportedOperationException.
228 *java.util.UUID.toString()*
230 public |java.lang.String| toString()
232 Returns a String object representing this UUID.
234 The UUID string representation is as described by this BNF :
236 UUID = "-" "-" "-" "-"
238 time_low = 4* time_mid = 2* time_high_and_version = 2* variant_and_sequence =
239 2* node = 6* hexOctet = hexDigit = "0" | "1" | "2" | "3" | "4" | "5" | "6" |
240 "7" | "8" | "9" | "a" | "b" | "c" | "d" | "e" | "f" | "A" | "B" | "C" | "D" |
245 Returns: a string representation of this UUID.
247 *java.util.UUID.variant()*
251 The variant number associated with this UUID. The variant number describes the
254 The variant number has the following meaning:
256 0 Reserved for NCS backward compatibility 2 The Leach-Salz variant (used by
257 this class) 6 Reserved, Microsoft Corporation backward compatibility 7 Reserved
258 for future definition
262 Returns: the variant number of this UUID.
264 *java.util.UUID.version()*
268 The version number associated with this UUID. The version number describes how
269 this UUID was generated.
271 The version number has the following meaning:
273 1 Time-based UUID 2 DCE security UUID 3 Name-based UUID 4 Randomly generated
278 Returns: the version number of this UUID.