de.uplanet.util
Class Guid

java.lang.Object
  extended by de.uplanet.util.Guid

@Scriptable
public final class Guid
extends java.lang.Object

This class represents global universal IDs.

Instances of this class are immutable.

This class uses the SHAPRNG for secure random numbers and the SHA-1 algorithm for hashing to 20 bytes.

Version:
$Revision: 55008 $

Field Summary
static java.lang.String NULL
          A GUID string representation that contains only zeroes.
static java.lang.String SHA1PRNG
          The algorithm used for generating GUIDs.
static int STRING_LENGTH
          The length of a GUID represented as a string.
 
Method Summary
static Guid createInstance()
          Creates an instance of GUID using the SHAPRNG algorithm and the current system time.
static Guid createInstance(byte[] p_randomBytes)
          Creates an instance of GUID using given random bytes.
 boolean equals(java.lang.Object p_obj)
           
 byte[] getBytes()
          Get the GUIDs 20 bytes.
 int hashCode()
           
static boolean isStringRepresentation(java.lang.String p_str)
          Tests if the given string is a GUID representation.
static void seed()
          Initialize the random number generator.
 java.lang.String toString()
          Convert the GUID to a string.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

NULL

public static final java.lang.String NULL
A GUID string representation that contains only zeroes.

See Also:
Constant Field Values

SHA1PRNG

public static final java.lang.String SHA1PRNG
The algorithm used for generating GUIDs.

See Also:
Constant Field Values

STRING_LENGTH

public static final int STRING_LENGTH
The length of a GUID represented as a string.

See Also:
Constant Field Values
Method Detail

seed

public static void seed()
Initialize the random number generator.

This method should be called at most once per Java VM instance.


createInstance

public static Guid createInstance()
Creates an instance of GUID using the SHAPRNG algorithm and the current system time.

Returns:
An initialized instance of Guid.

createInstance

public static Guid createInstance(byte[] p_randomBytes)
Creates an instance of GUID using given random bytes.

Returns:
An initialized instance of Guid.

getBytes

public byte[] getBytes()
Get the GUIDs 20 bytes.

Returns:
A copy of this GUIDs bytes.

isStringRepresentation

public static boolean isStringRepresentation(java.lang.String p_str)
Tests if the given string is a GUID representation.

Parameters:
p_str - The string to test (may be null).
Returns:
true if the string is representing a GUID, false otherwise.

equals

public boolean equals(java.lang.Object p_obj)
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Convert the GUID to a string.

Overrides:
toString in class java.lang.Object
Returns:
The string representation of the GUID.

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object


Last updated: 2011-08-11 10-04
Copyright © 2000-2011 United Planet. All Rights Reserved.