org.ipdr.utils
Class UUIDUtil

java.lang.Object
  extended by org.ipdr.utils.UUIDUtil

public class UUIDUtil
extends java.lang.Object

The UUIDUtil class provides utilities for creating and displaying 128 bit (16 byte) UUID's.

This implementation deviates slightly from the original OSF DCE UUID specification (@see draft-leach-uuids-guids-01


Field Summary
protected static short HOSTADDR_SIZE
          Raw IP address size.
protected static byte[] hostAddrs_
          Raw IP address (in network byte order).
protected static java.util.Random UUID_seed_
          Random variable used in UUID creation.
static short UUID_SIZE
          Size of the UUID field when represented in hex binary.
protected static int UUID_VARIANT
          The OSF DCE variant.
protected static short UUID_VERSION
          This version is based on the OSF DCE version.
 
Constructor Summary
UUIDUtil()
           
 
Method Summary
static byte[] convUUIDToByteArray(java.lang.String docId)
          This method takes the UUID string format as per pattern specified in the NDM-U 3.0 specification as input and converts it into Byte array.
static byte[] getNewUUID()
          Method to get a new UUID.
static void main(java.lang.String[] args)
          Simple test entry point.
static java.lang.String toString(byte[] uuid)
          Generates a printable string containing the byte array in the standard UUID format.
static int writeInt(byte[] buf, int start, int value)
          Writes a 'int' to the input byte array.
static int writeShort(byte[] buf, int start, short value)
          Writes a 'short' to the input byte buffer at the specified starting index.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UUID_SIZE

public static final short UUID_SIZE
Size of the UUID field when represented in hex binary.

See Also:
Constant Field Values

UUID_VERSION

protected static final short UUID_VERSION
This version is based on the OSF DCE version. According to that spec, the version is the most significant 4 bits of the time stamp. Only values 1-4 are defined. Since we do not fully comply with any of the defined versions, we choose 5, to avoid conflict and indicate that this is a new version.

See Also:
Constant Field Values

UUID_VARIANT

protected static final int UUID_VARIANT
The OSF DCE variant. Sicne we don't fully comply here either, we set all 3 bits on (e), which means "reserved for future definition" according to the spec.

See Also:
Constant Field Values

UUID_seed_

protected static java.util.Random UUID_seed_
Random variable used in UUID creation.


HOSTADDR_SIZE

protected static final short HOSTADDR_SIZE
Raw IP address size.

See Also:
Constant Field Values

hostAddrs_

protected static byte[] hostAddrs_
Raw IP address (in network byte order).

Constructor Detail

UUIDUtil

public UUIDUtil()
Method Detail

getNewUUID

public static byte[] getNewUUID()
Method to get a new UUID.

Returns:
Hex Binary containing the UUID.

toString

public static java.lang.String toString(byte[] uuid)
Generates a printable string containing the byte array in the standard UUID format.

Parameters:
uuid - 16 byte array containing a valid UUID.
Returns:
UUID in the standard printable (dashed) format.

convUUIDToByteArray

public static byte[] convUUIDToByteArray(java.lang.String docId)
                                  throws IPDRException
This method takes the UUID string format as per pattern specified in the NDM-U 3.0 specification as input and converts it into Byte array.

Parameters:
docId - UUID in String format
Returns:
byte[] byte array
Throws:
IPDRException

writeInt

public static int writeInt(byte[] buf,
                           int start,
                           int value)
Writes a 'int' to the input byte array.

Parameters:
buf - the array to write to
start - the beginning offset in the array to start processing
value - a 'int' to be written
Returns:
index of the next field in the input buf following this write

writeShort

public static int writeShort(byte[] buf,
                             int start,
                             short value)
Writes a 'short' to the input byte buffer at the specified starting index.

Parameters:
buf - the array to write to
start - the beginning offset in the array to start processing
value - a 'short' to be written
Returns:
index of the next field in the input buf following this write

main

public static void main(java.lang.String[] args)
Simple test entry point. Creates a new UUID. Then it invokes toString() method to display.