org.sakaiproject.metaobj.utils.id.guid
Class Guid

java.lang.Object
  extended byorg.sakaiproject.metaobj.utils.id.guid.Guid
All Implemented Interfaces:
Serializable

public class Guid
extends Object
implements Serializable

See Also:
Serialized Form

Field Summary
static byte AUTOGEN_BY_DB
           
static byte NO_AUTOGEN_BY_DB
           
 
Constructor Summary
Guid()
          Description: Allocate a new Guid object
Guid(byte[] inGuid)
          Description: Allocates a new Guid object from the passed in byte array.
Guid(String sGuid)
           
 
Method Summary
 boolean equals(Object o)
          from effective java by joshua bloch step 1: perform == test step 2: instanceof test step 3: cast parameter to type step 4: check primitives with ==, objects with equals()
static byte[] fromHexString(String sguid)
          Create a GUID bytes from a hex string version.
 boolean getDbAutoGen()
           
 byte[] getGuid()
          Get the raw bytes for this GUID
 String getString()
           
 int hashCode()
           
 boolean isDbAutoGen()
           
 boolean isValidGuid()
           
static boolean isValidGuidString(String sGuid)
           
 void setAutoGen(boolean dbAutoGen)
           
 void setGuid(byte[] inGuid)
          Sets GUID to passed in value
 String toString()
          Return string representation of the GUID as a hex value Example: returns the string 0x8f6eff8344a8e03b125590af6d21e9b2 This can be then passed to a database as a numerical value
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

AUTOGEN_BY_DB

public static final byte AUTOGEN_BY_DB
See Also:
Constant Field Values

NO_AUTOGEN_BY_DB

public static final byte NO_AUTOGEN_BY_DB
See Also:
Constant Field Values
Constructor Detail

Guid

public Guid()
Description: Allocate a new Guid object


Guid

public Guid(byte[] inGuid)
Description: Allocates a new Guid object from the passed in byte array.

Parameters:
inGuid - 16 byte array for this GUID
Throws:
IllegalArgumentException - if byte array is not GUID_LEN bytes

Guid

public Guid(String sGuid)
Method Detail

equals

public boolean equals(Object o)
from effective java by joshua bloch step 1: perform == test step 2: instanceof test step 3: cast parameter to type step 4: check primitives with ==, objects with equals()

Parameters:
o -
Returns:

hashCode

public int hashCode()

isValidGuid

public boolean isValidGuid()

setGuid

public void setGuid(byte[] inGuid)
             throws IllegalArgumentException
Sets GUID to passed in value

Parameters:
inGuid - 16-byte array containing raw GUID value
Throws:
IllegalArgumentException - if byte array is not GUID_LEN bytes

getGuid

public byte[] getGuid()
Get the raw bytes for this GUID

Returns:
the raw GUID in a byte array

getString

public String getString()

toString

public String toString()
Return string representation of the GUID as a hex value

Example: returns the string 0x8f6eff8344a8e03b125590af6d21e9b2

This can be then passed to a database as a numerical value

See Also:
internalToString()

fromHexString

public static byte[] fromHexString(String sguid)
                            throws IllegalArgumentException
Create a GUID bytes from a hex string version. Throws IllegalArgumentException if sguid is not of the proper format.

Throws:
IllegalArgumentException

isValidGuidString

public static boolean isValidGuidString(String sGuid)

isDbAutoGen

public boolean isDbAutoGen()

getDbAutoGen

public boolean getDbAutoGen()

setAutoGen

public void setAutoGen(boolean dbAutoGen)