UUID class in the JSR-82 API
public UUID(java.lang.String uuidValue, boolean shortUUID)
Creates a UUID object from the string provided. The characters in the string must be from the hexadecimal set [0-9, a-f, A-F]. It is important to note that the prefix "0x" generally used for hex representation of numbers is not allowed. If the string does not have characters from the hexadecimal set, an exception will be thrown. The string length has to be positive and less than or equal to 32. A string length that exceeds 32 is illegal and will cause an exception. Finally, a null input is also considered illegal and causes an exception.
If shortUUID is true
, uuidValue represents a 16-bit or 32-bit UUID. If uuidValue is in the range 0x0000 to 0xFFFF then this constructor will create a 16-bit UUID. If uuidValue is in the range 0x00010000 to 0xFFFFFFFF, then this constructor will create a 32-bit UUID. Therefore, uuidValue may only be 8 characters long.
On the other hand, if shortUUID is false
, then uuidValue represents a 128-bit UUID. Therefore, uuidValue may only be 32 character long
uuidValue - the string representation of a 16-bit, 32-bit or 128-bit UUID
shortUUID - indicates the size of the UUID to be constructed; true is used to indicate short UUIDs, i.e. either 16-bit or 32-bit; false indicates an 128-bit UUID
NumberFormatException - if uuidValue has characters that are not defined in the hexadecimal set [0-9, a-f, A-F]
IllegalArgumentException - if uuidValue length is zero; if shortUUID is true and uuidValue's length is greater than 8; if shortUUID is false and uuidValue's length is greater than 32
NullPointerException - if uuidValue is null