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 OptionManager
m_OptionManager
for 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 void
cleanUpOptions()
Cleans up the options.void
defineOptions()
Adds options to the internal list of options.void
destroy()
Frees up memory in a "destructive" non-reversible way.protected abstract void
doRun()
Performs the actual run.static RunScheme
forCommandLine(String cmdline)
Instantiates the run scheme from the given commandline (i.e., classname and optional options).static RunScheme
forName(String classname, String[] options)
Instantiates the run scheme with the given options.OptionManager
getOptionManager()
Returns the option manager.protected void
initialize()
initializes member variables.protected OptionManager
newOptionManager()
Returns a new instance of the option manager.protected void
postRun()
Performs some output/cleanup after the actual run.protected void
preRun()
Performs some initializations before the actual run.void
run()
Runs the scheme and prints some information to stdout.static void
runScheme(Class env, Class scheme, String[] args)
Runs the tool from commandline.String
toCommandLine()
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:
defineOptions
in interfaceOptionHandler
-
getOptionManager
public OptionManager getOptionManager()
Returns the option manager.- Specified by:
getOptionManager
in interfaceOptionHandler
- Returns:
- the manager
-
cleanUpOptions
public void cleanUpOptions()
Cleans up the options.- Specified by:
cleanUpOptions
in interfaceOptionHandler
-
destroy
public void destroy()
Frees up memory in a "destructive" non-reversible way.
Cleans up the options.- Specified by:
destroy
in interfaceDestroyable
- See Also:
cleanUpOptions()
-
preRun
protected void preRun() throws Exception
Performs some initializations before the actual run. Default implementation does nothing.- Throws:
Exception
- if something goes wrong
-
doRun
protected abstract void doRun() throws Exception
Performs the actual run.- Throws:
Exception
- if something goes wrong
-
postRun
protected void postRun() throws Exception
Performs some output/cleanup after the actual run. Default implementation does nothing.- Throws:
Exception
- if something goes wrong
-
run
public void run() throws Exception
Runs the scheme and prints some information to stdout.- Throws:
Exception
- if something goes wrong
-
toCommandLine
public String toCommandLine()
Returns the commandline string.- Specified by:
toCommandLine
in 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
-
-