de.enough.polish.emulator.process
Class ProcessCondition

java.lang.Object
  extended by de.enough.polish.emulator.process.ProcessCondition
All Implemented Interfaces:
OutputFilter
Direct Known Subclasses:
ProcessWait

public class ProcessCondition
extends Object
implements OutputFilter

Blocks until an started process is finished. While the process is running, filter() matches each line printed by the process with the regex

Copyright Enough Software 2008-2009

Author:
Andre Schmidt, j2mepolish@enough.de

Constructor Summary
ProcessCondition(String[] arguments, String regex)
          Constructs a new Condition instance.
ProcessCondition(String[] arguments, String[] regexes)
          Constructs a new Condition instance.
 
Method Summary
 void filter(String message, PrintStream output)
          Filters the given message.
 boolean isMet()
          Calls the process, waits until it is finished and returns result.
protected  boolean matches(String message)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProcessCondition

public ProcessCondition(String[] arguments,
                        String regex)
Constructs a new Condition instance.

Parameters:
arguments - the arguments to start the process
regex - the regex to match

ProcessCondition

public ProcessCondition(String[] arguments,
                        String[] regexes)
Constructs a new Condition instance.

Parameters:
arguments - the arguments to start the process
regexes - the regexes to match
Method Detail

filter

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

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

matches

protected boolean matches(String message)

isMet

public boolean isMet()
              throws IOException
Calls the process, waits until it is finished and returns result.

Returns:
true, if the regex was matched, otherwise false
Throws:
IOException - if an process error occurs