A random data generator class.
| Methods |
|
RandomGen()
Create a new random instance with a fixed seed value.
|
|
RandomGen()
Create a new random instance with a fixed seed value.
|
| boolean |
getBoolean(int percent)
Get a boolean that is true with the given probability in percent.
|
| boolean |
getBoolean(int percent)
Get a boolean that is true with the given probability in percent.
Parameters:
percent - the probability
Returns:
the boolean value
|
| byte[] |
getByteArray()
Get a random byte array.
|
| byte[] |
getByteArray()
Get a random byte array. In 10% of the cases, null is returned.
Returns:
the array
|
| void |
getBytes(byte[] data)
Get a number of random bytes.
|
| void |
getBytes(byte[] data)
Get a number of random bytes.
Parameters:
data - the target buffer
|
| int |
getInt(int max)
Get the next integer that is smaller than max.
|
| int |
getInt(int max)
Get the next integer that is smaller than max.
Parameters:
max - the upper limit (exclusive)
Returns:
the random value
|
| int[] |
getIntArray()
Get a random integer array.
|
| int[] |
getIntArray()
Get a random integer array. In 10% of the cases, null is returned.
Returns:
the array
|
| int |
getLog(int max)
Get the next random value that is at most max but probably much lower.
|
| int |
getLog(int max)
Get the next random value that is at most max but probably much lower.
Parameters:
max - the maximum value
Returns:
the value
|
| double |
getRandomDouble()
Get a random double.
|
| double |
getRandomDouble()
Get a random double. The algorithm is similar to a random int.
Returns:
the random value
|
| int |
getRandomInt()
Get a random integer.
|
| int |
getRandomInt()
Get a random integer. In 10% of the cases, Integer.MAX_VALUE is returned,
in 10% of the cases Integer.MIN_VALUE. Also in the 10% of the cases, a
random value between those extremes is returned. In 20% of the cases,
this method returns 0. In 10% of the cases, a gaussian value in the range
-200 and +1800 is returned. In all other cases, a gaussian value in the
range -5 and +20 is returned.
Returns:
the random value
|
| long |
getRandomLong()
Get a random long.
|
| long |
getRandomLong()
Get a random long. The algorithm is similar to a random int.
Returns:
the random value
|
| String |
modify(String sql)
Randomly modify a SQL statement.
|
| String |
modify(String sql)
Randomly modify a SQL statement.
Parameters:
sql - the original SQL statement
Returns:
the modified statement
|
| boolean |
nextBoolean()
Get a random boolean.
|
| boolean |
nextBoolean()
Get a random boolean.
Returns:
the random value
|
| double |
nextGaussian()
Get the next gaussian value.
|
| double |
nextGaussian()
Get the next gaussian value.
Returns:
the value
|
| Date |
randomDate()
Get a random date value.
|
| Date |
randomDate()
Get a random date value. In 10% of the cases, null is returned.
Returns:
the value
|
| String |
randomString(int len)
Get a random string with the given length.
|
| String |
randomString(int len)
Get a random string with the given length.
Parameters:
len - the length
Returns:
the string
|
| Time |
randomTime()
Get a random time value.
|
| Time |
randomTime()
Get a random time value. In 10% of the cases, null is returned.
Returns:
the value
|
| Timestamp |
randomTimestamp()
Get a random timestamp value.
|
| Timestamp |
randomTimestamp()
Get a random timestamp value. In 10% of the cases, null is returned.
Returns:
the value
|
| void |
setSeed(int seed)
Set the seed value.
|
| void |
setSeed(int seed)
Set the seed value.
Parameters:
seed - the new seed value
|