Class UUIDGenerator
java.lang.Object
org.apache.catalina.tribes.util.UUIDGenerator
Simple generation of a UUID.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intNumber of bits per byte.static final intNumber of bytes per integer.protected static final RandomStandard random number generator.protected static final SecureRandomSecure random number generator.protected static final StringManagerStringManager for internationalized strings.static final intLength of a UUID in bytes.static final intUUID version. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidSame as java.util.Random.nextBytes except this one we don't have to allocate a new byte arraystatic byte[]randomUUID(boolean secure) Generates a random UUID.static byte[]randomUUID(boolean secure, byte[] into, int offset) Generates a random UUID and stores it in the provided byte array.
-
Field Details
-
sm
StringManager for internationalized strings. -
UUID_LENGTH
public static final int UUID_LENGTHLength of a UUID in bytes.- See Also:
-
UUID_VERSION
public static final int UUID_VERSIONUUID version.- See Also:
-
BYTES_PER_INT
public static final int BYTES_PER_INTNumber of bytes per integer.- See Also:
-
BITS_PER_BYTE
public static final int BITS_PER_BYTENumber of bits per byte.- See Also:
-
secrand
Secure random number generator. -
rand
Standard random number generator.
-
-
Constructor Details
-
UUIDGenerator
public UUIDGenerator()Constructs a new UUIDGenerator.
-
-
Method Details
-
randomUUID
public static byte[] randomUUID(boolean secure) Generates a random UUID.- Parameters:
secure- Whether to use a secure random generator- Returns:
- The generated UUID as a byte array
-
randomUUID
public static byte[] randomUUID(boolean secure, byte[] into, int offset) Generates a random UUID and stores it in the provided byte array.- Parameters:
secure- Whether to use a secure random generatorinto- The byte array to store the UUIDoffset- The offset in the byte array- Returns:
- The byte array containing the UUID
- Throws:
ArrayIndexOutOfBoundsException- If the byte array is too small
-
nextBytes
Same as java.util.Random.nextBytes except this one we don't have to allocate a new byte array- Parameters:
into- byte[]offset- intlength- intr- Random
-