Package adams.data.random
Class AbstractRandomNumberGenerator<T extends Number>
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.data.random.AbstractRandomNumberGenerator<T>
-
- Type Parameters:
T
- the type of random number to return
- All Implemented Interfaces:
Destroyable
,GlobalInfoSupporter
,LoggingLevelHandler
,LoggingSupporter
,OptionHandler
,ShallowCopySupporter<RandomNumberGenerator>
,SizeOfHandler
,RandomNumberGenerator<T>
,Serializable
- Direct Known Subclasses:
AbstractSeededRandomNumberGenerator
,JavaRandomByteUnseeded
,JavaRandomDoubleUnseeded
,JavaRandomIntUnseeded
public abstract class AbstractRandomNumberGenerator<T extends Number> extends AbstractOptionHandler implements RandomNumberGenerator<T>
Ancestor for random number generators.- Version:
- $Revision$
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class adams.core.option.AbstractOptionHandler
m_OptionManager
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description AbstractRandomNumberGenerator()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
check()
Performs optional checks.void
defineOptions()
Adds options to the internal list of options.protected abstract T
doNext()
Returns the next random number.static AbstractRandomNumberGenerator
forCommandLine(String cmdline)
Instantiates the statistic from the given commandline (i.e., classname and optional options).static AbstractRandomNumberGenerator
forName(String classname, String[] options)
Instantiates the statistic with the given options.static String[]
getGenerators()
Returns a list with classnames of statistics.T
next()
Returns the nexct random number.void
reset()
Resets the generator.AbstractRandomNumberGenerator
shallowCopy()
Returns a shallow copy of itself, i.e., based on the commandline options.AbstractRandomNumberGenerator
shallowCopy(boolean expand)
Returns a shallow copy of itself, i.e., based on the commandline options.-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, globalInfo, initialize, loggingLevelTipText, newOptionManager, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.core.Destroyable
destroy
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
Methods inherited from interface adams.core.option.OptionHandler
cleanUpOptions, getOptionManager, toCommandLine
-
-
-
-
Method Detail
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptions
in interfaceOptionHandler
- Overrides:
defineOptions
in classAbstractOptionHandler
-
reset
public void reset()
Resets the generator.- Specified by:
reset
in interfaceRandomNumberGenerator<T extends Number>
- Overrides:
reset
in classAbstractOptionHandler
-
check
protected void check()
Performs optional checks.
Default implementation does nothing.
-
doNext
protected abstract T doNext()
Returns the next random number. Does the actual computation.- Returns:
- the next number
-
next
public T next()
Returns the nexct random number.- Specified by:
next
in interfaceRandomNumberGenerator<T extends Number>
- Returns:
- the next number
-
shallowCopy
public AbstractRandomNumberGenerator shallowCopy()
Returns a shallow copy of itself, i.e., based on the commandline options.- Specified by:
shallowCopy
in interfaceShallowCopySupporter<T extends Number>
- Returns:
- the shallow copy
-
shallowCopy
public AbstractRandomNumberGenerator shallowCopy(boolean expand)
Returns a shallow copy of itself, i.e., based on the commandline options.- Specified by:
shallowCopy
in interfaceShallowCopySupporter<T extends Number>
- Parameters:
expand
- whether to expand variables to their current values- Returns:
- the shallow copy
-
getGenerators
public static String[] getGenerators()
Returns a list with classnames of statistics.- Returns:
- the statistic classnames
-
forName
public static AbstractRandomNumberGenerator forName(String classname, String[] options)
Instantiates the statistic with the given options.- Parameters:
classname
- the classname of the statistic to instantiateoptions
- the options for the statistic- Returns:
- the instantiated statistic or null if an error occurred
-
forCommandLine
public static AbstractRandomNumberGenerator forCommandLine(String cmdline)
Instantiates the statistic from the given commandline (i.e., classname and optional options).- Parameters:
cmdline
- the classname (and optional options) of the statistic to instantiate- Returns:
- the instantiated statistic or null if an error occurred
-
-