Package adams.flow.standalone.rats.input
Class Exec
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.flow.standalone.rats.input.AbstractRatInput
-
- adams.flow.standalone.rats.input.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<AbstractRatInput>
,adams.core.SizeOfHandler
,adams.core.Stoppable
,adams.core.StoppableWithFeedback
,RatInput
,Serializable
public class Exec extends AbstractRatInput implements adams.core.management.EnvironmentVariablesHandler, adams.core.management.WorkingDirectoryHandler
Executes a command and forwards either output from stdout or stderr.
-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
-stderr <boolean> (property: outputStdErr) If set to true, then stderr is output instead of stdout. 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 String
m_Output
the output.protected boolean
m_OutputStdErr
whether to output stderr instead of stdout.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.input.AbstractRatInput
m_LoggingPrefix, m_Owner, m_ReceptionInterrupted, m_ReceptionRunning, m_Stopped
-
-
Constructor Summary
Constructors Constructor Description Exec()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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
doReceive()
Performs the actual reception of data.String
envVarsTipText()
Returns the tip text for this property.Class
generates()
Returns the type of data this scheme generates.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.boolean
getOutputStdErr()
Returns whether stderr instead of stdout is output.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.boolean
hasPendingOutput()
Checks whether any output can be collected.Object
output()
Returns the received data.String
outputStdErrTipText()
Returns the tip text for this property.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
setOutputStdErr(boolean value)
Sets whether to output stderr instead of stdout.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.input.AbstractRatInput
canReceive, check, cleanUp, configureLogger, doWait, getAdditionalInformation, getFullName, getOwner, getQueue, getReceptionInterrupted, handleException, initialize, initReception, interruptReception, isReceptionRunning, isStopped, receive, setOwner, setUp, shallowCopy, shallowCopy, updatePrefix
-
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_OutputStdErr
protected boolean m_OutputStdErr
whether to output stderr instead of stdout.
-
m_Output
protected String m_Output
the output.
-
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 classAbstractRatInput
- 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.
-
setOutputStdErr
public void setOutputStdErr(boolean value)
Sets whether to output stderr instead of stdout.- Parameters:
value
- if true then stderr is output instead of stdout
-
getOutputStdErr
public boolean getOutputStdErr()
Returns whether stderr instead of stdout is output.- Returns:
- true if stderr is output instead of stdout
-
outputStdErrTipText
public String outputStdErrTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
doReceive
protected String doReceive()
Performs the actual reception of data.- Specified by:
doReceive
in classAbstractRatInput
- Returns:
- null if successful, otherwise error message
-
generates
public Class generates()
Returns the type of data this scheme generates.- Specified by:
generates
in interfaceRatInput
- Specified by:
generates
in classAbstractRatInput
- Returns:
- the type of data
-
hasPendingOutput
public boolean hasPendingOutput()
Checks whether any output can be collected.- Specified by:
hasPendingOutput
in interfaceRatInput
- Specified by:
hasPendingOutput
in classAbstractRatInput
- Returns:
- true if output available
-
output
public Object output()
Returns the received data.- Specified by:
output
in interfaceRatInput
- Specified by:
output
in classAbstractRatInput
- Returns:
- the data
-
stopExecution
public void stopExecution()
Stops the execution. No message set.- Specified by:
stopExecution
in interfaceRatInput
- Specified by:
stopExecution
in interfaceadams.core.Stoppable
- Overrides:
stopExecution
in classAbstractRatInput
-
-