com.metamatrix.core.id
Class UUID

java.lang.Object
  extended by com.metamatrix.core.id.UUID
All Implemented Interfaces:
ObjectID, java.io.Serializable, java.lang.Comparable

public class UUID
extends java.lang.Object
implements ObjectID, java.io.Serializable

This class represents a universally unique identifier, consisting of two long integral values.

This identifier is supposed to be unique both spatially and temporally. It is based on version 4 IETF variant random UUIDs.

See Also:
Serialized Form

Field Summary
static int FQ_LENGTH
           
static java.lang.String PROTOCOL
           
static java.lang.String PROTOCOL_UCASE
           
 
Fields inherited from interface com.metamatrix.core.id.ObjectID
DELIMITER
 
Constructor Summary
UUID(long mostSig, long leastSig)
          Construct an instance of this class from two long integral values.
UUID(java.util.UUID uuid)
           
 
Method Summary
 int compareTo(java.lang.Object obj)
          Compares this object to another.
 boolean equals(java.lang.Object obj)
          Returns true if the specified object is semantically equal to this instance.
 java.lang.String exportableForm()
          Returns a 36-character string of six fields separated by hyphens, with each field represented in lowercase hexadecimal with the same number of digits as in the field.
static long getPart1(ObjectID id)
          Return the first part of the UUID as a long.
static long getPart2(ObjectID id)
          Return the first part of the UUID as a long.
 java.lang.String getProtocol()
          Return the name of the protocol that this factory uses.
static int getVariant(ObjectID id)
           
static int getVersion(ObjectID id)
           
 int hashCode()
          Returns the hashcode for this instance.
static ObjectID stringToObject(java.lang.String value)
          Attempt to convert the specified string to the appropriate ObjectID instance.
 java.lang.String toString()
          Returns a string representing the current state of the object.
 java.lang.String toString(char delim)
          Returns a string representing the current state of the object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

PROTOCOL

public static final java.lang.String PROTOCOL
See Also:
Constant Field Values

PROTOCOL_UCASE

public static final java.lang.String PROTOCOL_UCASE

FQ_LENGTH

public static final int FQ_LENGTH
Constructor Detail

UUID

public UUID(long mostSig,
            long leastSig)
Construct an instance of this class from two long integral values. Both values must be non-negative.

Throws:
java.lang.IllegalArgumentException - if either value is negative

UUID

public UUID(java.util.UUID uuid)
Method Detail

getPart1

public static long getPart1(ObjectID id)
Return the first part of the UUID as a long.

Returns:
first part of the UUID as a long

getPart2

public static long getPart2(ObjectID id)
Return the first part of the UUID as a long.

Returns:
first part of the UUID as a long

getVariant

public static int getVariant(ObjectID id)

getVersion

public static int getVersion(ObjectID id)

getProtocol

public java.lang.String getProtocol()
Return the name of the protocol that this factory uses.

Specified by:
getProtocol in interface ObjectID
Returns:
the protocol name

hashCode

public int hashCode()
Returns the hashcode for this instance. All of the bits in each 32-bit part of the longs are exclusively 'or'd together to yield the hashcode.

Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)

Returns true if the specified object is semantically equal to this instance. Note: this method is consistent with compareTo() .

UUID instances are equal if they represent the same 128-bit value.

Overrides:
equals in class java.lang.Object
Parameters:
obj - the object that this instance is to be compared to.
Returns:
whether the object is equal to this object.

compareTo

public int compareTo(java.lang.Object obj)

Compares this object to another. If the specified object is not an instance of the LongID class, then this method throws a ClassCastException (as instances are comparable only to instances of the same class).

Note: this method is consistent with equals(), meaning that (compare(x, y)==0) == (x.equals(y)).

Specified by:
compareTo in interface ObjectID
Specified by:
compareTo in interface java.lang.Comparable
Parameters:
obj - the object that this instance is to be compared to; may not be null.
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object, respectively.
Throws:
java.lang.ClassCastException - if the specified object's type prevents it from being compared to this instance.

toString

public java.lang.String toString()
Returns a string representing the current state of the object.

Specified by:
toString in interface ObjectID
Overrides:
toString in class java.lang.Object
Returns:
the string representation of this instance.

toString

public java.lang.String toString(char delim)
Description copied from interface: ObjectID
Returns a string representing the current state of the object.

Specified by:
toString in interface ObjectID
Parameters:
delim - the delimiter that should be used
Returns:
the string representation of this instance.
See Also:
ObjectID.toString(char)

exportableForm

public java.lang.String exportableForm()

Returns a 36-character string of six fields separated by hyphens, with each field represented in lowercase hexadecimal with the same number of digits as in the field. The order of fields is: time_low, time_mid, version and time_hi treated as a single field, variant and clock_seq treated as a single field, and node.

Returns:
A string of the form 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', where all the characters are lowercase hexadecimal digits

stringToObject

public static ObjectID stringToObject(java.lang.String value)
                               throws InvalidIDException
Attempt to convert the specified string to the appropriate ObjectID instance.

Parameters:
value - the stringified id with the protocol and ObjectID.DELIMITER already removed, and which is never null or zero length
Returns:
the ObjectID instance for the stringified ID if this factory is able to parse the string, or null if the factory is unaware of the specified format.
Throws:
InvalidIDException


Copyright © 2009. All Rights Reserved.