|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.castor.xmlctf.RandomHelper
public class RandomHelper
Assists in the generation of random instances of a given object model.
Constructor Summary | |
---|---|
RandomHelper()
|
Method Summary | |
---|---|
static boolean |
flip()
Returns true or false randomly with equal probability. |
static boolean |
flip(double p)
Returns true randomly with the probability p. |
static java.util.ArrayList |
getRandom(java.util.ArrayList al,
java.lang.Class c)
Returns a populated ArrayList of random length. |
static java.math.BigDecimal |
getRandom(java.math.BigDecimal bg,
java.lang.Class c)
Returns a random BigDecimal. |
static boolean |
getRandom(boolean b)
Returns a random boolean. |
static byte |
getRandom(byte b)
Returns a random byte. |
static byte[] |
getRandom(byte[] array,
java.lang.Class c)
Returns a populated array of byte of random length. |
static char |
getRandom(char c)
Returns a random printable char. |
static java.util.Collection |
getRandom(java.util.Collection al,
java.lang.Class c)
Returns a populated Collection of random length. |
static java.util.Date |
getRandom(java.util.Date date,
java.lang.Class c)
Returns a random java.util.Date. |
static double |
getRandom(double d)
Returns a random double. |
static float |
getRandom(float f)
Returns a random float. |
static int |
getRandom(int i)
Returns a random int. |
static int[] |
getRandom(int[] array,
java.lang.Class c)
Returns a populated array of int of random length. |
static java.util.List |
getRandom(java.util.List al,
java.lang.Class c)
Returns a populated List of random length. |
static long |
getRandom(long l)
Returns a random long. |
static java.lang.Object[] |
getRandom(java.lang.Object[] array,
java.lang.Class c)
Creates a populated array of type c of random length. |
static java.lang.Object |
getRandom(java.lang.Object object,
java.lang.Class c)
Returns a random Object of the type provided by class c. |
static RecurringDuration |
getRandom(RecurringDuration recurring,
java.lang.Class c)
Returns a random Castor RecurringDuration. |
static java.util.Set |
getRandom(java.util.Set al,
java.lang.Class c)
Returns a populated Set of random length. |
static java.util.SortedSet |
getRandom(java.util.SortedSet al,
java.lang.Class c)
Returns a populated SortedSet of random length. |
static java.lang.String[] |
getRandom(java.lang.String[] array,
java.lang.Class c)
Returns a populated array of String of random length. |
static java.lang.String |
getRandom(java.lang.String s,
java.lang.Class c)
Returns a random String that will not have leading or trailing whitespace and that will not have consecutive internal whitespace. |
static java.lang.String |
getRandom(java.lang.String s,
java.lang.Class c,
boolean collapseWhitespace)
Returns a random String, optionally with leading and trailing whitespace removed and internal consecutive whitespace collapsed. |
static TimeDuration |
getRandom(TimeDuration date,
java.lang.Class c)
Returns a random Castor TimeDuration. |
static java.util.Vector |
getRandom(java.util.Vector vect,
java.lang.Class c)
Returns a populated vector of random length. |
static long |
getSeed()
Returns the seed which was used to initialize the pseudo-random number generator. |
static char |
rndPrintableChar()
Returns a random printable character from the PRINTABLE_CHAR
string. |
static void |
setSeed(long seed)
Re-initializes the random number generator with the given seed. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public RandomHelper()
Method Detail |
---|
public static int[] getRandom(int[] array, java.lang.Class c)
array
- An unused parameter, used only for polymorphism.c
- An unused parameter that indicates we are making a random
Object, not a random primitive
public static byte[] getRandom(byte[] array, java.lang.Class c)
array
- An unused parameter, used only for polymorphism.c
- An unused parameter that indicates we are making a random
Object, not a random primitive
public static java.lang.String[] getRandom(java.lang.String[] array, java.lang.Class c)
array
- An unused parameter, used only for polymorphism.c
- An unused parameter that indicates we are making a random
Object, not a random primitive
public static java.lang.Object[] getRandom(java.lang.Object[] array, java.lang.Class c) throws java.lang.InstantiationException, java.lang.IllegalAccessException
array
- An unused parameter, used only for polymorphism.c
- the type of object to put in the array
java.lang.InstantiationException
- if the class cannot be instantiated.
java.lang.IllegalAccessException
- if the class cannot be accessed.public static java.util.Vector getRandom(java.util.Vector vect, java.lang.Class c) throws java.lang.InstantiationException, java.lang.IllegalAccessException
vect
- the vector to populate, if null a new Vector will be created.c
- the type of object to put in the vector.
java.lang.InstantiationException
- if the class cannot be instantiated.
java.lang.IllegalAccessException
- if the class cannot be accessed.public static java.util.ArrayList getRandom(java.util.ArrayList al, java.lang.Class c) throws java.lang.InstantiationException, java.lang.IllegalAccessException
al
- the ArrayList to populatec
- the type of object to put in the vector
java.lang.InstantiationException
- if the class cannot be instantiated
java.lang.IllegalAccessException
- if the class cannot be accessedpublic static java.util.Collection getRandom(java.util.Collection al, java.lang.Class c) throws java.lang.InstantiationException, java.lang.IllegalAccessException
al
- the ArrayList to populatec
- the type of object to put in the vector
java.lang.InstantiationException
- if the class cannot be instantiated
java.lang.IllegalAccessException
- if the class cannot be accessedpublic static java.util.List getRandom(java.util.List al, java.lang.Class c) throws java.lang.InstantiationException, java.lang.IllegalAccessException
al
- the ArrayList to populatec
- the type of object to put in the vector
java.lang.InstantiationException
- if the class cannot be instantiated
java.lang.IllegalAccessException
- if the class cannot be accessedpublic static java.util.Set getRandom(java.util.Set al, java.lang.Class c) throws java.lang.InstantiationException, java.lang.IllegalAccessException
al
- the Set to populatec
- the type of object to put in the vector
java.lang.InstantiationException
- if the class cannot be instantiated
java.lang.IllegalAccessException
- if the class cannot be accessedpublic static java.util.SortedSet getRandom(java.util.SortedSet al, java.lang.Class c) throws java.lang.InstantiationException, java.lang.IllegalAccessException
al
- the SortedSet to populatec
- the type of object to put in the vector
java.lang.InstantiationException
- if the class cannot be instantiated
java.lang.IllegalAccessException
- if the class cannot be accessedpublic static java.lang.String getRandom(java.lang.String s, java.lang.Class c)
getRandom(String, Class, boolean)
with the boolean argument
false
.
s
- An unused parameter, used only for polymorphism.c
- An unused parameter that indicates we are making a random
Object, not a random primitive
public static java.lang.String getRandom(java.lang.String s, java.lang.Class c, boolean collapseWhitespace)
s
- An unused parameter, used only for polymorphism.c
- An unused parameter that indicates we are making a random
Object, not a random primitivecollapseWhitespace
- if true, removes leading and trailing
whitespace and collapses multiple consecutive spaces.
public static java.util.Date getRandom(java.util.Date date, java.lang.Class c)
date
- An unused parameter, used only for polymorphism.c
- An unused parameter that indicates we are making a random
Object, not a random primitive
public static TimeDuration getRandom(TimeDuration date, java.lang.Class c)
date
- An unused parameter, used only for polymorphism.c
- An unused parameter that indicates we are making a random
Object, not a random primitive
public static RecurringDuration getRandom(RecurringDuration recurring, java.lang.Class c)
recurring
- An unused parameter, used only for polymorphism.c
- An unused parameter that indicates we are making a random
Object, not a random primitive
public static java.lang.Object getRandom(java.lang.Object object, java.lang.Class c)
object
- An unused parameter, used only for polymorphism.c
- the type of object we will create a randomized instance of. This
class must implement CastorTestable.
public static java.math.BigDecimal getRandom(java.math.BigDecimal bg, java.lang.Class c)
bg
- An unused parameter, used only for polymorphism.c
- An unused parameter that indicates we are making a random
Object, not a random primitive
public static int getRandom(int i)
i
- An unused parameter, used only for polymorphism.
public static float getRandom(float f)
f
- An unused parameter, used only for polymorphism.
public static boolean getRandom(boolean b)
b
- An unused parameter, used only for polymorphism.
public static long getRandom(long l)
l
- An unused parameter, used only for polymorphism.
public static double getRandom(double d)
d
- An unused parameter, used only for polymorphism.
public static char getRandom(char c)
c
- An unused parameter, used only for polymorphism.
public static byte getRandom(byte b)
b
- An unused parameter, used only for polymorphism.
public static boolean flip()
public static boolean flip(double p)
p
- A probability for returning true
public static char rndPrintableChar()
PRINTABLE_CHAR
string.
public static long getSeed()
public static void setSeed(long seed)
seed
- the new seed for the random number generator.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |