org.apache.ode.utils
Class GUID

java.lang.Object
  extended by org.apache.ode.utils.GUID
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Comparable

public final class GUID
extends java.lang.Object
implements java.lang.Cloneable, java.lang.Comparable, java.io.Serializable

This class is used to generate globally unique IDs. The requirements for global uniqueness are as follows:

     1) The time on any machine is never set back.
     2) Each machine has a unique IP address.
     3) Each process has the 'org.apache.ode.uid.port' property set to the
        same non-zero value.
 
    byte:    0   1   2   3   4  5  6  7  8  9  10  11   12  13
             [ IPADDRESS ]  [   START TIME IN MS     ] [ count]
    This format allow more compact string representation.
    Persistence mechanism maps 6 bits to a number-char mapping.  Byte
    0-5 (48 bits, 6 bits per char => 8 chars)
    Since the current time typically has zeros for many of its most significant
    digits, all leading zeros are truncated from the string representation.
    The following 6 bit to char mapping is used:
    0-9   -> 0-9
    10-35 -> A-Z
    36-60 -> a-y
    61    -> za
    62    -> zb
    63    -> zc
 

See Also:
Serialized Form

Nested Class Summary
static class GUID.MalformedGuidException
           
 
Constructor Summary
GUID()
          Create a new unique GUID
GUID(java.lang.String str)
          Reconstitute a GUID from it's string representation
 
Method Summary
 int compareTo(java.lang.Object o)
           
 boolean equals(java.lang.Object o)
           
 byte[] getGuid()
          Get the GUID bytes.
static GUID getVMGUID()
           
 int hashCode()
           
static void main(java.lang.String[] argv)
           
 java.lang.String toString()
          Convert a GUID to it's string representation.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GUID

public GUID()
Create a new unique GUID


GUID

public GUID(java.lang.String str)
     throws GUID.MalformedGuidException
Reconstitute a GUID from it's string representation

Parameters:
str - DOCUMENTME
Throws:
GUID.MalformedGuidException - DOCUMENTME
Method Detail

getGuid

public byte[] getGuid()
Get the GUID bytes.


getVMGUID

public static GUID getVMGUID()

compareTo

public int compareTo(java.lang.Object o)
Specified by:
compareTo in interface java.lang.Comparable

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

main

public static void main(java.lang.String[] argv)
                 throws java.lang.Exception
Throws:
java.lang.Exception

toString

public java.lang.String toString()
Convert a GUID to it's string representation. This will return a string of at most 32 bytes.

Overrides:
toString in class java.lang.Object
Returns:
DOCUMENTME