Class Randoms

java.lang.Object
com.oracle.coherence.common.base.Randoms

public abstract class Randoms extends Object
Class for providing random functionality.
Since:
20.06
Author:
cp 2000.08.02
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    Return a random number assigned to this process.
    static Random
    Obtain a Random object that can be used to get random values.
    static Binary
    getRandomBinary(int cbMin, int cbMax)
    Generates a random-length Binary within the length bounds provided whose contents are random bytes.
    static Binary
    getRandomBinary(int cbMin, int cbMax, byte... abHead)
    Generates a random-length Binary including abHead at the head of the Binary, in addition to random bytes within the length bounds provided.
    static String
    getRandomString(int cchMin, int cchMax, boolean fAscii)
    Generates a random-length String within the length bounds provided.
    static int[]
    randomize(int[] a)
    Randomize the order of the elements within the passed array.
    static long[]
    randomize(long[] a)
    Randomize the order of the elements within the passed array.
    static Object[]
    Randomize the order of the elements within the passed array.
    static List
    Randomize the order of the elements within the passed collection.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Randoms

      public Randoms()
  • Method Details

    • getProcessRandom

      public static int getProcessRandom()
      Return a random number assigned to this process.

      This value will remain the same across invocations, but is generally different across JVMs.

      Returns:
      the process's random number.
    • getRandom

      public static Random getRandom()
      Obtain a Random object that can be used to get random values.
      Returns:
      a random number generator
      Since:
      Coherence 3.2
    • randomize

      public static List randomize(Collection coll)
      Randomize the order of the elements within the passed collection.
      Parameters:
      coll - the Collection to randomize; the passed Collection is not altered
      Returns:
      a new and immutable List whose contents are identical to those of the passed collection except for the order in which they appear
      Since:
      Coherence 3.2
    • randomize

      public static Object[] randomize(Object[] a)
      Randomize the order of the elements within the passed array.
      Parameters:
      a - an array of objects to randomize
      Returns:
      the array that was passed in, and with its contents unchanged except for the order in which they appear
      Since:
      Coherence 3.2
    • randomize

      public static int[] randomize(int[] a)
      Randomize the order of the elements within the passed array.
      Parameters:
      a - an array of int values to randomize
      Returns:
      the array that was passed in, and with its contents unchanged except for the order in which they appear
      Since:
      Coherence 3.2
    • randomize

      public static long[] randomize(long[] a)
      Randomize the order of the elements within the passed array.
      Parameters:
      a - an array of long values to randomize
      Returns:
      the array that was passed in, and with its contents unchanged except for the order in which they appear
      Since:
      Coherence 12.2.1.4
    • getRandomBinary

      public static Binary getRandomBinary(int cbMin, int cbMax)
      Generates a random-length Binary within the length bounds provided whose contents are random bytes.
      Parameters:
      cbMin - the minimum number of bytes in the resulting Binary
      cbMax - the maximum number of bytes in the resulting Binary
      Returns:
      a randomly generated Binary object
      Since:
      Coherence 3.2
    • getRandomBinary

      public static Binary getRandomBinary(int cbMin, int cbMax, byte... abHead)
      Generates a random-length Binary including abHead at the head of the Binary, in addition to random bytes within the length bounds provided.
      Parameters:
      cbMin - the minimum number of bytes in the resulting Binary
      cbMax - the maximum number of bytes in the resulting Binary
      abHead - the head of the returned Binary
      Returns:
      a randomly generated Binary object with a length of [len(abHead) + cbMin, cbMax]
      Since:
      Coherence 12.1.3
    • getRandomString

      public static String getRandomString(int cchMin, int cchMax, boolean fAscii)
      Generates a random-length String within the length bounds provided. If the ASCII option is indicated, the characters will be in the range [32-127], otherwise the characters will be in the range [0x0000-0xFFFF].
      Parameters:
      cchMin - the minimum length of the resulting String
      cchMax - the maximum length of the resulting String
      fAscii - true if the resulting String should contain only ASCII values
      Returns:
      a randomly generated String object
      Since:
      Coherence 3.2