Class UUID
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
FieldsModifier and TypeFieldDescriptionstatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final bytestatic final bytestatic final bytestatic final bytestatic final byte -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
INDEX_CLOCK_HI
public static final byte INDEX_CLOCK_HI- See Also:
-
INDEX_CLOCK_MID
public static final byte INDEX_CLOCK_MID- See Also:
-
INDEX_CLOCK_LO
public static final byte INDEX_CLOCK_LO- See Also:
-
INDEX_TYPE
public static final byte INDEX_TYPE- See Also:
-
INDEX_CLOCK_SEQUENCE
public static final byte INDEX_CLOCK_SEQUENCE- See Also:
-
INDEX_VARIATION
public static final byte INDEX_VARIATION- See Also:
-
TYPE_NULL
public static final byte TYPE_NULL- See Also:
-
TYPE_TIME_BASED
public static final byte TYPE_TIME_BASED- See Also:
-
TYPE_DCE
public static final byte TYPE_DCE- See Also:
-
TYPE_NAME_BASED
public static final byte TYPE_NAME_BASED- See Also:
-
TYPE_RANDOM_BASED
public static final byte TYPE_RANDOM_BASED- See Also:
-
NAMESPACE_DNS
- See Also:
-
NAMESPACE_URL
- See Also:
-
NAMESPACE_OID
- See Also:
-
NAMESPACE_X500
- See Also:
-
-
Constructor Details
-
UUID
public UUID(int type, byte[] data) - Parameters:
type- UUID typedata- 16 byte UUID contents
-
UUID
This is for conversions between two types of UUID
-
-
Method Details
-
asBytes
public byte[] asBytes() -
hashCode
public int hashCode() -
toString
-
stringToBytes
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
Checking equality of UUIDs is easy; just compare the 128-bit number.
-