public class RandomNumberFactory
extends java.lang.Object
RandomNumber
. This factory
can either create a RandomNumnber
instance specified by the
user, or create the default RandomNumber
Class. The default
Class is initially set to Congruential
.Modifier and Type | Field and Description |
---|---|
protected static java.util.Map<java.lang.String,java.lang.Class<? extends RandomNumber>> |
cache
A cache of RandomNumber Classes that have already been found.
|
(package private) static java.lang.Class<? extends RandomNumber> |
DEFAULT_CLASS
The default Class that will be generated if one is not specified by the
user.
|
(package private) static java.lang.String |
DEFAULT_CLASS_NAME
Holds a String with the initial setting of the default Class.
|
protected static java.util.List<java.lang.String> |
searchPackages
A list of packages to search when the Class name is not fully qualified.
|
protected static boolean |
verbose
If true, print debug/trace information (not yet implemented)
|
Modifier | Constructor and Description |
---|---|
protected |
RandomNumberFactory()
This factory should not be instantiated.
|
Modifier and Type | Method and Description |
---|---|
static void |
addSearchPackage(java.lang.String packageName)
Adds the given package to the search path for RandomNumber Classes.
|
static RandomNumber |
getAntithetic(RandomNumber rng)
Creates an instance of a
RandomNumber the will generate
numbers that are antithetic to the given instance. |
static java.util.Map<java.lang.String,java.lang.Class<? extends RandomNumber>> |
getCache()
A cache of RandomNumber Classes that have already been found.
|
static java.lang.Class<? extends RandomNumber> |
getClassFor(java.lang.String className)
Helper method - given an unqualified class name, searches through search
path for actual class, returning the first one it finds.
|
static RandomNumber |
getInstance()
Creates an instance of the default Class with its default seed(s).
|
static RandomNumber |
getInstance(long seed)
Creates an instance of the default Class with the given seed.
|
static RandomNumber |
getInstance(long[] seed)
Creates an instance of the default Class with the given seeds.
|
static RandomNumber |
getInstance(RandomNumber rng)
Creates an instance that has the same Class as the given
RandomNumber and initial seed(s) equal to the current seed
of the given RandomNumber . |
static RandomNumber |
getInstance(java.lang.String className)
Creates an instance of the given Class with its default seed(s).
|
static RandomNumber |
getInstance(java.lang.String className,
long seed)
Creates an instance of the given Class with the given seed.
|
static RandomNumber |
getInstance(java.lang.String className,
long[] seed)
Creates an instance of the given Class with the given seeds.
|
static Pooled |
getInstance(java.lang.String className,
RandomNumber[] rng)
Creates an instance of a
Pooled RandomNumber of the given
Class using the 2 given instances of RandomNumber . |
static Pooled |
getInstance(java.lang.String className,
RandomNumber first,
RandomNumber second)
Creates an instance of a
Pooled RandomNumber of the given
Class using the 2 given instances of RandomNumber . |
static RandomNumberStream |
getRngStream(java.lang.String className,
int stream,
int substream)
Deprecated.
use getInstance(String Map) instead
|
static java.lang.String[] |
getSearchPackages()
Returns an array containing the names of the packages in the current
search path.
|
static boolean |
isVerbose()
If true, print debug/trace information (not yet implemented)
|
static void |
removeSearchPackage(java.lang.String packageName)
Removes the given package from the search path.
|
static void |
setDefaultClass(java.lang.String className)
The default class is instantiated when the user does not specify a class.
|
static void |
setVerbose(boolean v)
If true, print debug/trace information (not yet implemented)
|
static final java.lang.String DEFAULT_CLASS_NAME
static java.lang.Class<? extends RandomNumber> DEFAULT_CLASS
protected static java.util.Map<java.lang.String,java.lang.Class<? extends RandomNumber>> cache
protected static final java.util.List<java.lang.String> searchPackages
protected static boolean verbose
protected RandomNumberFactory()
public static void setVerbose(boolean v)
v
- Sets verbose mode (not implemented yet)public static boolean isVerbose()
public static java.util.Map<java.lang.String,java.lang.Class<? extends RandomNumber>> getCache()
public static void setDefaultClass(java.lang.String className)
className
- Unqualified name of default classpublic static RandomNumber getInstance()
public static RandomNumber getInstance(long seed)
RandomNumber
s that take a single seed.seed
- Desired seed for instancepublic static RandomNumber getInstance(long[] seed)
seed
- Desired seeds for default instancepublic static RandomNumber getInstance(java.lang.String className)
className
- (Unqualified) name of desired RandomNumber
classpublic static RandomNumber getInstance(java.lang.String className, long seed)
RandomNumber
s that take a single seed.seed
- Desired seedclassName
- (Unqualified) name of desired RandomNumber
classpublic static RandomNumber getInstance(java.lang.String className, long[] seed)
seed
- Desired seedsclassName
- (Unqualified) name of desired RandomNumber
classpublic static RandomNumber getInstance(RandomNumber rng)
RandomNumber
and initial seed(s) equal to the current seed
of the given RandomNumber
. While immediately upon creation
the new RandomNumber
is the same as the given instance, the
two are not linked. The two instances will independently generate the
same sequence of numbers.rng
- Instance to be copiedpublic static Pooled getInstance(java.lang.String className, RandomNumber first, RandomNumber second)
Pooled RandomNumber
of the given
Class using the 2 given instances of RandomNumber
.className
- Desired class implementing Pooled
first
- First instance to be pooledsecond
- second instance to be pooledPooled
instance pooling first and secondjava.lang.IllegalArgumentException
- If the given Class does not implement
the Pooled
interface.public static Pooled getInstance(java.lang.String className, RandomNumber[] rng)
Pooled RandomNumber
of the given
Class using the 2 given instances of RandomNumber
.className
- Desired (unqualified) classrng
- Array (of length 2) to be pooledPooled
instancejava.lang.IllegalArgumentException
- If the given RandomNumber array does not
contain 2 instances of RandomNumber
or if the given Class
does not implement Pooled
.public static RandomNumber getAntithetic(RandomNumber rng)
RandomNumber
the will generate
numbers that are antithetic to the given instance. Note that the
antithetic instance uses the given instance to generate and does not make
a copy of it; therefore, if two negatively correlated streams are
desired, the argument should be a copy.rng
- RandomNumber
instance to be antitheticizedRandomNumber
instance that is antithetic to one
passed in.Antithetic
public static void addSearchPackage(java.lang.String packageName)
packageName
- Name of package to be searched when qualifying class
names (Note: not checked whether package actually exists).public static void removeSearchPackage(java.lang.String packageName)
packageName
- Name of package to be removed from search pathpublic static java.lang.String[] getSearchPackages()
public static java.lang.Class<? extends RandomNumber> getClassFor(java.lang.String className)
className
- (Unqualified) name for desired classpublic static RandomNumberStream getRngStream(java.lang.String className, int stream, int substream)
className
- name of RandomVariate classstream
- given desired streamsubstream
- given desired substream