- java.lang.Object
-
- org.tentackle.common.ToolRunner
-
public class ToolRunner extends Object
Runner for external tools.
-
-
Constructor Summary
Constructors Constructor Description ToolRunner(File tool)Creates a runner for a tool.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ToolRunnerarg(Object... args)Adds arguments.voidclear()Clears arguments and results.intgetErrCode()Gets the error code.List<String>getErrors()Gets the standard error output.StringgetErrorsAsString()Gets the standard error output.List<String>getOutput()Gets the standard output.StringgetOutputAsString()Gets the standard output.ToolRunnerrun()Runs the tool.StringtoString()
-
-
-
Constructor Detail
-
ToolRunner
public ToolRunner(File tool)
Creates a runner for a tool.Throws
TentackleRuntimeExceptionif tool not found or not executable.- Parameters:
tool- the tool
-
-
Method Detail
-
arg
public ToolRunner arg(Object... args)
Adds arguments.- Parameters:
args- the arguments- Returns:
- this runner
-
run
public ToolRunner run()
Runs the tool.Throws
TentackleRuntimeExceptionif running the tool failed.- Returns:
- this runner
-
getOutput
public List<String> getOutput()
Gets the standard output.- Returns:
- the output lines, never null
-
getOutputAsString
public String getOutputAsString()
Gets the standard output.- Returns:
- the output, never null
-
getErrors
public List<String> getErrors()
Gets the standard error output.Throws
TentackleRuntimeExceptionif run method not invoked yet.- Returns:
- the error lines, never null
-
getErrorsAsString
public String getErrorsAsString()
Gets the standard error output.Throws
TentackleRuntimeExceptionif run method not invoked yet.- Returns:
- the errors, never null
-
getErrCode
public int getErrCode()
Gets the error code.Throws
TentackleRuntimeExceptionif run method not invoked yet.- Returns:
- the error, 0 if ok
-
clear
public void clear()
Clears arguments and results.
-
-