Package de.uplanet.util
Klasse Guid
java.lang.Object
de.uplanet.util.Guid
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.
-
Feldübersicht
FelderModifizierer und TypFeldBeschreibungstatic final StringA GUID string representation that contains only zeroes.static final GuidThe GUID that consists solely of zero bytes.static final StringThe algorithm used for generating GUIDs.static final intThe length of a GUID represented as a string. -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungstatic StringcheckValid(String p_str) Check if the given string is notnulland represents a GUID, and throw anIllegalArgumentExceptionif this is not the case.static StringcheckValidOrNull(String p_str) Check if the given string isnullor represents a GUID, and throw anIllegalArgumentExceptionif this is not the case.static GuidCreates an instance of GUID using the SHAPRNG algorithm and the current system time.static GuidcreateInstance(byte[]... p_randomBytes) Creates an instance of GUID using given random bytes.booleanbyte[]getBytes()Get the GUIDs20bytes.inthashCode()static booleanisStringRepresentation(String p_str) Tests if the given string is a GUID representation.static voidseed()Initialize the random number generator.toString()Convert the GUID to a string.
-
Felddetails
-
NULL
A GUID string representation that contains only zeroes.- Siehe auch:
-
NULL_GUID
The GUID that consists solely of zero bytes. -
SHA1PRNG
The algorithm used for generating GUIDs.- Siehe auch:
-
STRING_LENGTH
public static final int STRING_LENGTHThe length of a GUID represented as a string.- Siehe auch:
-
-
Methodendetails
-
seed
public static void seed()Initialize the random number generator.This method should be called at most once per Java VM instance.
-
createInstance
Creates an instance of GUID using the SHAPRNG algorithm and the current system time.- Gibt zurück:
- An initialized instance of Guid.
-
createInstance
Creates an instance of GUID using given random bytes.- Parameter:
p_randomBytes- Random bytes that are used to create the GUID.- Gibt zurück:
- An initialized instance of Guid.
-
getBytes
public byte[] getBytes()Get the GUIDs20bytes.- Gibt zurück:
- A copy of this GUIDs bytes.
-
isStringRepresentation
Tests if the given string is a GUID representation.- Parameter:
p_str- The string to test (may benull).- Gibt zurück:
trueif the string represents a GUID, orfalseif the given value isnullor does not represent a GUID.
-
checkValidOrNull
Check if the given string isnullor represents a GUID, and throw anIllegalArgumentExceptionif this is not the case.For security reasons possible error messages will contain at most an eight character prefix of the input string.
- Parameter:
p_str- The string to check.- Gibt zurück:
- The given string.
- Löst aus:
IllegalArgumentException- If the given string is notnulland does not represent a valid GUID.
-
checkValid
Check if the given string is notnulland represents a GUID, and throw anIllegalArgumentExceptionif this is not the case.For security reasons possible error messages will contain at most an eight character prefix of the input string.
- Parameter:
p_str- The string to check.- Gibt zurück:
- The given string.
- Löst aus:
IllegalArgumentException- If the given string isnullor does not represent a valid GUID.
-
equals
-
toString
Convert the GUID to a string. -
hashCode
public int hashCode()
-