Package adams.tools
Class AbstractTool
-
- All Implemented Interfaces:
CleanUpHandler,Destroyable,GlobalInfoSupporter,LoggingLevelHandler,LoggingSupporter,OptionHandler,SizeOfHandler,Stoppable,StoppableWithFeedback,Serializable,Comparable
- Direct Known Subclasses:
AbstractDatabaseTool,AbstractScript,AbstractScriptedTool,CompareDatasets,ZipPassword
public abstract class AbstractTool extends AbstractOptionHandler implements Comparable, CleanUpHandler, StoppableWithFeedback
An abstract class for general commandline-handling classes.- Version:
- $Revision$
- Author:
- dale
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanm_Stoppedwhether the tool was stopped.-
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 AbstractTool()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidcleanUp()Cleans up data structures, frees up memory.intcompareTo(Object o)Compares this object with the specified object for order.voiddestroy()Frees up memory in a "destructive" non-reversible way.protected abstract voiddoRun()Contains the actual run code.booleanequals(Object o)Returns whether the two objects are the same.static AbstractToolforCommandLine(String cmdline)Instantiates the tool from the given commandline (i.e., classname and optional options).static AbstractToolforName(String classname, String[] options)Instantiates the tool with the given options.static String[]getTools()Returns a list with classnames of tools.booleanisStopped()Returns whether the tool was stopped.protected voidpostRun()After the actual run was executed.protected voidpreRun()Before the actual run is executed.voidrun()Executes the tool.static voidrunTool(Class env, Class tool, String[] options)Runs the tool from the commandline.voidstopExecution()Stops the execution.-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, defineOptions, finishInit, getDefaultLoggingLevel, getOptionManager, globalInfo, initialize, loggingLevelTipText, newOptionManager, reset, 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, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
-
-
-
Method Detail
-
compareTo
public int compareTo(Object o)
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
Only compares the commandlines of the two objects.- Specified by:
compareToin interfaceComparable- Parameters:
o- the object to be compared.- Returns:
- a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
- Throws:
ClassCastException- if the specified object's type prevents it from being compared to this object.
-
equals
public boolean equals(Object o)
Returns whether the two objects are the same.
Only compares the commandlines of the two objects.
-
preRun
protected void preRun()
Before the actual run is executed. Default implementation only resets the stopped flag.
-
doRun
protected abstract void doRun()
Contains the actual run code.
-
postRun
protected void postRun()
After the actual run was executed. Default implementation does nothing.
-
stopExecution
public void stopExecution()
Stops the execution.- Specified by:
stopExecutionin interfaceStoppable
-
cleanUp
public void cleanUp()
Cleans up data structures, frees up memory. Default implementation does nothing.- Specified by:
cleanUpin interfaceCleanUpHandler
-
destroy
public void destroy()
Frees up memory in a "destructive" non-reversible way.
Calls cleanUp() and cleans up the options.- Specified by:
destroyin interfaceDestroyable- Overrides:
destroyin classAbstractOptionHandler- See Also:
AbstractOptionHandler.cleanUpOptions()
-
run
public void run()
Executes the tool.
-
isStopped
public boolean isStopped()
Returns whether the tool was stopped.- Specified by:
isStoppedin interfaceStoppableWithFeedback- Returns:
- true if the tool was stopped
-
getTools
public static String[] getTools()
Returns a list with classnames of tools.- Returns:
- the tool classnames
-
forName
public static AbstractTool forName(String classname, String[] options)
Instantiates the tool with the given options.- Parameters:
classname- the classname of the tool to instantiateoptions- the options for the tool- Returns:
- the instantiated tool or null if an error occurred
-
forCommandLine
public static AbstractTool forCommandLine(String cmdline)
Instantiates the tool from the given commandline (i.e., classname and optional options).- Parameters:
cmdline- the classname (and optional options) of the tool to instantiate- Returns:
- the instantiated tool or null if an error occurred
-
-