org.elasticsearch.common
Class UUID

java.lang.Object
  extended by org.elasticsearch.common.UUID
All Implemented Interfaces:
Comparable<UUID>

public class UUID
extends Object
implements Comparable<UUID>

A UUID taken from java UUID that simply holds less data.


Constructor Summary
UUID(long mostSigBits, long leastSigBits)
          Constructs a new UUID using the specified data.
 
Method Summary
 int compareTo(UUID val)
          Compares this UUID with the specified UUID.
 boolean equals(Object obj)
          Compares this object to the specified object.
static UUID fromString(String name)
          Creates a UUID from the string standard representation as described in the toString() method.
 long getLeastSignificantBits()
          Returns the least significant 64 bits of this UUID's 128 bit value.
 long getMostSignificantBits()
          Returns the most significant 64 bits of this UUID's 128 bit value.
 int hashCode()
          Returns a hash code for this UUID.
static UUID nameUUIDFromBytes(byte[] name)
          Static factory to retrieve a type 3 (name based) UUID based on the specified byte array.
static String randomBase64UUID()
           
static UUID randomUUID()
          Static factory to retrieve a type 4 (pseudo randomly generated) UUID.
 String toString()
          Returns a String object representing this UUID.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

UUID

public UUID(long mostSigBits,
            long leastSigBits)
Constructs a new UUID using the specified data. mostSigBits is used for the most significant 64 bits of the UUID and leastSigBits becomes the least significant 64 bits of the UUID.

Parameters:
mostSigBits -
leastSigBits -
Method Detail

randomUUID

public static UUID randomUUID()
Static factory to retrieve a type 4 (pseudo randomly generated) UUID.

The UUID is generated using a cryptographically strong pseudo random number generator.

Returns:
a randomly generated UUID.

randomBase64UUID

public static String randomBase64UUID()

nameUUIDFromBytes

public static UUID nameUUIDFromBytes(byte[] name)
Static factory to retrieve a type 3 (name based) UUID based on the specified byte array.

Parameters:
name - a byte array to be used to construct a UUID.
Returns:
a UUID generated from the specified array.

fromString

public static UUID fromString(String name)
Creates a UUID from the string standard representation as described in the toString() method.

Parameters:
name - a string that specifies a UUID.
Returns:
a UUID with the specified value.
Throws:
IllegalArgumentException - if name does not conform to the string representation as described in toString().

getLeastSignificantBits

public long getLeastSignificantBits()
Returns the least significant 64 bits of this UUID's 128 bit value.

Returns:
the least significant 64 bits of this UUID's 128 bit value.

getMostSignificantBits

public long getMostSignificantBits()
Returns the most significant 64 bits of this UUID's 128 bit value.

Returns:
the most significant 64 bits of this UUID's 128 bit value.

toString

public String toString()
Returns a String object representing this UUID.

The UUID string representation is as described by this BNF :

 UUID                   = <time_low> "-" <time_mid> "-"
                          <time_high_and_version> "-"
                          <variant_and_sequence> "-"
                          <node>
 time_low               = 4*<hexOctet>
 time_mid               = 2*<hexOctet>
 time_high_and_version  = 2*<hexOctet>
 variant_and_sequence   = 2*<hexOctet>
 node                   = 6*<hexOctet>
 hexOctet               = <hexDigit><hexDigit>
 hexDigit               =
       "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
       | "a" | "b" | "c" | "d" | "e" | "f"
       | "A" | "B" | "C" | "D" | "E" | "F"
 

Overrides:
toString in class Object
Returns:
a string representation of this UUID.

hashCode

public int hashCode()
Returns a hash code for this UUID.

Overrides:
hashCode in class Object
Returns:
a hash code value for this UUID.

equals

public boolean equals(Object obj)
Compares this object to the specified object. The result is true if and only if the argument is not null, is a UUID object, has the same variant, and contains the same value, bit for bit, as this UUID.

Overrides:
equals in class Object
Parameters:
obj - the object to compare with.
Returns:
true if the objects are the same; false otherwise.

compareTo

public int compareTo(UUID val)
Compares this UUID with the specified UUID.

The first of two UUIDs follows the second if the most significant field in which the UUIDs differ is greater for the first UUID.

Specified by:
compareTo in interface Comparable<UUID>
Parameters:
val - UUID to which this UUID is to be compared.
Returns:
-1, 0 or 1 as this UUID is less than, equal to, or greater than val.


Copyright © 2009-2012. All Rights Reserved.