Class Exec

  • All Implemented Interfaces:
    adams.core.AdditionalInformationHandler, adams.core.CleanUpHandler, adams.core.Destroyable, adams.core.GlobalInfoSupporter, adams.core.logging.LoggingLevelHandler, adams.core.logging.LoggingSupporter, adams.core.management.EnvironmentVariablesHandler, adams.core.management.WorkingDirectoryHandler, adams.core.option.OptionHandler, adams.core.QuickInfoSupporter, adams.core.ShallowCopySupporter<AbstractRatOutput>, adams.core.SizeOfHandler, adams.core.Stoppable, adams.core.StoppableWithFeedback, adams.event.VariableChangeListener, RatOutput, Serializable

    public class Exec
    extends AbstractRatOutput
    implements adams.core.management.EnvironmentVariablesHandler, adams.core.management.WorkingDirectoryHandler
    Executes the specified command when the rat finishes execution.
    Ignores any input.

    -logging-level <OFF|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST> (property: loggingLevel)
        The logging level for outputting errors and debugging output.
        default: WARNING
     
    -cmd <java.lang.String> (property: command)
        The external command to run.
        default: ls -l .
     
    -working-directory <java.lang.String> (property: workingDirectory)
        The current working directory for the command.
        default:
     
    -env-var <adams.core.base.BaseKeyValuePair> [-env-var ...] (property: envVars)
        The environment variables to overlay on top of the current ones.
        default:
     
    -placeholder <boolean> (property: commandContainsPlaceholder)
        Set this to true to enable automatic placeholder expansion for the command 
        string.
        default: false
     
    -variable <boolean> (property: commandContainsVariable)
        Set this to true to enable automatic variable expansion for the command 
        string.
        default: false
     
    Author:
    FracPete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Field Detail

      • m_Command

        protected String m_Command
        the command to run.
      • m_WorkingDirectory

        protected String m_WorkingDirectory
        the current working directory.
      • m_EnvVars

        protected adams.core.base.BaseKeyValuePair[] m_EnvVars
        environment variables.
      • m_CommandContainsPlaceholder

        protected boolean m_CommandContainsPlaceholder
        whether the command string contains a placeholder, which needs to be expanded first.
      • m_CommandContainsVariable

        protected boolean m_CommandContainsVariable
        whether the command string contains a variable, which needs to be expanded first.
      • m_ProcessOutput

        protected transient com.github.fracpete.processoutput4j.output.CollectingProcessOutput m_ProcessOutput
        for executing the command.
    • Constructor Detail

      • Exec

        public Exec()
    • Method Detail

      • globalInfo

        public String globalInfo()
        Returns a string describing the object.
        Specified by:
        globalInfo in interface adams.core.GlobalInfoSupporter
        Specified by:
        globalInfo in class adams.core.option.AbstractOptionHandler
        Returns:
        a description suitable for displaying in the gui
      • defineOptions

        public void defineOptions()
        Adds options to the internal list of options.
        Specified by:
        defineOptions in interface adams.core.option.OptionHandler
        Overrides:
        defineOptions in class adams.core.option.AbstractOptionHandler
      • getQuickInfo

        public String getQuickInfo()
        Returns a quick info about the actor, which will be displayed in the GUI.
        Specified by:
        getQuickInfo in interface adams.core.QuickInfoSupporter
        Overrides:
        getQuickInfo in class AbstractRatOutput
        Returns:
        null if no info available, otherwise short string
      • setCommand

        public void setCommand​(String value)
        Sets the command to run.
        Parameters:
        value - the command
      • getCommand

        public String getCommand()
        Returns the command to run.
        Returns:
        the command
      • commandTipText

        public String commandTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setWorkingDirectory

        public void setWorkingDirectory​(String value)
        Sets the current working directory for the command.
        Specified by:
        setWorkingDirectory in interface adams.core.management.WorkingDirectoryHandler
        Parameters:
        value - the directory, ignored if empty
      • getWorkingDirectory

        public String getWorkingDirectory()
        Returns the current working directory for the command.
        Specified by:
        getWorkingDirectory in interface adams.core.management.WorkingDirectoryHandler
        Returns:
        the directory, ignored if empty
      • workingDirectoryTipText

        public String workingDirectoryTipText()
        Returns the tip text for this property.
        Specified by:
        workingDirectoryTipText in interface adams.core.management.WorkingDirectoryHandler
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setEnvVars

        public void setEnvVars​(adams.core.base.BaseKeyValuePair[] value)
        Sets the environment variables to overlay on top of the current ones.
        Specified by:
        setEnvVars in interface adams.core.management.EnvironmentVariablesHandler
        Parameters:
        value - the environment variables
      • getEnvVars

        public adams.core.base.BaseKeyValuePair[] getEnvVars()
        Returns the environment variables to overlay on top of the current ones.
        Specified by:
        getEnvVars in interface adams.core.management.EnvironmentVariablesHandler
        Returns:
        the environment variables
      • envVarsTipText

        public String envVarsTipText()
        Returns the tip text for this property.
        Specified by:
        envVarsTipText in interface adams.core.management.EnvironmentVariablesHandler
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setCommandContainsPlaceholder

        public void setCommandContainsPlaceholder​(boolean value)
        Sets whether the command string contains a placeholder which needs to be expanded first.
        Parameters:
        value - true if command string contains a placeholder
      • getCommandContainsPlaceholder

        public boolean getCommandContainsPlaceholder()
        Returns whether the command string contains a placeholder which needs to be expanded first.
        Returns:
        true if command string contains a placeholder
      • commandContainsPlaceholderTipText

        public String commandContainsPlaceholderTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setCommandContainsVariable

        public void setCommandContainsVariable​(boolean value)
        Sets whether the command string contains a variable which needs to be expanded first.
        Parameters:
        value - true if command string contains a variable
      • getCommandContainsVariable

        public boolean getCommandContainsVariable()
        Returns whether the command string contains a variable which needs to be expanded first.
        Returns:
        true if command string contains a variable
      • commandContainsVariableTipText

        public String commandContainsVariableTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • doTransmit

        protected String doTransmit()
        Performs the actual transmission.
        Specified by:
        doTransmit in class AbstractRatOutput
        Returns:
        null if successful, otherwise error message