Class UUID
- java.lang.Object
-
- org.apache.activemq.artemis.utils.UUID
-
public final class UUID extends java.lang.ObjectUUID represents Universally Unique Identifiers (aka Global UID in Windows world). UUIDs are usually generated via UUIDGenerator (or in case of 'Null UUID', 16 zero bytes, via static method getNullUUID()), or received from external systems.By default class caches the string presentations of UUIDs so that description is only created the first time it's needed. For memory stingy applications this caching can be turned off (note though that if uuid.toString() is never called, desc is never calculated so only loss is the space allocated for the desc pointer... which can of course be commented out to save memory).
Similarly, hash code is calculated when it's needed for the first time, and from thereon that value is just returned. This means that using UUIDs as keys should be reasonably efficient.
UUIDs can be compared for equality, serialized, cloned and even sorted. Equality is a simple bit-wise comparison. Ordering (for sorting) is done by first ordering based on type (in the order of numeric values of types), secondarily by time stamp (only for time-based time stamps), and finally by straight numeric byte-by-byte comparison (from most to least significant bytes).
-
-
Field Summary
Fields Modifier and Type Field Description static byteINDEX_CLOCK_HIstatic byteINDEX_CLOCK_LOstatic byteINDEX_CLOCK_MIDstatic byteINDEX_CLOCK_SEQUENCEstatic byteINDEX_TYPEstatic byteINDEX_VARIATIONstatic java.lang.StringNAMESPACE_DNSstatic java.lang.StringNAMESPACE_OIDstatic java.lang.StringNAMESPACE_URLstatic java.lang.StringNAMESPACE_X500static byteTYPE_DCEstatic byteTYPE_NAME_BASEDstatic byteTYPE_NULLstatic byteTYPE_RANDOM_BASEDstatic byteTYPE_TIME_BASED
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]asBytes()booleanequals(java.lang.Object o)Checking equality of UUIDs is easy; just compare the 128-bit number.inthashCode()static byte[]stringToBytes(java.lang.String uuid)Creates a 128bit number from the String representation ofUUID.java.lang.StringtoString()
-
-
-
Field Detail
-
INDEX_CLOCK_HI
public static final byte INDEX_CLOCK_HI
- See Also:
- Constant Field Values
-
INDEX_CLOCK_MID
public static final byte INDEX_CLOCK_MID
- See Also:
- Constant Field Values
-
INDEX_CLOCK_LO
public static final byte INDEX_CLOCK_LO
- See Also:
- Constant Field Values
-
INDEX_TYPE
public static final byte INDEX_TYPE
- See Also:
- Constant Field Values
-
INDEX_CLOCK_SEQUENCE
public static final byte INDEX_CLOCK_SEQUENCE
- See Also:
- Constant Field Values
-
INDEX_VARIATION
public static final byte INDEX_VARIATION
- See Also:
- Constant Field Values
-
TYPE_NULL
public static final byte TYPE_NULL
- See Also:
- Constant Field Values
-
TYPE_TIME_BASED
public static final byte TYPE_TIME_BASED
- See Also:
- Constant Field Values
-
TYPE_DCE
public static final byte TYPE_DCE
- See Also:
- Constant Field Values
-
TYPE_NAME_BASED
public static final byte TYPE_NAME_BASED
- See Also:
- Constant Field Values
-
TYPE_RANDOM_BASED
public static final byte TYPE_RANDOM_BASED
- See Also:
- Constant Field Values
-
NAMESPACE_DNS
public static final java.lang.String NAMESPACE_DNS
- See Also:
- Constant Field Values
-
NAMESPACE_URL
public static final java.lang.String NAMESPACE_URL
- See Also:
- Constant Field Values
-
NAMESPACE_OID
public static final java.lang.String NAMESPACE_OID
- See Also:
- Constant Field Values
-
NAMESPACE_X500
public static final java.lang.String NAMESPACE_X500
- See Also:
- Constant Field Values
-
-
Method Detail
-
asBytes
public byte[] asBytes()
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
stringToBytes
public static byte[] stringToBytes(java.lang.String uuid)
Creates a 128bit number from the String representation ofUUID.- Parameters:
uuid- The UUID- Returns:
- byte array that can be used to recreate a UUID instance from the given String representation
-
equals
public boolean equals(java.lang.Object o)
Checking equality of UUIDs is easy; just compare the 128-bit number.- Overrides:
equalsin classjava.lang.Object
-
-