com.iwombat.util
Class GUIDUtil
java.lang.Object
com.iwombat.util.GUIDUtil
public class GUIDUtil
- extends java.lang.Object
Generic utility for converting byte-arrays containing UUIDs to Microsoft
style GUID strings. This entails some rather unique little-to-big endian
conversions.
Due to how MS structures a UUID (GUID) in c and its decomposition into
a string, there are some rather unique little endian conversions that take
place.
For example:
Hex string: a1b1c1d1a2b2a3b3a4b4a5b5c5d5e5f5
GUID string: {d1c1b1a1-b2a2-b3a3-b4a4-a5b5c5d5e5f5}
Implied MS c-struct:
struct {
int lowTime;
short midTime;
short highTimeAndVersion;
short sequenceAndVariant;
uchar[] macaddr;
} GUID
Note: These conversions will leave the original version and variant in tact and
will not convert to the MS version and variant or vice-versa.
Method Summary |
static java.lang.String |
guidStringFromHexString(java.lang.String hexString)
Convert hex string to GUID string |
static java.lang.String |
hexStringFromGUID(java.lang.String guidString)
Convert GUID string to a HEX string |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
GUIDUtil
public GUIDUtil()
guidStringFromHexString
public static java.lang.String guidStringFromHexString(java.lang.String hexString)
- Convert hex string to GUID string
- Parameters:
hexString
- - an untokenized hex string
- Returns:
- GUID string
- Throws:
java.lang.IllegalArgumentException
hexStringFromGUID
public static java.lang.String hexStringFromGUID(java.lang.String guidString)
- Convert GUID string to a HEX string
- Parameters:
guidString
- - tokenized MS-style GUID string
- Returns:
- hexString - untokenized hexString
- Throws:
java.lang.IllegalArgumentException