com.sun.faban.driver.util
Class Random

java.lang.Object
  extended by com.sun.faban.driver.util.Random

public class Random
extends Object

RandNum is a random number/value generator. This is a primitive facility for RandomValues. RandomValues and all subclasses generate application-specific random values.

Author:
Shanti Subramanyam

Constructor Summary
Random()
          Constructs the random value generator.
Random(long seed)
          Constructs the random value generators with a seed.
 
Method Summary
 double drandom(double x, double y)
          Selects a double random number uniformly distributed between x and y, inclusively, with a mean of (x+y)/2.
 long lrandom(long x, long y)
          Selects a long random number uniformly distributed between x and y, inclusively, with a mean of (x+y)/2.
 String makeAString(int x, int y)
          makeAString [x..y] generates a random string of alphanumeric characters of random lengthof mininum x, maximum y and mean (x+y)/2
 Calendar makeCalendarInInterval(Calendar min, Calendar max)
          Creates a random calendar between Calendar min and max.
 Calendar makeCalendarInInterval(Calendar ref, int min, int max, int units)
          Creates a random calendar between time ref + min and ref + max.
 String makeCString(int x, int y)
          makeCString [x..y] generates a random string of only alpahabet characters of random length of mininum x, maximum y and mean (x+y)/2
 Date makeDateInInterval(Date inDate, int x, int y)
          makeDateInInterval generates a java.sql.Date instance representing a Date within the range specified by (input Date + x) and (inputDate + y)
 String makeNString(int x, int y)
          makeNString [x..y] generates a random string of only numeric characters of random length of mininum x, maximum y and mean (x+y)/2.
 int NURand(int A, int x, int y)
          NURand integer non-uniform random number generator.
 int random(int x, int y)
          Selects a random number uniformly distributed between x and y, inclusively, with a mean of (x+y)/2.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Random

public Random()
Constructs the random value generator.


Random

public Random(long seed)
Constructs the random value generators with a seed.

Parameters:
seed - The seed for the random value generator
Method Detail

random

public int random(int x,
                  int y)
Selects a random number uniformly distributed between x and y, inclusively, with a mean of (x+y)/2.

Parameters:
x - the x value
y - the y value
Returns:
the random value between x and y, inclusive

lrandom

public long lrandom(long x,
                    long y)
Selects a long random number uniformly distributed between x and y, inclusively, with a mean of (x+y)/2.

Parameters:
x - the x value
y - the y value
Returns:
the random value between x and y, inclusive

drandom

public double drandom(double x,
                      double y)
Selects a double random number uniformly distributed between x and y, inclusively, with a mean of (x+y)/2.

Parameters:
x - the x value
y - the y value
Returns:
the random value between x and y, exclusive

NURand

public int NURand(int A,
                  int x,
                  int y)
NURand integer non-uniform random number generator. TPC-C function NURand(A, x, y) = (((random(0,A) | random(x,y)) + C) % (y - x + 1)) + x

Parameters:
A - the A value
x - the x value
y - the y value
Returns:
the random value between x and y, inclusive

makeAString

public String makeAString(int x,
                          int y)
makeAString [x..y] generates a random string of alphanumeric characters of random lengthof mininum x, maximum y and mean (x+y)/2

Parameters:
x - the minimum length
y - the maximum length
Returns:
the random string of length between x and y

makeCString

public String makeCString(int x,
                          int y)
makeCString [x..y] generates a random string of only alpahabet characters of random length of mininum x, maximum y and mean (x+y)/2

Parameters:
x - the minimum length
y - the maximum length
Returns:
the random character string of length between x and y

makeDateInInterval

public Date makeDateInInterval(Date inDate,
                               int x,
                               int y)
makeDateInInterval generates a java.sql.Date instance representing a Date within the range specified by (input Date + x) and (inputDate + y)

Parameters:
inDate - the reference date
x - minimum offset from the reference date
y - maximum offset from the reference date
Returns:
the resulting random date

makeCalendarInInterval

public Calendar makeCalendarInInterval(Calendar ref,
                                       int min,
                                       int max,
                                       int units)
Creates a random calendar between time ref + min and ref + max.

Parameters:
ref - The reference calendar
min - The lower time offset from ref
max - The upper time offset from ref
units - The units of min and max, referencing the fields of Calendar, e.g. Calendar.YEAR
Returns:
The randomly created calendar

makeCalendarInInterval

public Calendar makeCalendarInInterval(Calendar min,
                                       Calendar max)
Creates a random calendar between Calendar min and max.

Parameters:
min - The minimum time
max - The maximum time
Returns:
The randomly created calendar

makeNString

public String makeNString(int x,
                          int y)
makeNString [x..y] generates a random string of only numeric characters of random length of mininum x, maximum y and mean (x+y)/2.

Parameters:
x - the minimum length
y - the maximum length
Returns:
the random character string of length between x and y