Class AbstractExternalCommand

    • Field Detail

      • m_OutputType

        protected OutputType m_OutputType
        the type of output to forward.
      • m_StdErrProcessor

        protected StdErrProcessor m_StdErrProcessor
        the handler for processing output on stderr.
      • m_StdOutProcessor

        protected StdOutProcessor m_StdOutProcessor
        the handler for processing output on stderr.
      • m_OutputFormatter

        protected OutputFormatter m_OutputFormatter
        the output formatter in use.
      • m_Executed

        protected boolean m_Executed
        the command was executed.
      • m_Running

        protected boolean m_Running
        whether the command is still running.
      • m_Stopped

        protected boolean m_Stopped
        whether the execution was stopped.
      • m_Output

        protected List m_Output
        for buffering output.
      • m_FlowContext

        protected Actor m_FlowContext
        the flow context.
      • m_LastCommand

        protected transient String[] m_LastCommand
        the last command that was executed.
    • Constructor Detail

      • AbstractExternalCommand

        public AbstractExternalCommand()
    • Method Detail

      • getDefaultOutputType

        protected OutputType getDefaultOutputType()
        Returns the default output type.
        Returns:
        the default
      • outputTypeTipText

        public String outputTypeTipText()
        Returns the tip text for this property.
        Specified by:
        outputTypeTipText in interface ExternalCommand
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • getDefaultOutputFormatter

        protected OutputFormatter getDefaultOutputFormatter()
        Returns the default output formatter.
        Returns:
        the default
      • outputFormatterTipText

        public String outputFormatterTipText()
        Returns the tip text for this property.
        Specified by:
        outputFormatterTipText in interface ExternalCommand
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • getDefaultStdOutProcessor

        protected StdOutProcessor getDefaultStdOutProcessor()
        Returns the default handler for processing output on stdout.
        Returns:
        the handler
      • stdOutProcessorTipText

        public String stdOutProcessorTipText()
        Returns the tip text for this property.
        Specified by:
        stdOutProcessorTipText in interface ExternalCommand
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • getDefaultStdErrProcessor

        protected StdErrProcessor getDefaultStdErrProcessor()
        Returns the default handler for processing output on stderr.
        Returns:
        the handler
      • stdErrProcessorTipText

        public String stdErrProcessorTipText()
        Returns the tip text for this property.
        Specified by:
        stdErrProcessorTipText in interface ExternalCommand
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • getQuickInfo

        public String getQuickInfo()
        Returns a quick info about the object, which can be displayed in the GUI.
        Default implementation returns null.
        Specified by:
        getQuickInfo in interface QuickInfoSupporter
        Returns:
        null if no info available, otherwise short string
      • getFlowContext

        public Actor getFlowContext()
        Returns the flow context, if any.
        Specified by:
        getFlowContext in interface FlowContextHandler
        Returns:
        the actor, null if none available
      • check

        protected String check()
        Hook method for performing checks before executing the command.
        Returns:
        null if successful, otherwise error message
      • log

        protected void log​(String[] cmd)
        Logs the command for execution.
        Parameters:
        cmd - the command
      • log

        protected void log​(List<String> cmd)
        Logs the command for execution.
        Parameters:
        cmd - the command
      • log

        protected void log​(CommandResult res)
        For logging the result of a command.
        Parameters:
        res - the result to log
      • commandResultToError

        protected String commandResultToError​(CommandResult res)
        Generates an error message from the command result.
        Parameters:
        res - the result to turn into an error message
        Returns:
        the error message
      • buildCommand

        protected List<String> buildCommand()
        Assembles the command to run.
        Returns:
        the command
      • doAsyncExecute

        protected Object doAsyncExecute()
        Executes the command in asynchronous fashion. Async commands must set the m_Running flag to false themselves.
        Returns:
        the result of the command, either a CommandResult or a String object (= error message)
      • doBlockingExecute

        protected Object doBlockingExecute()
        Executes the command in blocking fashion (ie waits till it finishes). The m_Running flag is set to false automatically.
        Returns:
        the result of the command, either a CommandResult or a String object (= error message)
      • execute

        public String execute()
        Executes the command.
        Specified by:
        execute in interface ExternalCommand
        Returns:
        null if successful, otherwise error message
      • addFormattedOutput

        public void addFormattedOutput​(Object output)
        Gets called by the output formatter class.
        Specified by:
        addFormattedOutput in interface ExternalCommand
        Parameters:
        output - the formatted output to collect
      • hasLastCommand

        public boolean hasLastCommand()
        Checks whether a command has been executed (and recorded).
        Specified by:
        hasLastCommand in interface ExternalCommand
        Returns:
        true if executed/recorded
      • getLastCommand

        public String[] getLastCommand()
        Returns the last command that was executed.
        Specified by:
        getLastCommand in interface ExternalCommand
        Returns:
        the last command, null if not available
      • isExecuted

        public boolean isExecuted()
        Returns whether the command was executed.
        Specified by:
        isExecuted in interface ExternalCommand
        Returns:
        true if executed
      • isRunning

        public boolean isRunning()
        Returns whether the command is currently running.
        Specified by:
        isRunning in interface ExternalCommand
        Returns:
        true if running
      • isFinished

        public boolean isFinished()
        Returns whether the command finished.
        Specified by:
        isFinished in interface ExternalCommand
        Returns:
        true if finished
      • hasOutput

        public boolean hasOutput()
        Whether there is any pending output.
        Specified by:
        hasOutput in interface ExternalCommand
        Returns:
        true if output pending
      • output

        public Object output()
        Returns the next line in the output.
        Specified by:
        output in interface ExternalCommand
        Returns:
        the line, null if none available
      • stopExecution

        public void stopExecution()
        Stops the execution.
        Specified by:
        stopExecution in interface Stoppable
      • isStopped

        public boolean isStopped()
        Whether the execution has been stopped.
        Specified by:
        isStopped in interface StoppableWithFeedback
        Returns:
        true if stopped
      • generates

        public Class generates()
        Returns what output type the command generates via its output formatter.
        Specified by:
        generates in interface ExternalCommand
        Returns:
        the type