Package adams.run
Class RunScheme
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.run.RunScheme
-
- All Implemented Interfaces:
Destroyable,LoggingSupporter,OptionHandler,SizeOfHandler,Serializable
- Direct Known Subclasses:
RunDatabaseScheme
public abstract class RunScheme extends LoggingObject implements OptionHandler
Abstract class for running non-commandline schemes from commandline.- Version:
- $Revision$
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected OptionManagerm_OptionManagerfor managing the available options.-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description RunScheme()default constructor.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidcleanUpOptions()Cleans up the options.voiddefineOptions()Adds options to the internal list of options.voiddestroy()Frees up memory in a "destructive" non-reversible way.protected abstract voiddoRun()Performs the actual run.static RunSchemeforCommandLine(String cmdline)Instantiates the run scheme from the given commandline (i.e., classname and optional options).static RunSchemeforName(String classname, String[] options)Instantiates the run scheme with the given options.OptionManagergetOptionManager()Returns the option manager.protected voidinitialize()initializes member variables.protected OptionManagernewOptionManager()Returns a new instance of the option manager.protected voidpostRun()Performs some output/cleanup after the actual run.protected voidpreRun()Performs some initializations before the actual run.voidrun()Runs the scheme and prints some information to stdout.static voidrunScheme(Class env, Class scheme, String[] args)Runs the tool from commandline.StringtoCommandLine()Returns the commandline string.-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
-
-
-
Field Detail
-
m_OptionManager
protected OptionManager m_OptionManager
for managing the available options.
-
-
Method Detail
-
initialize
protected void initialize()
initializes member variables.
-
newOptionManager
protected OptionManager newOptionManager()
Returns a new instance of the option manager.- Returns:
- the manager to use
-
defineOptions
public void defineOptions()
Adds options to the internal list of options. Derived classes must override this method to add additional options.- Specified by:
defineOptionsin interfaceOptionHandler
-
getOptionManager
public OptionManager getOptionManager()
Returns the option manager.- Specified by:
getOptionManagerin interfaceOptionHandler- Returns:
- the manager
-
cleanUpOptions
public void cleanUpOptions()
Cleans up the options.- Specified by:
cleanUpOptionsin interfaceOptionHandler
-
destroy
public void destroy()
Frees up memory in a "destructive" non-reversible way.
Cleans up the options.- Specified by:
destroyin interfaceDestroyable- See Also:
cleanUpOptions()
-
preRun
protected void preRun() throws ExceptionPerforms some initializations before the actual run. Default implementation does nothing.- Throws:
Exception- if something goes wrong
-
doRun
protected abstract void doRun() throws ExceptionPerforms the actual run.- Throws:
Exception- if something goes wrong
-
postRun
protected void postRun() throws ExceptionPerforms some output/cleanup after the actual run. Default implementation does nothing.- Throws:
Exception- if something goes wrong
-
run
public void run() throws ExceptionRuns the scheme and prints some information to stdout.- Throws:
Exception- if something goes wrong
-
toCommandLine
public String toCommandLine()
Returns the commandline string.- Specified by:
toCommandLinein interfaceOptionHandler- Returns:
- the commandline
-
forName
public static RunScheme forName(String classname, String[] options)
Instantiates the run scheme with the given options.- Parameters:
classname- the classname of the run scheme to instantiateoptions- the options for the run scheme- Returns:
- the instantiated run scheme or null if an error occurred
-
forCommandLine
public static RunScheme forCommandLine(String cmdline)
Instantiates the run scheme from the given commandline (i.e., classname and optional options).- Parameters:
cmdline- the classname (and optional options) of the run scheme to instantiate- Returns:
- the instantiated run scheme or null if an error occurred
-
-