Package adams.tools

Class AbstractTool

    • Field Detail

      • m_Stopped

        protected boolean m_Stopped
        whether the tool was stopped.
    • Constructor Detail

      • AbstractTool

        public AbstractTool()
    • 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:
        compareTo in interface Comparable
        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.
        Overrides:
        equals in class Object
        Parameters:
        o - the object to be compared
        Returns:
        true if the object is the same as this one
      • 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:
        stopExecution in interface Stoppable
      • cleanUp

        public void cleanUp()
        Cleans up data structures, frees up memory. Default implementation does nothing.
        Specified by:
        cleanUp in interface CleanUpHandler
      • run

        public void run()
        Executes the tool.
      • isStopped

        public boolean isStopped()
        Returns whether the tool was stopped.
        Specified by:
        isStopped in interface StoppableWithFeedback
        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 instantiate
        options - 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
      • runTool

        public static void runTool​(Class env,
                                   Class tool,
                                   String[] options)
        Runs the tool from the commandline.
        Parameters:
        env - the environment class to use
        tool - the tool class
        options - the commandline options