Class UuidFactory
Uuid instances.
Included are methods to create a Uuid with a given 128-bit value or a string
representation of such a value, to generate new Uuid values, and to read a binary
representation of a Uuid from a stream.
- Since:
- 2.0
- Author:
- Sun Microsystems, Inc.
-
Method Summary
Modifier and TypeMethodDescriptionstatic Uuidcreate(long bits0, long bits1) Creates a newUuidwith the specified 128-bit value.static UuidCreates a newUuidwith the 128-bit value represented by the specified string.static Uuidgenerate()Generates a newUuidwith 122 bits of its value produced from a cryptographically strong random sequence.static Uuidread(InputStream in) Creates a newUuidwith the 128-bit value obtained by unmarshalling a binary representation from the suppliedInputStream.
-
Method Details
-
create
Creates a newUuidwith the specified 128-bit value.This method can be used to create a
Uuidwith a value that has been previously generated, perhaps by an external mechanism.- Parameters:
bits0- the most significant 64 bits of the 128-bit valuebits1- the least significant 64 bits of the 128-bit value- Returns:
- a
Uuidwith the given value
-
create
Creates a newUuidwith the 128-bit value represented by the specified string.The supplied string representation must be in the format defined by
Uuid.toStringexcept that uppercase hexadecimal digits are allowed.- Parameters:
s- the string representation to create theUuidwith- Returns:
- a
Uuidwith the value represented by the given string - Throws:
IllegalArgumentException- if the supplied string representation does not conform to the specified formatNullPointerException- ifsisnull
-
generate
Generates a newUuidwith 122 bits of its value produced from a cryptographically strong random sequence.The value of a
Uuidreturned by this method is computationally difficult to guess and is highly likely to be unique with respect to all otherUuidvalues returned by this method over space and time.Specifically, this method creates a new
Uuidwith the avariantfield of0x2, aversionfield of0x4, and the remaining 122 bits of its value produced from a cryptographically strong random sequence.- Returns:
- a newly generated
Uuid - See Also:
-
read
Creates a newUuidwith the 128-bit value obtained by unmarshalling a binary representation from the suppliedInputStream.Specifically, this method reads 16 bytes from the stream, and then it creates a new
Uuidwith the 128-bit value represented by those bytes interpreted in network (big-endian) byte order.- Parameters:
in- theInputStreamto read theUuidfrom- Returns:
- a
Uuidwith the value unmarshalled from the stream - Throws:
IOException- if an I/O exception occurs while performing this operationNullPointerException- ifinisnull
-