expectj
Class ProcessSpawn

java.lang.Object
  extended by expectj.AbstractSpawnable
      extended by expectj.ProcessSpawn
All Implemented Interfaces:
Spawnable

public class ProcessSpawn
extends AbstractSpawnable
implements Spawnable

This class spawns a process that ExpectJ can control.

Author:
Sachin Shekar Shetty, Johan Walles

Nested Class Summary
 
Nested classes/interfaces inherited from interface expectj.Spawnable
Spawnable.CloseListener
 
Method Summary
 int getExitValue()
          If the process representes by this object has already exited, it returns the exit code. isClosed() should be used in conjunction with this method.
 InputStream getStderr()
          Get a stream from which the Spawn's stderr can be read.
 OutputStream getStdin()
          Get a stream through which the Spawn's stdin can be written to.
 InputStream getStdout()
          Get a stream from which the Spawn's stdout can be read.
 boolean isClosed()
          Find out whether the Spawn has finished.
 void start()
          This method executes the given command within the specified time limit.
 void stop()
          This method stops the spawned process.
 
Methods inherited from class expectj.AbstractSpawnable
onClose, setCloseListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface expectj.Spawnable
setCloseListener
 

Method Detail

stop

public void stop()
This method stops the spawned process.

Specified by:
stop in interface Spawnable

start

public void start()
           throws IOException
This method executes the given command within the specified time limit. It starts the process thread and also the timer when enabled. It starts the piped streams to enable copying of process stream contents to standard streams.

Specified by:
start in interface Spawnable
Throws:
IOException - on trouble launching the process

getStdout

public InputStream getStdout()
Description copied from interface: Spawnable
Get a stream from which the Spawn's stdout can be read.

Specified by:
getStdout in interface Spawnable
Returns:
the input stream of the process.
See Also:
Process.getInputStream()

getStdin

public OutputStream getStdin()
Description copied from interface: Spawnable
Get a stream through which the Spawn's stdin can be written to.

Specified by:
getStdin in interface Spawnable
Returns:
the output stream of the process.
See Also:
Process.getOutputStream()

getStderr

public InputStream getStderr()
Description copied from interface: Spawnable
Get a stream from which the Spawn's stderr can be read.

Specified by:
getStderr in interface Spawnable
Returns:
the error stream of the process.
See Also:
Process.getErrorStream()

isClosed

public boolean isClosed()
Description copied from interface: Spawnable
Find out whether the Spawn has finished.

Specified by:
isClosed in interface Spawnable
Returns:
true if the process has exited.

getExitValue

public int getExitValue()
                 throws ExpectJException
If the process representes by this object has already exited, it returns the exit code. isClosed() should be used in conjunction with this method.

Specified by:
getExitValue in interface Spawnable
Returns:
The exit code of the finished process.
Throws:
ExpectJException - if the process is still running.
See Also:
Spawnable.isClosed(), System.exit(int)


Copyright © 2010. All Rights Reserved.