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
    Number of bits per byte.
    static final int
    Number of bytes per integer.
    protected static final Random
    Standard random number generator.
    protected static final SecureRandom
    Secure random number generator.
    protected static final StringManager
    StringManager for internationalized strings.
    static final int
    Length of a UUID in bytes.
    static final int
    UUID version.
  • Constructor Summary

    Constructors
    Constructor
    Description
    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[] into, 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:
    • UUID_VERSION

      public static final int UUID_VERSION
      UUID version.
      See Also:
    • BYTES_PER_INT

      public static final int BYTES_PER_INT
      Number of bytes per integer.
      See Also:
    • BITS_PER_BYTE

      public static final int BITS_PER_BYTE
      Number of bits per byte.
      See Also:
    • 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[] into, int offset)
      Generates a random UUID and stores it in the provided byte array.
      Parameters:
      secure - Whether to use a secure random generator
      into - 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 byte array is too small
    • 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