ca.bc.gov.webade.user
Class GUID

java.lang.Object
  extended byca.bc.gov.webade.user.GUID
All Implemented Interfaces:
java.io.Serializable

public final class GUID
extends java.lang.Object
implements java.io.Serializable

Author:
jross
See Also:
Serialized Form

Constructor Summary
GUID(byte[] guidBytes)
          Creates a GUID instance using a byte-array containing a native GUID binary value.
GUID(java.lang.String guidString)
          Creates a GUID instance using a Microsoft-formatted GUID string.
GUID(java.lang.String guidString, boolean isNativeFormat)
          Creates a GUID instance using a Hex-based GUID string.
 
Method Summary
static java.lang.String convertGUIDStringFormat(java.lang.String guid)
          Converts the given GUID between native GUID and Microsoft GUID and returns the result.
static byte[] convertMicrosoftGUIDToNativeBytes(java.lang.String microsoftGuid)
          Converts the given microsoft guid to a byte array representation.
static java.lang.String convertNativeBytesToMicrosoftGUID(byte[] guidBytes)
          Converts the given guid byte array to a microsoft string representation.
static java.lang.String convertNativeBytesToNativeGUID(byte[] guidBytes)
          Converts the given guid byte array to a native string representation.
static byte[] convertNativeGUIDToNativeBytes(java.lang.String nativeGuid)
          Converts the given native guid to a byte array representation.
 boolean equals(java.lang.Object object)
           
 boolean isValid()
           
 java.lang.String toMicrosoftGUIDString()
           
 byte[] toNativeByteArray()
           
 java.lang.String toNativeGUIDString()
           
 java.lang.String toString()
           
static boolean validate(byte[] guidBytes)
          Validates the given byte array to ensure its value represents a valid guid value.
static boolean validate(java.lang.String guidString)
          Validates the given string to ensure its value represents a valid guid value.
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GUID

public GUID(byte[] guidBytes)
Creates a GUID instance using a byte-array containing a native GUID binary value.

Parameters:
guidBytes - The GUID binary in byte array form.

GUID

public GUID(java.lang.String guidString)
Creates a GUID instance using a Microsoft-formatted GUID string.

Parameters:
guidString - The GUID string value.

GUID

public GUID(java.lang.String guidString,
            boolean isNativeFormat)
Creates a GUID instance using a Hex-based GUID string.

Parameters:
guidString - The GUID string value.
isNativeFormat - A flag indicating whether the GUID string is in native or Microsoft format.
Method Detail

convertGUIDStringFormat

public static final java.lang.String convertGUIDStringFormat(java.lang.String guid)
Converts the given GUID between native GUID and Microsoft GUID and returns the result. For example: 00D26B7C1AECEE4F8B8353B74D2E5BA5 to 7C6BD200EC1A4FEE8B8353B74D2E5BA5

Parameters:
guid - The guid to convert.
Returns:
The converted guid, or null if the given string is not a valid guid.

convertNativeGUIDToNativeBytes

public static byte[] convertNativeGUIDToNativeBytes(java.lang.String nativeGuid)
Converts the given native guid to a byte array representation.

Parameters:
nativeGuid - The native guid to convert.
Returns:
The byte array containing the guid value in byte form, or null if the given value is not a valid guid.

convertMicrosoftGUIDToNativeBytes

public static byte[] convertMicrosoftGUIDToNativeBytes(java.lang.String microsoftGuid)
Converts the given microsoft guid to a byte array representation.

Parameters:
microsoftGuid - The microsoft guid to convert.
Returns:
The byte array containing the guid value in byte form, or null if the given value is not a valid guid.

convertNativeBytesToNativeGUID

public static java.lang.String convertNativeBytesToNativeGUID(byte[] guidBytes)
Converts the given guid byte array to a native string representation.

Parameters:
guidBytes - The guid to convert.
Returns:
The native guid value in string form, or null if the given value is not a valid guid.

convertNativeBytesToMicrosoftGUID

public static java.lang.String convertNativeBytesToMicrosoftGUID(byte[] guidBytes)
Converts the given guid byte array to a microsoft string representation.

Parameters:
guidBytes - The guid to convert.
Returns:
The microsoft guid value in string form, or null if the given value is not a valid guid.

validate

public static boolean validate(java.lang.String guidString)
Validates the given string to ensure its value represents a valid guid value.

Parameters:
guidString - The guid string to validate.
Returns:
True if the string contains a valid guid string.

validate

public static boolean validate(byte[] guidBytes)
Validates the given byte array to ensure its value represents a valid guid value.

Parameters:
guidBytes - The guid byte array to validate.
Returns:
True if the array contains a valid guid value.

toNativeByteArray

public byte[] toNativeByteArray()
Returns:
The native GUID byte array representation of this GUID.

toNativeGUIDString

public java.lang.String toNativeGUIDString()
Returns:
The native GUID string representation of this GUID.

toMicrosoftGUIDString

public java.lang.String toMicrosoftGUIDString()
Returns:
The Microsoft GUID string representation of this GUID.

isValid

public boolean isValid()
Returns:
Returns true if the GUID is valid.

equals

public boolean equals(java.lang.Object object)
See Also:
Object.equals(java.lang.Object)

toString

public java.lang.String toString()
See Also:
Object.toString()