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 ExecutionaddStderrObserver(Consumer<String> observer)Builder-pattern method for adding a stderr observer.ExecutionaddStdoutObserver(Consumer<String> observer)Builder-pattern method for adding a stdout observer.Executionarg(String argument)Builder-style method for adding an argument toarguments.Executionenv(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.StringBuffergetError()Getter forerror: Text from stderrFilegetExe()Getter forexe: Executable file.booleangetFinished()Getter forfinished: Whether the execution has completed.StringBuffergetInput()Getter forinput: Text from stdoutProcessgetProcess()Getter forprocess: The executed process.booleangetRunning()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.booleangetVerbose()Getter forverbose: Whether to log verbose debug information to stdout or not.FilegetWorkingDirectory()Getter forworkingDirectory: The working directory for execution, or null for the current directory.voidrun()Runs the executable, monitors it, and returns when done.ExecutionsetArguments(Vector<String> newArguments)Setter forarguments: Command line arguments.ExecutionsetEnvironmentVariables(LinkedHashMap<String,String> newEnvironmentVariables)Setter forenvironmentVariables: Environment variables.ExecutionsetError(StringBuffer newError)Setter forerror: Text from stderrExecutionsetExe(File newExe)Setter forexe: Executable file.ExecutionsetExe(String command)Setter forexe: Executable file.ExecutionsetInput(StringBuffer newInput)Setter forinput: Text from stdoutExecutionsetProcess(Process newProcess)Setter forprocess: The executed process.ExecutionsetVerbose(boolean newVerbose)Setter forverbose: Whether to log verbose debug information to stdout or not.ExecutionsetWorkingDirectory(File newWorkingDirectory)Setter forworkingDirectory: The working directory for execution, or null for the current directory.Stringstderr()Returns output printed to stderr.Stringstdout()Returns output printed to stdout.static FileWhich(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.
-
addStdoutObserver
public Execution addStdoutObserver(Consumer<String> observer)
Builder-pattern method for adding a stdout observer.- Parameters:
observer-- Returns:
- This Execution.
-
addStderrObserver
public Execution addStderrObserver(Consumer<String> observer)
Builder-pattern method for adding a stderr observer.- Parameters:
observer-- Returns:
- This Execution.
-
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()
-
-