public class ToolContext extends MasterToolContext
Constructor and Description |
---|
ToolContext(String tool,
ServiceContext ctx,
ToolDescription desc,
ToolWrapper wrapper)
Constructs the tool context.
|
Modifier and Type | Method and Description |
---|---|
CommandHandle |
exec(Command cmd,
boolean useOutput)
Executes a command, optionally use the stdout from this command as the
tool output.
|
CommandHandle |
exec(Command cmd,
boolean useOutput,
int stream)
Executes a command, optionally use the stdout or stderr from this
command as the tool output.
|
String |
getOutputFile()
Returns name of output file.
|
String |
getOutputFile(String id)
Obtains one of the multiple output files identified by the id.
|
List<NameValuePair<String>> |
getOutputFiles()
Gets a list of output files.
|
ServiceContext |
getServiceContext()
Returns ServiceContext for the tool.
|
String |
getServiceProperty(String key)
Obtains the service property for the given key.
|
String |
getTmpDir()
Obtains the temporary directory to be used for storing temporary files.
|
List<String> |
getToolArgs()
Returns list of tool arguments.
|
String |
getToolName()
Returns tool name.
|
int |
getToolStatus()
Returns tool status.
|
CommandHandle |
java(Command cmd,
boolean useOutput)
Executes a command, optionally use the stdout from this command as the
tool output.
|
CommandHandle |
java(Command cmd,
boolean useOutput,
int stream)
Executes a command, optionally use the stdout or stderr from this
command as the tool output.
|
void |
setOutputFile(String path)
Sets the default output file with the given path.
|
void |
setOutputFile(String id,
String path)
Set output file with an id.
|
void |
setOutputStream(CommandHandle handle)
Sets the stdout from a command to be used as the tool output.
|
void |
setOutputStream(CommandHandle handle,
int stream)
Sets the stdout or stderr from a command to be used as the tool output.
|
equals, getTool, getToolDescription, getToolId, getToolParams, getToolServiceContext, hashCode
public ToolContext(String tool, ServiceContext ctx, ToolDescription desc, ToolWrapper wrapper)
tool
- The tool namectx
- The service context, if anydesc
- The tool descriptionwrapper
- The tool wrapper responsible for invoking the tool.public int getToolStatus()
public String getToolName()
public List<String> getToolArgs()
public String getOutputFile()
public void setOutputFile(String path)
path
- The output file path.public void setOutputFile(String id, String path)
id
- The idpath
- The pathpublic String getOutputFile(String id)
id
- The idpublic List<NameValuePair<String>> getOutputFiles()
public String getServiceProperty(String key)
key
- The service property namepublic ServiceContext getServiceContext()
public CommandHandle exec(Command cmd, boolean useOutput) throws IOException, InterruptedException
cmd
- The command to executeuseOutput
- Whether to use the output from this commandIOException
- The command failed to executeInterruptedException
- Interrupted waiting for the commandpublic CommandHandle exec(Command cmd, boolean useOutput, int stream) throws IOException, InterruptedException
cmd
- The command to executeuseOutput
- Whether to use the output from this commandstream
- The stream to use as the output, STDOUT or STDERRIOException
- The command failed to executeInterruptedException
- Interrupted waiting for the commandpublic CommandHandle java(Command cmd, boolean useOutput) throws IOException, InterruptedException
cmd
- The command to executeuseOutput
- Whether to use the output from this commandIOException
- The command failed to executeInterruptedException
- Interrupted waiting for the commandpublic CommandHandle java(Command cmd, boolean useOutput, int stream) throws IOException, InterruptedException
cmd
- The command to executeuseOutput
- Whether to use the output from this commandstream
- The stream to use as the output, STDOUT or STDERRIOException
- The command failed to executeInterruptedException
- Interrupted waiting for the commandpublic void setOutputStream(CommandHandle handle)
handle
- The command handle to the command to capture.public void setOutputStream(CommandHandle handle, int stream)
handle
- The command handle to the command to capturestream
- The stream to use as the output, STDOUT or STDERRpublic String getTmpDir()