public class UUID extends Object implements Serializable, Cloneable, Comparable<UUID>
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()
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...
|
Modifier and Type | Method and Description |
---|---|
byte[] |
asByteArray()
Returns the UUID as a 16-byte byte array
|
Object |
clone()
Default cloning behaviour (bitwise copy) is just fine...
|
int |
compareTo(UUID o) |
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() |
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.
|
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()
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
public Object clone()
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 compareTo(UUID o)
compareTo
in interface Comparable<UUID>
public boolean equals(Object o)
public static UUID valueOf(String id) throws NumberFormatException
id
- Canonical string representation used for constructing
an UUID instanceNumberFormatException
- 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 definitionCopyright © 2015. All rights reserved.