Class Exec
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.flow.standalone.rats.output.AbstractRatOutput
-
- adams.flow.standalone.rats.output.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 Summary
Fields Modifier and Type Field Description protected String
m_Command
the command to run.protected boolean
m_CommandContainsPlaceholder
whether the command string contains a placeholder, which needs to be expanded first.protected boolean
m_CommandContainsVariable
whether the command string contains a variable, which needs to be expanded first.protected adams.core.base.BaseKeyValuePair[]
m_EnvVars
environment variables.protected com.github.fracpete.processoutput4j.output.CollectingProcessOutput
m_ProcessOutput
for executing the command.protected String
m_WorkingDirectory
the current working directory.-
Fields inherited from class adams.flow.standalone.rats.output.AbstractRatOutput
m_BackupState, m_DetectedObjectVariables, m_DetectedVariables, m_Input, m_LoggingPrefix, m_Owner, m_Stopped, m_VariablesUpdated
-
-
Constructor Summary
Constructors Constructor Description Exec()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Class[]
accepts()
Returns the type of data that gets accepted.String
commandContainsPlaceholderTipText()
Returns the tip text for this property.String
commandContainsVariableTipText()
Returns the tip text for this property.String
commandTipText()
Returns the tip text for this property.void
defineOptions()
Adds options to the internal list of options.protected String
doTransmit()
Performs the actual transmission.String
envVarsTipText()
Returns the tip text for this property.String
getCommand()
Returns the command to run.boolean
getCommandContainsPlaceholder()
Returns whether the command string contains a placeholder which needs to be expanded first.boolean
getCommandContainsVariable()
Returns whether the command string contains a variable which needs to be expanded first.adams.core.base.BaseKeyValuePair[]
getEnvVars()
Returns the environment variables to overlay on top of the current ones.String
getQuickInfo()
Returns a quick info about the actor, which will be displayed in the GUI.String
getWorkingDirectory()
Returns the current working directory for the command.String
globalInfo()
Returns a string describing the object.void
setCommand(String value)
Sets the command to run.void
setCommandContainsPlaceholder(boolean value)
Sets whether the command string contains a placeholder which needs to be expanded first.void
setCommandContainsVariable(boolean value)
Sets whether the command string contains a variable which needs to be expanded first.void
setEnvVars(adams.core.base.BaseKeyValuePair[] value)
Sets the environment variables to overlay on top of the current ones.void
setWorkingDirectory(String value)
Sets the current working directory for the command.void
stopExecution()
Stops the execution.String
workingDirectoryTipText()
Returns the tip text for this property.-
Methods inherited from class adams.flow.standalone.rats.output.AbstractRatOutput
backupState, canInput, check, cleanUp, configureLogger, doWait, findVariables, getAdditionalInformation, getFullName, getOwner, getQueue, getVariables, handleException, initialize, initTransmission, input, isBackedUp, isStopped, pruneBackup, pruneBackup, restoreState, setOwner, setUp, shallowCopy, shallowCopy, transmit, updateDetectedVariables, updatePrefix, updateVariables, variableChanged
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, loggingLevelTipText, newOptionManager, reset, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
-
-
-
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.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfo
in interfaceadams.core.GlobalInfoSupporter
- Specified by:
globalInfo
in classadams.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 interfaceadams.core.option.OptionHandler
- Overrides:
defineOptions
in classadams.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 interfaceadams.core.QuickInfoSupporter
- Overrides:
getQuickInfo
in classAbstractRatOutput
- 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 interfaceadams.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 interfaceadams.core.management.WorkingDirectoryHandler
- Returns:
- the directory, ignored if empty
-
workingDirectoryTipText
public String workingDirectoryTipText()
Returns the tip text for this property.- Specified by:
workingDirectoryTipText
in interfaceadams.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 interfaceadams.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 interfaceadams.core.management.EnvironmentVariablesHandler
- Returns:
- the environment variables
-
envVarsTipText
public String envVarsTipText()
Returns the tip text for this property.- Specified by:
envVarsTipText
in interfaceadams.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.
-
accepts
public Class[] accepts()
Returns the type of data that gets accepted.- Specified by:
accepts
in interfaceRatOutput
- Specified by:
accepts
in classAbstractRatOutput
- Returns:
- the type of data
-
doTransmit
protected String doTransmit()
Performs the actual transmission.- Specified by:
doTransmit
in classAbstractRatOutput
- Returns:
- null if successful, otherwise error message
-
stopExecution
public void stopExecution()
Stops the execution. No message set.- Specified by:
stopExecution
in interfaceRatOutput
- Specified by:
stopExecution
in interfaceadams.core.Stoppable
- Overrides:
stopExecution
in classAbstractRatOutput
-
-