org.glite.data.common.helpers
Class CommandResult

java.lang.Object
  extended byorg.glite.data.common.helpers.CommandResult

public final class CommandResult
extends java.lang.Object

See StreamChomp.

Command result class for reading the output of a Runtimne.exec properly. The usage is as follows:

Runtime runtime = Runtime.getRuntime();
Process proc = null;
proc = runtime.exec(command.toString());
StreamChomp stdout = new StreamChomp(proc.getInputStream(), "stdout");
StreamChomp stderr = new StreamChomp(proc.getErrorStream(), "stderr");
stdout.start();
stderr.start();
exitCode = proc.waitFor();
while (!stdout.isDone()) {
Thread.sleep(10);
}
while (!stderr.isDone()) {
Thread.sleep(10);
}
commandResult.setOut(stdout);
commandResult.setErr(stderr);
commandResult.setRetCode(exitCode);


Constructor Summary
CommandResult()
           
 
Method Summary
 StreamChomp getErr()
          Get error of command.
 StreamChomp getOut()
          Get output of command.
 int getRetCode()
          Get return code of command.
 void setErr(StreamChomp err)
          Bean setter method.
 void setOut(StreamChomp out)
          Bean setter method.
 void setRetCode(int retCode)
          Bean setter method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommandResult

public CommandResult()
Method Detail

getOut

public StreamChomp getOut()
Get output of command.

Returns:
output stream

setOut

public void setOut(StreamChomp out)
Bean setter method.

Parameters:
out - the output to be set

getErr

public StreamChomp getErr()
Get error of command.

Returns:
error stream

setErr

public void setErr(StreamChomp err)
Bean setter method.

Parameters:
err - the error to be set

getRetCode

public int getRetCode()
Get return code of command.

Returns:
Return code

setRetCode

public void setRetCode(int retCode)
Bean setter method.

Parameters:
retCode - return code