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 Stringm_Commandthe command to run.protected booleanm_CommandContainsPlaceholderwhether the command string contains a placeholder, which needs to be expanded first.protected booleanm_CommandContainsVariablewhether the command string contains a variable, which needs to be expanded first.protected adams.core.base.BaseKeyValuePair[]m_EnvVarsenvironment variables.protected Stringm_Outputthe output.protected booleanm_OutputStdErrwhether to output stderr instead of stdout.protected com.github.fracpete.processoutput4j.output.CollectingProcessOutputm_ProcessOutputfor executing the command.protected Stringm_WorkingDirectorythe 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 StringcommandContainsPlaceholderTipText()Returns the tip text for this property.StringcommandContainsVariableTipText()Returns the tip text for this property.StringcommandTipText()Returns the tip text for this property.voiddefineOptions()Adds options to the internal list of options.protected StringdoReceive()Performs the actual reception of data.StringenvVarsTipText()Returns the tip text for this property.Classgenerates()Returns the type of data this scheme generates.StringgetCommand()Returns the command to run.booleangetCommandContainsPlaceholder()Returns whether the command string contains a placeholder which needs to be expanded first.booleangetCommandContainsVariable()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.booleangetOutputStdErr()Returns whether stderr instead of stdout is output.StringgetQuickInfo()Returns a quick info about the actor, which will be displayed in the GUI.StringgetWorkingDirectory()Returns the current working directory for the command.StringglobalInfo()Returns a string describing the object.booleanhasPendingOutput()Checks whether any output can be collected.Objectoutput()Returns the received data.StringoutputStdErrTipText()Returns the tip text for this property.voidsetCommand(String value)Sets the command to run.voidsetCommandContainsPlaceholder(boolean value)Sets whether the command string contains a placeholder which needs to be expanded first.voidsetCommandContainsVariable(boolean value)Sets whether the command string contains a variable which needs to be expanded first.voidsetEnvVars(adams.core.base.BaseKeyValuePair[] value)Sets the environment variables to overlay on top of the current ones.voidsetOutputStdErr(boolean value)Sets whether to output stderr instead of stdout.voidsetWorkingDirectory(String value)Sets the current working directory for the command.voidstopExecution()Stops the execution.StringworkingDirectoryTipText()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:
globalInfoin interfaceadams.core.GlobalInfoSupporter- Specified by:
globalInfoin 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:
defineOptionsin interfaceadams.core.option.OptionHandler- Overrides:
defineOptionsin classadams.core.option.AbstractOptionHandler
-
getQuickInfo
public String getQuickInfo()
Returns a quick info about the actor, which will be displayed in the GUI.- Specified by:
getQuickInfoin interfaceadams.core.QuickInfoSupporter- Overrides:
getQuickInfoin 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:
setWorkingDirectoryin 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:
getWorkingDirectoryin interfaceadams.core.management.WorkingDirectoryHandler- Returns:
- the directory, ignored if empty
-
workingDirectoryTipText
public String workingDirectoryTipText()
Returns the tip text for this property.- Specified by:
workingDirectoryTipTextin 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:
setEnvVarsin 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:
getEnvVarsin interfaceadams.core.management.EnvironmentVariablesHandler- Returns:
- the environment variables
-
envVarsTipText
public String envVarsTipText()
Returns the tip text for this property.- Specified by:
envVarsTipTextin 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:
doReceivein classAbstractRatInput- Returns:
- null if successful, otherwise error message
-
generates
public Class generates()
Returns the type of data this scheme generates.- Specified by:
generatesin interfaceRatInput- Specified by:
generatesin classAbstractRatInput- Returns:
- the type of data
-
hasPendingOutput
public boolean hasPendingOutput()
Checks whether any output can be collected.- Specified by:
hasPendingOutputin interfaceRatInput- Specified by:
hasPendingOutputin classAbstractRatInput- Returns:
- true if output available
-
output
public Object output()
Returns the received data.- Specified by:
outputin interfaceRatInput- Specified by:
outputin classAbstractRatInput- Returns:
- the data
-
stopExecution
public void stopExecution()
Stops the execution. No message set.- Specified by:
stopExecutionin interfaceRatInput- Specified by:
stopExecutionin interfaceadams.core.Stoppable- Overrides:
stopExecutionin classAbstractRatInput
-
-