|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.drools.util.UUID
public class UUID
UUID 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 | |
---|---|
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 Summary | |
---|---|
UUID()
Default constructor creates a NIL UUID, one that contains all zeroes Note that the clearing of array is actually unnecessary as JVMs are required to clear up the allocated arrays by default. |
|
UUID(byte[] data)
Constructor for cases where you already have the 16-byte binary representation of the UUID (for example if you save UUIDs binary takes less than half of space string representation takes). |
|
UUID(byte[] data,
int start)
Constructor for cases where you already have the binary representation of the UUID (for example if you save UUIDs binary takes less than half of space string representation takes) in a byte array |
|
UUID(String id)
Constructor for creating UUIDs from the canonical string representation Note that implementation is optimized for speed, not necessarily code clarity... |
Method Summary | |
---|---|
byte[] |
asByteArray()
Returns the UUID as a 16-byte byte array |
Object |
clone()
Default cloning behaviour (bitwise copy) is just fine... |
int |
compareTo(Object o)
Let's also make UUIDs sortable. |
boolean |
equals(Object o)
Checking equality of UUIDs is easy; just compare the 128-bit number. |
static UUID |
getNullUUID()
Accessor for getting the shared null UUID |
int |
getType()
Returns the UUID type code |
int |
hashCode()
|
boolean |
isNullUUID()
|
static void |
setDescCaching(boolean state)
|
byte[] |
toByteArray()
'Synonym' for 'asByteArray' |
void |
toByteArray(byte[] dst)
|
void |
toByteArray(byte[] dst,
int pos)
Fills in the 16 bytes (from index pos) of the specified byte array with the UUID contents. |
String |
toString()
|
static UUID |
valueOf(byte[] src)
Constructs a new UUID instance given a byte array that contains the (16 byte) binary representation. |
static UUID |
valueOf(byte[] src,
int start)
Constructs a new UUID instance given a byte array that contains the (16 byte) binary representation. |
static UUID |
valueOf(String id)
Constructs a new UUID instance given the canonical string representation of an UUID. |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
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
Constructor Detail |
---|
public UUID()
public UUID(byte[] data)
data
- array that contains the binary representation of UUIDpublic UUID(byte[] data, int start)
data
- array that contains the binary representation of UUIDstart
- byte offset where UUID startspublic UUID(String id) throws NumberFormatException
id
- String that contains the canonical representation of
the UUID to build; 36-char string (see UUID specs for details).
Hex-chars may be in upper-case too; UUID class will always output
them in lowercase.
NumberFormatException
Method Detail |
---|
public Object clone()
public static void setDescCaching(boolean state)
public static UUID getNullUUID()
public boolean isNullUUID()
public int getType()
public byte[] asByteArray()
public void toByteArray(byte[] dst, int pos)
dst
- Byte array to fillpos
- Offset in the arraypublic void toByteArray(byte[] dst)
public byte[] toByteArray()
public int hashCode()
public String toString()
public int compareTo(Object o)
compareTo
in interface Comparable
o
- Object to compare this UUID to; should be a UUID
ClassCastException
- if o is not a UUID.public boolean equals(Object o)
public static UUID valueOf(String id) throws NumberFormatException
id
- Canonical string representation used for constructing
an UUID instance
NumberFormatException
- if 'id' is invalid UUIDpublic static UUID valueOf(byte[] src, int start)
src
- Byte array that contains the UUID definitionstart
- Offset in the array where the UUID startspublic static UUID valueOf(byte[] src)
src
- Byte array that contains the UUID definition
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |