The specific use of the Java UUID

Source: Internet
Author: User
Tags uuid



Reference JDK




UUIDextends objectimplements Serializable, comparable<uuid>

A class that represents a universally unique identifier (UUID). The UUID represents a 128-bit value.

These generic identifiers have different variants. This class of methods is used to manipulate the Leach-salz variant, although the construction method allows any UUID variants to be created (described below).

The layout of the Variant 2 (Leach-salz) UUID is as follows: The most significant bit of the long data consists of the following unsigned fields:

The least significant bit of long data consists of the following unsigned fields:

The Variant field contains a value that represents the layout of the UUID . The bit layout described above only works when the variant value of the UUID is 2 (representing the Leach-salz variant).

The version field holds a value that describes this UUID type. There are 4 different basic UUID types: A time-based UUID, a DCE security uuid, a name-based UUID, and a randomly generated UUID. The version values for these types are 1, 2, 3, and 4, respectively.

For more information about the algorithm used to create the UUID , see RFC 4122: Universal Unique identifier (universally unique Identifier) (UUID) URN Namespace, section 4.2 "; Create a time-based UUID" algorithm.

Start from the following versions:
1.5
See also:
Serialization Table
Construction Method Summary
UUID(long mostSigBits, long leastSigBits)
Constructs a new UUIDusing the specified data.

Method Summary
 int clockSequence()
The value of the clock sequence associated with this UUID.
 int compareTo(UUID val)
Compares this UUID to a specified UUID.
 boolean equals(Object obj)
Compares this object to a specified object.
static UUID fromString(String name)
toString()creates a UUIDbased on the string standard representation described in the method.
 long getLeastSignificantBits()
Returns the lowest valid 64 bits in the 128-bit value of this UUID.
 long getMostSignificantBits()
Returns the most significant 64 bits in the 128-bit value of this UUID.
 int hashCode()
Returns the UUID hash code for this.
static UUID nameUUIDFromBytes(byte[] name)
Gets a static factory of type 3 (name-based)UUID , based on the specified byte array.
 long node()
The node value associated with this UUID.
static UUID randomUUID()
Gets the static factory of type 4 (pseudo-randomly generated) UUID.
 long timestamp()
The timestamp value associated with this UUID.
 String toString()
Returns the object that represents this UUID String .
 int variant()
The variant number associated with this UUID .
 int version()
The version number associated with this UUID .

Methods of inheriting from class Java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait

The specific use of the Java UUID

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.