Package com.day.util

Class UUID

  • All Implemented Interfaces:
    java.io.Serializable

    public class UUID
    extends java.lang.Object
    implements java.io.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
    See Also:
    Serialized Form
    • Field Summary

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

      Constructors 
      Constructor Description
      UUID()
      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​(java.lang.String string)
      Generates a UUID from a string.
      UUID​(java.lang.String name, java.lang.String namespace)
      Create a name base UUID (version 3)
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static UUID create()
      Generate a UUID for this host using version 1 of [leach]
      boolean equals​(java.lang.Object toUUID)
      Compare two UUIDs
      byte[] getBytes()
      Returns the bytes of the uuid
      int getVersion()
      Get the UUID version number.
      int hashCode()
      Returns a hash code value for the object.
      static void init​(java.io.File uuidStateFile)
      Initialize the UUID generator.
      java.lang.String toString()
      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 Detail

      • hexDigits

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

      • UUID

        public UUID​(java.lang.String string)
        Generates a UUID from a string. the string must have the form. the version is set accoridingly. "00000000-0000-0000-0000-000000000000"
      • UUID

        public UUID​(byte[] bytes)
        Creates a UUID from a byte array.
      • UUID

        public UUID​(long[] longs)
        Creates a UUID from 2 longs
      • UUID

        public UUID​(java.lang.String name,
                    java.lang.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.
    • Method Detail

      • getVersion

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

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

        public java.lang.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 java.lang.Object
      • getBytes

        public byte[] getBytes()
        Returns the bytes of the uuid
      • 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 java.lang.Object
        Returns:
        a hash code value for this object.
        See Also:
        Object.equals(java.lang.Object), Hashtable
      • init

        public static void init​(java.io.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]