public static class RandomUtils.DataGenerator extends Object
| Modifier and Type | Method | Description |
|---|---|---|
String |
nextHexString(int len,
boolean useSha1) |
Generates a random string of hex characters of length
len. |
long |
nextLong(long lower,
long upper) |
Generates a uniformly distributed random long integer between
lower
and upper (endpoints included). |
double |
nextUniform(double lower,
double upper) |
Generates a uniformly distributed random value from the open interval
(lower, upper) (i.e., endpoints excluded). |
double |
nextUniform(double lower,
double upper,
boolean lowerInclusive) |
Generates a uniformly distributed random value from the interval
(lower, upper) or the interval [lower, upper). |
public String nextHexString(int len, boolean useSha1)
len.
Algorithm Description: how hexadecimal strings are
generated depends on the value of the useSha1 argument.
useSha1 == false, a 2-step process is used:
len / 2 + 1 binary bytes are generated using the underlying
generator.
useSha1 == true, hex strings are generated in 40-byte
segments using a 3-step process:
len - Length of the generated string.useSha1 - Whether to use a digest.
If true (resp. false), the 3-step (resp. 2-step)
process will be used.NotStrictlyPositiveException - if len <= 0.public long nextLong(long lower,
long upper)
lower
and upper (endpoints included).lower - Lower bound for generated long integer.upper - Upper bound for generated long integer.lower
and less than or equal to upperNumberIsTooLargeException - if lower >= upperpublic double nextUniform(double lower,
double upper)
(lower, upper) (i.e., endpoints excluded).
Definition:
Uniform Distribution lower and upper - lower are the
location and scale parameters, respectively.
Algorithm Description: scales the output of Random.nextDouble(), but rejects 0 values (i.e., will generate another random double if Random.nextDouble() returns 0). This is necessary to provide a symmetric output interval (both endpoints excluded).
lower - Lower bound of the support (excluded).upper - Upper bound of the support (excluded).NumberIsTooLargeException - if lower >= upper.NotFiniteNumberException - if one of the bounds is infinite.NotANumberException - if one of the bounds is NaN.public double nextUniform(double lower,
double upper,
boolean lowerInclusive)
(lower, upper) or the interval [lower, upper). The lower
bound is thus optionally included, while the upper bound is always
excluded.
Definition:
Uniform Distribution lower and upper - lower are the
location and scale parameters, respectively.
Algorithm Description: if the lower bound is excluded, scales the output of "nextDouble()", but rejects 0 values (i.e. it will generate another random double if "nextDouble()" returns 0). This is necessary to provide a symmetric output interval (both endpoints excluded).
lower - Lower bound of the support.upper - Exclusive upper bound of the support.lowerInclusive - true if the lower bound is inclusive.(lower, upper)
interval, if lowerInclusive is false, or in the
[lower, upper) interval, if lowerInclusive is
true.NumberIsTooLargeException - if lower >= upper.NotFiniteNumberException - if one of the bounds is infinite.NotANumberException - if one of the bounds is NaN.Copyright © 2003–2017 The Apache Software Foundation. All rights reserved.