GigaSpaces XAP 9.1 API

net.jini.id
Class UuidFactory

java.lang.Object
  extended by net.jini.id.UuidFactory

public final class UuidFactory
extends Object

Provides static methods for creating 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
static Uuid create(long bits0, long bits1)
          Creates a new Uuid with the specified 128-bit value.
static Uuid create(String s)
          Creates a new Uuid with the 128-bit value represented by the specified string.
static Uuid generate()
          Generates a new Uuid with 122 bits of its value produced from a cryptographically strong random sequence.
static Uuid read(InputStream in)
          Creates a new Uuid with the 128-bit value obtained by unmarshalling a binary representation from the supplied InputStream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

create

public static Uuid create(long bits0,
                          long bits1)
Creates a new Uuid with the specified 128-bit value.

This method can be used to create a Uuid with a value that has been previously generated, perhaps by an external mechanism.

Parameters:
bits0 - the most significant 64 bits of the 128-bit value
bits1 - the least significant 64 bits of the 128-bit value
Returns:
a Uuid with the given value

create

public static Uuid create(String s)
Creates a new Uuid with the 128-bit value represented by the specified string.

The supplied string representation must be in the format defined by Uuid.toString except that uppercase hexadecimal digits are allowed.

Parameters:
s - the string representation to create the Uuid with
Returns:
a Uuid with the value represented by the given string
Throws:
IllegalArgumentException - if the supplied string representation does not conform to the specified format
NullPointerException - if s is null

generate

public static Uuid generate()
Generates a new Uuid with 122 bits of its value produced from a cryptographically strong random sequence.

The value of a Uuid returned by this method is computationally difficult to guess and is highly likely to be unique with respect to all other Uuid values returned by this method over space and time.

Specifically, this method creates a new Uuid with the a variant field of 0x2, a version field of 0x4, and the remaining 122 bits of its value produced from a cryptographically strong random sequence.

Returns:
a newly generated Uuid
See Also:
SecureRandom

read

public static Uuid read(InputStream in)
                 throws IOException
Creates a new Uuid with the 128-bit value obtained by unmarshalling a binary representation from the supplied InputStream.

Specifically, this method reads 16 bytes from the stream, and then it creates a new Uuid with the 128-bit value represented by those bytes interpreted in network (big-endian) byte order.

Parameters:
in - the InputStream to read the Uuid from
Returns:
a Uuid with the value unmarshalled from the stream
Throws:
IOException - if an I/O exception occurs while performing this operation
NullPointerException - if in is null

GigaSpaces XAP 9.1 API

Copyright © GigaSpaces.