# Class UUIDGenerator

java.lang.Object
org.apache.catalina.tribes.util.UUIDGenerator

public class UUIDGenerator extends Object
Simple generation of a UUID.

## Field Summary

Fields
Modifier and Type
Field
Description
`static final int`
`BITS_PER_BYTE`
Number of bits per byte.
`static final int`
`BYTES_PER_INT`
Number of bytes per integer.
`protected static final Random`
`rand`
Standard random number generator.
`protected static final SecureRandom`
`secrand`
Secure random number generator.
`protected static final StringManager`
`sm`
StringManager for internationalized strings.
`static final int`
`UUID_LENGTH`
Length of a UUID in bytes.
`static final int`
`UUID_VERSION`
UUID version.

## Constructor Summary

Constructors
Constructor
Description
`UUIDGenerator()`
Constructs a new UUIDGenerator.

## Method Summary

Modifier and Type
Method
Description
`static void`
`nextBytes(byte[] into, int offset, int length, Random r)`
Same as java.util.Random.nextBytes except this one we don't have to allocate a new byte array
`static byte[]`
`randomUUID(boolean secure)`
Generates a random UUID.
`static byte[]`
`randomUUID(boolean secure, byte[] dest, int offset)`
Generates a random UUID and stores it in the provided byte array.

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### sm

protected static final StringManager sm
StringManager for internationalized strings.

### UUID_LENGTH

public static final int UUID_LENGTH
Length of a UUID in bytes.

See Also:
  - Constant Field Values

### UUID_VERSION

public static final int UUID_VERSION
UUID version.

See Also:
  - Constant Field Values

### BYTES_PER_INT

public static final int BYTES_PER_INT
Number of bytes per integer.

See Also:
  - Constant Field Values

### BITS_PER_BYTE

public static final int BITS_PER_BYTE
Number of bits per byte.

See Also:
  - Constant Field Values

### secrand

protected static final SecureRandom secrand
Secure random number generator.

### rand

protected static final Random 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[] dest, int offset)
Generates a random UUID and stores it in the provided byte array.

Parameters:
  `secure` - Whether to use a secure random generator
  `dest` - The byte array to store the UUID
  `offset` - The offset in the byte array
Returns:
  The byte array containing the UUID
Throws:
  `ArrayIndexOutOfBoundsException` - If the destination byte array is null, the destination byte array is too small or the offset is negative

### nextBytes

public static void nextBytes(byte[] into, int offset, int length, Random r)
Same as java.util.Random.nextBytes except this one we don't have to allocate a new byte array

Parameters:
  `into` - byte[]
  `offset` - int
  `length` - int
  `r` - Random