Package nzilbb.util
Class Execution
- java.lang.Object
-
- nzilbb.util.Execution
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Execution
arg(String argument)
Builder-style method for adding an argument toarguments
.Execution
env(String variable, String value)
Builder-style method for adding an environment variable toenvironmentVariables
.Vector<String>
getArguments()
Getter forarguments
: Command line arguments.LinkedHashMap<String,String>
getEnvironmentVariables()
Getter forenvironmentVariables
: Environment variables.StringBuffer
getError()
Getter forerror
: Text from stderrFile
getExe()
Getter forexe
: Executable file.boolean
getFinished()
Getter forfinished
: Whether the execution has completed.StringBuffer
getInput()
Getter forinput
: Text from stdoutProcess
getProcess()
Getter forprocess
: The executed process.boolean
getRunning()
Getter forrunning
: Whether the execution is currently running.List<Consumer<String>>
getStderrObservers()
Getter forstderrObservers
: Listeners for strings coming from stderr.List<Consumer<String>>
getStdoutObservers()
Getter forstdoutObservers
: Listeners for strings coming from stdout.boolean
getVerbose()
Getter forverbose
: Whether to log verbose debug information to stdout or not.File
getWorkingDirectory()
Getter forworkingDirectory
: The working directory for execution, or null for the current directory.void
run()
Runs the executable, monitors it, and returns when done.Execution
setArguments(Vector<String> newArguments)
Setter forarguments
: Command line arguments.Execution
setEnvironmentVariables(LinkedHashMap<String,String> newEnvironmentVariables)
Setter forenvironmentVariables
: Environment variables.Execution
setError(StringBuffer newError)
Setter forerror
: Text from stderrExecution
setExe(File newExe)
Setter forexe
: Executable file.Execution
setExe(String command)
Setter forexe
: Executable file.Execution
setInput(StringBuffer newInput)
Setter forinput
: Text from stdoutExecution
setProcess(Process newProcess)
Setter forprocess
: The executed process.Execution
setVerbose(boolean newVerbose)
Setter forverbose
: Whether to log verbose debug information to stdout or not.Execution
setWorkingDirectory(File newWorkingDirectory)
Setter forworkingDirectory
: The working directory for execution, or null for the current directory.String
stderr()
Returns output printed to stderr.String
stdout()
Returns output printed to stdout.static File
Which(String command)
Runs the "which" command to determine if a command is available.
-
-
-
Method Detail
-
getExe
public File getExe()
Getter forexe
: Executable file.- Returns:
- Executable file.
-
setExe
public Execution setExe(File newExe)
Setter forexe
: Executable file.- Parameters:
newExe
- Executable file.
-
setExe
public Execution setExe(String command)
Setter forexe
: Executable file.- Parameters:
command
- Command.
-
getWorkingDirectory
public File getWorkingDirectory()
Getter forworkingDirectory
: The working directory for execution, or null for the current directory.- Returns:
- The working directory for execution, or null for the current directory.
-
setWorkingDirectory
public Execution setWorkingDirectory(File newWorkingDirectory)
Setter forworkingDirectory
: The working directory for execution, or null for the current directory.- Parameters:
newWorkingDirectory
- The working directory for execution, or null for the current directory.
-
getEnvironmentVariables
public LinkedHashMap<String,String> getEnvironmentVariables()
Getter forenvironmentVariables
: Environment variables.- Returns:
- Environment variables.
-
setEnvironmentVariables
public Execution setEnvironmentVariables(LinkedHashMap<String,String> newEnvironmentVariables)
Setter forenvironmentVariables
: Environment variables.- Parameters:
newEnvironmentVariables
- Environment variables.
-
getArguments
public Vector<String> getArguments()
Getter forarguments
: Command line arguments.- Returns:
- Command line arguments.
-
setArguments
public Execution setArguments(Vector<String> newArguments)
Setter forarguments
: Command line arguments.- Parameters:
newArguments
- Command line arguments.
-
getProcess
public Process getProcess()
Getter forprocess
: The executed process.- Returns:
- The executed process.
-
setProcess
public Execution setProcess(Process newProcess)
Setter forprocess
: The executed process.- Parameters:
newProcess
- The executed process.
-
getInput
public StringBuffer getInput()
Getter forinput
: Text from stdout- Returns:
- Text from stdout
-
setInput
public Execution setInput(StringBuffer newInput)
Setter forinput
: Text from stdout- Parameters:
newInput
- Text from stdout
-
getError
public StringBuffer getError()
Getter forerror
: Text from stderr- Returns:
- Text from stderr
-
setError
public Execution setError(StringBuffer newError)
Setter forerror
: Text from stderr- Parameters:
newError
- Text from stderr
-
getRunning
public boolean getRunning()
Getter forrunning
: Whether the execution is currently running.- Returns:
- Whether the execution is currently running.
-
getFinished
public boolean getFinished()
Getter forfinished
: Whether the execution has completed.- Returns:
- Whether the execution has completed.
-
getVerbose
public boolean getVerbose()
Getter forverbose
: Whether to log verbose debug information to stdout or not.- Returns:
- Whether to log verbose debug information to stdout or not.
-
setVerbose
public Execution setVerbose(boolean newVerbose)
Setter forverbose
: Whether to log verbose debug information to stdout or not.- Parameters:
newVerbose
- Whether to log verbose debug information to stdout or not.
-
getStdoutObservers
public List<Consumer<String>> getStdoutObservers()
Getter forstdoutObservers
: Listeners for strings coming from stdout.- Returns:
- Listeners for strings coming from stdout.
-
getStderrObservers
public List<Consumer<String>> getStderrObservers()
Getter forstderrObservers
: Listeners for strings coming from stderr.- Returns:
- Listeners for strings coming from stderr.
-
arg
public Execution arg(String argument)
Builder-style method for adding an argument toarguments
.- Parameters:
argument
- The argument to add.- Returns:
- A reference to this object.
-
env
public Execution env(String variable, String value)
Builder-style method for adding an environment variable toenvironmentVariables
.- Parameters:
variable
- The variable to add.value
- The value for the variable.- Returns:
- A reference to this object.
-
run
public void run()
Runs the executable, monitors it, and returns when done.
-
stdout
public String stdout()
Returns output printed to stdout.- Returns:
- Output printed to stdout.
- See Also:
getInput()
-
stderr
public String stderr()
Returns output printed to stderr.- Returns:
- Output printed to stderr.
- See Also:
getError()
-
-