Package com.day.util

Class UUID

java.lang.Object
com.day.util.UUID
All Implemented Interfaces:
Serializable

public class UUID extends Object implements Serializable
A Universally Unique Identifier (UUID) is a 128 bit number generated according to an algorithm that is garanteed to be unique in time and space from all other UUIDs. It consists of an IEEE 802 Internet Address and various time stamps to ensure uniqueness. For a complete specification, see http://www.ietf.org/internet-drafts/draft-mealling-uuid-urn-05.txt
Since:
antbear Audience wad
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final char[]
    hexdigits for toString
  • Constructor Summary

    Constructors
    Constructor
    Description
    Generates a random UUID (version 4)
    UUID(byte[] bytes)
    Creates a UUID from a byte array.
    UUID(byte[] node, long time, short clock)
    Generate a time-based UUID for this host (version 1).
    UUID(long[] longs)
    Creates a UUID from 2 longs
    UUID(String string)
    Generates a UUID from a string.
    UUID(String name, String namespace)
    Create a name base UUID (version 3)
  • Method Summary

    Modifier and Type
    Method
    Description
    static UUID
    Generate a UUID for this host using version 1 of [leach]
    boolean
    equals(Object toUUID)
    Compare two UUIDs
    byte[]
    Returns the bytes of the uuid
    int
    Get the UUID version number.
    int
    Returns a hash code value for the object.
    static void
    init(File uuidStateFile)
    Initialize the UUID generator.
    Provide a String representation of a UUID as specified in section 3.5 of [leach].

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • hexDigits

      public static final char[] hexDigits
      hexdigits for toString
  • Constructor Details

    • UUID

      public UUID(String string)
      Generates a UUID from a string. the string must have the form. the version is set accoridingly. "00000000-0000-0000-0000-000000000000"
      Parameters:
      string - the string to use
    • UUID

      public UUID(byte[] bytes)
      Creates a UUID from a byte array.
      Parameters:
      bytes - the byte array
    • UUID

      public UUID(long[] longs)
      Creates a UUID from 2 longs
      Parameters:
      longs - the 2 longs
    • UUID

      public UUID(String name, String namespace)
      Create a name base UUID (version 3)
    • UUID

      public UUID()
      Generates a random UUID (version 4)
    • UUID

      public UUID(byte[] node, long time, short clock)
      Generate a time-based UUID for this host (version 1).
       Field                  Data Type     Octet# Note
       time_low               unsigned 32   0-3    The low field of the
                              bit integer          timestamp.
      
       time_mid               unsigned 16   4-5    The middle field of the
                              bit integer          timestamp.
      
       time_hi_and_version    unsigned 16   6-7    The high field of the
                              bit integer          timestamp multiplexed
                                                   with the version number.
      
       clock_seq_hi_and_rese  unsigned 8    8      The high field of the
       rved                   bit integer          clock sequence
                                                   multiplexed with the
                                                   variant.
      
       clock_seq_low          unsigned 8    9      The low field of the
                              bit integer          clock sequence.
      
       node                   unsigned 48   10-15  The spatially unique
                              bit integer          node identifier.
       
      Parameters:
      node - the node
      time - the time
      clock - the clock
  • Method Details

    • getVersion

      public int getVersion()
      Get the UUID version number.
      Returns:
      the version
    • equals

      public boolean equals(Object toUUID)
      Compare two UUIDs
      Overrides:
      equals in class Object
      Returns:
      true if the UUIDs are equal; false otherwise.
    • toString

      public String toString()
      Provide a String representation of a UUID as specified in section 3.5 of [leach]. it has this format: "00000000-0000-0000-0000-000000000000"
      Overrides:
      toString in class Object
    • getBytes

      public byte[] getBytes()
      Returns the bytes of the uuid
      Returns:
      the bytes
    • hashCode

      public int hashCode()
      Returns a hash code value for the object. This method is supported for the benefit of hashtables such as those provided by java.util.Hashtable.
      Overrides:
      hashCode in class Object
      Returns:
      a hash code value for this object.
      See Also:
    • init

      public static void init(File uuidStateFile)
      Initialize the UUID generator.
      Parameters:
      uuidStateFile - the to read/write the state from
    • create

      public static UUID create()
      Generate a UUID for this host using version 1 of [leach]
      Returns:
      the UUID