public class CmdResult<R>
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
cmd |
private java.lang.RuntimeException |
exception |
private int |
exitStatus |
private R |
result |
private java.lang.String |
stderr |
private java.lang.String |
stdout |
Constructor and Description |
---|
CmdResult(CmdResult<?> other)
Clone a cmd result instance except for the result field.
|
CmdResult(java.lang.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.
|
java.lang.String |
getCmd()
Get the command that was executed.
|
java.lang.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.
|
java.lang.String |
getStderr()
Get the text written to standard error stream from the command.
|
java.lang.String |
getStdout()
Get the text written to the standard output stream from the command.
|
(package private) void |
setException(java.lang.Exception ex) |
(package private) void |
setExitStatus(int exitStatus) |
(package private) void |
setResult(R result) |
(package private) void |
setStderr(java.lang.String stderr) |
(package private) void |
setStdout(java.lang.String stdout) |
void |
throwExceptionIfNonZeroExitStatus()
Throws an exception if the exist status is not 0.
|
java.lang.String |
toString() |
private final java.lang.String cmd
private int exitStatus
private java.lang.String stdout
private java.lang.String stderr
private R result
private java.lang.RuntimeException exception
public CmdResult(java.lang.String cmd)
CmdResult(CmdResult<?> other)
public java.lang.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(java.lang.String stdout)
public java.lang.String getStdout()
void setStderr(java.lang.String stderr)
public java.lang.String getStderr()
void setException(java.lang.Exception ex)
public java.lang.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 java.lang.String toString()
toString
in class java.lang.Object
public org.json.simple.JSONObject asJSONObject(JSONOptions options)