public class CmdResult<R> extends Object
Modifier and Type | Field and Description |
---|---|
private String |
cmd |
private RuntimeException |
exception |
private int |
exitStatus |
private R |
result |
private String |
stderr |
private String |
stdout |
Constructor and Description |
---|
CmdResult(CmdResult<?> other)
Clone a cmd result instance except for the result field.
|
CmdResult(String cmd)
Creates a new result instance.
|
Modifier and Type | Method and Description |
---|---|
org.json.simple.JSONObject |
asJSONObject(JSONOptions options)
Get the information in this result as a JSON object.
|
String |
getCmd()
Get the command that was executed.
|
RuntimeException |
getException()
Get the exception that may have caused a failure.
|
int |
getExitStatus()
Get the exit status of the command.
|
R |
getResult()
Get the result that was parsed from the command output.
|
String |
getStderr()
Get the text written to standard error stream from the command.
|
String |
getStdout()
Get the text written to the standard output stream from the command.
|
(package private) void |
setException(Exception ex) |
(package private) void |
setExitStatus(int exitStatus) |
(package private) void |
setResult(R result) |
(package private) void |
setStderr(String stderr) |
(package private) void |
setStdout(String stdout) |
void |
throwExceptionIfNonZeroExitStatus()
Throws an exception if the exist status is not 0.
|
String |
toString() |
private final String cmd
private int exitStatus
private String stdout
private String stderr
private R result
private RuntimeException exception
public CmdResult(String cmd)
CmdResult(CmdResult<?> other)
public String getCmd()
void setExitStatus(int exitStatus)
public int getExitStatus()
void setResult(R result)
public R getResult()
AbstractSession.executeCmd(String, int)
will return stderr as the result if the command failed.void setStdout(String stdout)
public String getStdout()
void setStderr(String stderr)
public String getStderr()
void setException(Exception ex)
public RuntimeException getException()
public void throwExceptionIfNonZeroExitStatus()
setException(Exception)
that exception is
re-thrown, otherwise a new RuntimeException is created with stderr
(or stdout in case stderr is empty) as the message text.public org.json.simple.JSONObject asJSONObject(JSONOptions options)