public class CommandHandleImpl extends Object implements CommandHandle
Modifier and Type | Method and Description |
---|---|
void |
destroy()
Forcefully terminates the command.
|
int |
exitValue()
Obtains the exit value of the command.
|
byte[] |
fetchOutput(int streamId)
Obtains the stdout or stderr of the command.
|
FileTransfer |
fetchOutput(int streamId,
String destFile)
Obtains the stdout or stderr of the command and put it into file.
|
String |
getCommandString()
Obtains the command string this command handle represents.
|
void |
waitFor()
Waits for the command to terminate.
|
void |
waitFor(int timeout)
Waits for the command to terminate, with a given timeout.
|
void |
waitMatch()
Waits for the command until it matches a certain string it its
output streams.
|
public String getCommandString()
getCommandString
in interface CommandHandle
public void destroy()
destroy
in interface CommandHandle
public void waitFor() throws InterruptedException
waitFor
in interface CommandHandle
InterruptedException
- The waiting thread got interruptedpublic void waitFor(int timeout) throws InterruptedException
waitFor
in interface CommandHandle
timeout
- The time outInterruptedException
- The waiting thread got interrupted.public int exitValue()
exitValue
in interface CommandHandle
public byte[] fetchOutput(int streamId) throws IOException
fetchOutput
in interface CommandHandle
streamId
- Command.STDOUT or Command.STDERRIOException
- There is an error getting the outputpublic FileTransfer fetchOutput(int streamId, String destFile) throws IOException, IllegalStateException
fetchOutput
in interface CommandHandle
streamId
- Command.STDOUT or Command.STDERRdestFile
- The destination file on the calling systemIOException
- There is an error getting the outputIllegalStateException
- The command is not yet terminated or
does not record outputRemoteException
- A network error occurredpublic void waitMatch() throws InterruptedException
InterruptedException
- The wait was interrupted