de.enough.polish.emulator.process
Class ProcessWait

java.lang.Object
  extended by de.enough.polish.emulator.process.ProcessCondition
      extended by de.enough.polish.emulator.process.ProcessWait
All Implemented Interfaces:
OutputFilter, Runnable

public class ProcessWait
extends ProcessCondition
implements OutputFilter, Runnable

Waits until an started process prints a matching line and just returns. Used in emulators to wait till a specific stage in a process is reached.

Copyright Enough Software 2008-2009

Author:
Andre Schmidt

Constructor Summary
ProcessWait(String[] arguments, String regex)
          Constructs a new Wait instance.
ProcessWait(String[] arguments, String[] regexes)
          Constructs a new Wait instance.
ProcessWait(String[] arguments, String[] regexes, long timeout)
           
 
Method Summary
 void filter(String message, PrintStream output)
          Filters the given message.
 void proceed()
          Used to resolve wait() in the constructor.
 void run()
           
 
Methods inherited from class de.enough.polish.emulator.process.ProcessCondition
isMet, matches
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProcessWait

public ProcessWait(String[] arguments,
                   String regex)
            throws IOException
Constructs a new Wait instance. Starts the process described in arguments and wait for proceed() to be called in filter() to return.

Parameters:
arguments - the arguments for the process to start
regex - the regex for a line to match
Throws:
IOException - if an process error occurs

ProcessWait

public ProcessWait(String[] arguments,
                   String[] regexes)
            throws IOException
Constructs a new Wait instance. Starts the process described in arguments and wait for proceed() to be called in filter() to return.

Parameters:
arguments - the arguments for the process to start
regexes - the regex conditions for a line to match (first match will abort the wait)
Throws:
IOException - if an process error occurs

ProcessWait

public ProcessWait(String[] arguments,
                   String[] regexes,
                   long timeout)
            throws IOException
Throws:
IOException
Method Detail

proceed

public void proceed()
Used to resolve wait() in the constructor.


filter

public void filter(String message,
                   PrintStream output)
Description copied from interface: OutputFilter
Filters the given message.

Specified by:
filter in interface OutputFilter
Overrides:
filter in class ProcessCondition
Parameters:
message - the message
output - the output stream to which the message can be written.

run

public void run()
Specified by:
run in interface Runnable