public final class UUID extends Object
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).
Modifier and Type | Field and Description |
---|---|
static byte |
INDEX_CLOCK_HI |
static byte |
INDEX_CLOCK_LO |
static byte |
INDEX_CLOCK_MID |
static byte |
INDEX_CLOCK_SEQUENCE |
static byte |
INDEX_TYPE |
static byte |
INDEX_VARIATION |
static String |
NAMESPACE_DNS |
static String |
NAMESPACE_OID |
static String |
NAMESPACE_URL |
static String |
NAMESPACE_X500 |
static byte |
TYPE_DCE |
static byte |
TYPE_NAME_BASED |
static byte |
TYPE_NULL |
static byte |
TYPE_RANDOM_BASED |
static byte |
TYPE_TIME_BASED |
Constructor and Description |
---|
UUID(int type,
byte[] data) |
UUID(UUID uuid)
This is for conversions between two types of UUID
|
Modifier and Type | Method and Description |
---|---|
byte[] |
asBytes() |
boolean |
equals(Object o)
Checking equality of UUIDs is easy; just compare the 128-bit number.
|
int |
hashCode() |
static byte[] |
stringToBytes(String uuid)
Creates a 128bit number from the String representation of
UUID . |
String |
toString() |
public static final byte INDEX_CLOCK_HI
public static final byte INDEX_CLOCK_MID
public static final byte INDEX_CLOCK_LO
public static final byte INDEX_TYPE
public static final byte INDEX_CLOCK_SEQUENCE
public static final byte INDEX_VARIATION
public static final byte TYPE_NULL
public static final byte TYPE_TIME_BASED
public static final byte TYPE_DCE
public static final byte TYPE_NAME_BASED
public static final byte TYPE_RANDOM_BASED
public static final String NAMESPACE_DNS
public static final String NAMESPACE_URL
public static final String NAMESPACE_OID
public static final String NAMESPACE_X500
public UUID(int type, byte[] data)
type
- UUID typedata
- 16 byte UUID contentspublic UUID(UUID uuid)
public byte[] asBytes()
public static byte[] stringToBytes(String uuid)
UUID
.uuid
- The UUIDCopyright © 2020 JBoss by Red Hat. All rights reserved.