jartege
Class RandomValue

java.lang.Object
  extended byjartege.RandomValue

public class RandomValue
extends java.lang.Object

This class allows one to choose random values of primitive types.


Method Summary
static boolean booleanValue()
          Random value of type boolean.
static byte byteValue()
          Random value of type byte.
static byte byteValue(byte max)
          Random value of type byte in range [0, max].
static byte byteValue(byte[] array)
          Random value of type byte chosen in the specified array of bytes.
static byte byteValue(byte min, byte max)
          Random value of type byte in range [min, max].
static char charValue()
          Random value of type char.
static char charValue(char max)
          Random value of type char in range [0, max].
static char charValue(char[] array)
          Random value of type char chosen in the specified array.
static char charValue(char min, char max)
          Random value of type char in range [min, max].
static double doubleValue(double max)
          Random double value in range [0, max].
static double doubleValue(double min, double max)
          Random double value in range [min, max].
static float floatValue(float max)
          Random float value in range [0, max].
static float floatValue(float min, float max)
          Random float value in range [min, max].
static int intValue()
          Random value of type int.
static int intValue(int max)
          Random value of type int in range [0, max].
static int intValue(int[] array)
          Random value chosen in an array of int.
static int intValue(int min, int max)
          Random value of type int in range [min, max].
static long longValue()
          Random value of type long.
static long longValue(long max)
          Random value of type long.
static long longValue(long[] array)
          Random value chosen in an array of long.
static long longValue(long min, long max)
          Random value of type long.
static double nonUniformDoubleValue()
          Random value of type double.
static double nonUniformDoubleValue(double max)
          Random value of type double in range [0, max].
static double nonUniformDoubleValue(double min, double max)
          Random value of type double in range [min, max].
static float nonUniformFloatValue()
          Random value of type float.
static float nonUniformFloatValue(float max)
          Random value of type float in range [0, max].
static float nonUniformFloatValue(float min, float max)
          Random value of type float in range [min, max].
static java.lang.Object oneObject(java.util.Collection coll)
          Random object chosen in the specified collection.
static char printableCharValue()
          Random value of printable character (in range [32, 127]).
static char printableCharValue(char max)
          Random value of printable character in range [32, max].
static char printableCharValue(char min, char max)
          Random value of printable character in range [min, max].
static java.lang.String printableStringValue()
          Random String of printable characters.
static java.lang.String printableStringValue(short min, short max)
          Random String of printable characters of length in range [min, max].
static short shortValue()
          Random value of type short.
static short shortValue(short max)
          Random value of type short in range [0, max].
static short shortValue(short[] array)
          Random value chosen in an array of short.
static short shortValue(short min, short max)
          Random value of type short in range [min, max].
static java.lang.String stringValue()
          Random String.
static java.lang.String stringValue(short min, short max)
          Random String of printable characters of length in range [min, max].
static java.lang.String stringValue(java.lang.String[] array)
          Random string chosen in an array of String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

booleanValue

public static boolean booleanValue()
Random value of type boolean.


byteValue

public static byte byteValue()
Random value of type byte.


byteValue

public static byte byteValue(byte max)
Random value of type byte in range [0, max].

 
 requires
    0 <= max ; 

 ensures
    0 <= \result && \result <= max ; 

 


byteValue

public static byte byteValue(byte min,
                             byte max)
Random value of type byte in range [min, max].

 
 requires
    min <= max ; 

 ensures
    min <= \result && \result <= max ;

 


byteValue

public static byte byteValue(byte[] array)
Random value of type byte chosen in the specified array of bytes.

 
 requires
    array != null && array.length != 0 ; 

 ensures
    (\exists int i ; 0 <= i && i < array.length ; \result == array[i]) ; 

 


charValue

public static char charValue()
Random value of type char.


charValue

public static char charValue(char max)
Random value of type char in range [0, max].

 
 requires
    0 <= max ; 

 ensures
    0 <= \result && \result <= max ; 

 


charValue

public static char charValue(char min,
                             char max)
Random value of type char in range [min, max].

 
 requires
    min <= max ; 

 ensures
    min <= \result && \result <= max ;

 


charValue

public static char charValue(char[] array)
Random value of type char chosen in the specified array.

 
 requires
    array != null && array.length != 0 ; 

 ensures
    (\exists int i ; 0 <= i && i < array.length ; \result == array[i]) ; 

 


printableCharValue

public static char printableCharValue()
Random value of printable character (in range [32, 127]).


 ensures
    32 <= \result && \result <= 127 ;

 


printableCharValue

public static char printableCharValue(char max)
Random value of printable character in range [32, max].


 requires
    32 <= max && max <= 127 ; 

 ensures
    32 <= \result && \result <= max ; 

 


printableCharValue

public static char printableCharValue(char min,
                                      char max)
Random value of printable character in range [min, max].


 requires
    32 <= min && min <= max && max <= 127 ;

 ensures
    min <= \result && \result <= max ;

 


nonUniformDoubleValue

public static double nonUniformDoubleValue(double min,
                                           double max)
Random value of type double in range [min, max]. A sign, mantissa and exponent are randomly chosen and put together to form a double number. Note that the result is not uniformely distributed in [min, max].


 requires 
    min <= max ; 

 ensures 
    min <= \result && \result <= max ; 

 


nonUniformDoubleValue

public static double nonUniformDoubleValue(double max)
Random value of type double in range [0, max]. A mantissa and an exponent are randomly chosen and put together to form a double number less or equal to max. Note that the result is not uniformely distributed in range [0, max].


 requires 
    max >= 0 ; 

 ensures 
    0 <= \result && \result <= max ; 

 


nonUniformDoubleValue

public static double nonUniformDoubleValue()
Random value of type double. Does not generate infinity nor NaN. A sign, an exponent and a mantissa are randomly (and uniformely) chosen and put together to form a double number. Note that the result is not uniformely distributed in double.


doubleValue

public static double doubleValue(double min,
                                 double max)
Random double value in range [min, max].


 requires
    min <= max ; 

 ensures 
    min <= \result && \result <= max ; 

 


doubleValue

public static double doubleValue(double max)
Random double value in range [0, max].


 requires 
    max >= 0 ; 

 ensures
    0 <= \result && \result <= max ; 

 


intValue

public static int intValue()
Random value of type int.


intValue

public static int intValue(int[] array)
Random value chosen in an array of int.

 
 requires
    array != null && array.length != 0 ; 

 ensures
    (\exists int i ; 0 <= i && i < array.length ; \result == array[i]) ; 

 


intValue

public static int intValue(int min,
                           int max)
Random value of type int in range [min, max].


 requires
    min <= max ; 

 ensures
    min <= \result && \result <= max ;  

 


intValue

public static int intValue(int max)
Random value of type int in range [0, max].


 requires
    0 <= max ;

 ensures
    0 <= \result && \result <= max ;

 


longValue

public static long longValue()
Random value of type long.


longValue

public static long longValue(long max)
Random value of type long.


 requires
    0 <= max ;

 ensures
    0 <= \result && \result <= max ;

 


longValue

public static long longValue(long min,
                             long max)
Random value of type long.


 requires
    min <= max ;

 ensures
    min <= \result && \result <= max ;

 


longValue

public static long longValue(long[] array)
Random value chosen in an array of long.

 
 requires
    array != null && array.length != 0 ; 

 ensures
    (\exists int i ; 0 <= i && i < array.length ; \result == array[i]) ; 

 


shortValue

public static short shortValue()
Random value of type short.


shortValue

public static short shortValue(short min,
                               short max)
Random value of type short in range [min, max].


 requires 
    min <= max ; 

 ensures 
    min <= \result && \result <= max ; 

 


shortValue

public static short shortValue(short max)
Random value of type short in range [0, max].


 requires
    0 <= max ;

 ensures
    0 <= \result && \result <= max ;

 


shortValue

public static short shortValue(short[] array)
Random value chosen in an array of short.

 
 requires
    array != null && array.length != 0 ; 

 ensures
    (\exists int i ; 0 <= i && i < array.length ; \result == array[i]) ; 

 


nonUniformFloatValue

public static float nonUniformFloatValue(float min,
                                         float max)
Random value of type float in range [min, max]. A sign, mantissa and exponent are randomly chosen and put together to form a float number. Note that the result is not uniformely distributed in [min, max].


 requires 
    min <= max ; 

 ensures 
    min <= \result && \result <= max ; 

 


nonUniformFloatValue

public static float nonUniformFloatValue(float max)
Random value of type float in range [0, max]. A mantissa and an exponent are randomly chosen and put together to form a float number less or equal to max. Note that the result is not uniformely distributed in [0, max[.


 requires 
    max >= 0 ; 

 ensures 
    0 <= \result && \result <= max ; 

 


nonUniformFloatValue

public static float nonUniformFloatValue()
Random value of type float. Does not generate infinity nor NaN. A sign, an exponent and a mantissa are randomly (and uniformely) chosen and put together to form a float number. Note that the result is not uniformely distributed in float.


floatValue

public static float floatValue(float min,
                               float max)
Random float value in range [min, max].


 requires
    min <= max ; 

 ensures 
    min <= \result && \result <= max ; 

 


floatValue

public static float floatValue(float max)
Random float value in range [0, max].


 requires 
    max >= 0 ; 

 ensures
    0 <= \result && \result <= max ; 

 


stringValue

public static java.lang.String stringValue(java.lang.String[] array)
Random string chosen in an array of String.


 requires
    array != null && array.length != 0 ; 

 ensures
    (\exists int i ; 0 <= i && i < array.length ; 
                     \result == array[i]) ; 

 


stringValue

public static java.lang.String stringValue()
Random String.


stringValue

public static java.lang.String stringValue(short min,
                                           short max)
Random String of printable characters of length in range [min, max].


 requires 
    0 <= min && min <= max ; 

 ensures
    min <= \result.length() && \result.length() <= max ; 

 


printableStringValue

public static java.lang.String printableStringValue()
Random String of printable characters.


printableStringValue

public static java.lang.String printableStringValue(short min,
                                                    short max)
Random String of printable characters of length in range [min, max].


 requires 
    0 <= min && min <= max ; 

 ensures
    min <= \result.length() && \result.length() <= max ; 

 ensures
    (\forall int i ; 0 <= i && i < \result.length() ; 
       32 <= \result.charAt(i) && \result.charAt(i) <= 127) ; 

 


oneObject

public static java.lang.Object oneObject(java.util.Collection coll)
Random object chosen in the specified collection.


 requires
    coll != null && coll.size() != 0 ; 

 ensures
    coll.contains(\result) ;