Package it.tidalwave.util.spi
Class DefaultProcessExecutor.DefaultConsoleOutput
- java.lang.Object
-
- it.tidalwave.util.spi.DefaultProcessExecutor.DefaultConsoleOutput
-
- All Implemented Interfaces:
ProcessExecutor.ConsoleOutput
- Enclosing class:
- DefaultProcessExecutor
public class DefaultProcessExecutor.DefaultConsoleOutput extends java.lang.Object implements ProcessExecutor.ConsoleOutput
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface it.tidalwave.util.ProcessExecutor.ConsoleOutput
ProcessExecutor.ConsoleOutput.Listener
-
-
Constructor Summary
Constructors Constructor Description DefaultConsoleOutput()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Clears the buffer of lines.java.util.Scanner
filteredAndSplitBy(java.lang.String filterRegexp, java.lang.String delimiterRegexp)
Returns aScanner
over the latest line matching a given regular expression, with the specific delimiter regular expression.java.util.List<java.lang.String>
filteredBy(java.lang.String regexp)
Returns a list of lines that match the given regular expression.boolean
latestLineMatches(java.lang.String regexp)
Returnstrue
if the latest received line matches the given regular expression.ProcessExecutor.ConsoleOutput
start()
Should not be used by the programmer.ProcessExecutor.ConsoleOutput
waitFor(java.lang.String regexp)
Waits for a line matching the given regular expression to appear.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface it.tidalwave.util.ProcessExecutor.ConsoleOutput
getListener, setListener
-
-
-
-
Method Detail
-
start
@Nonnull public ProcessExecutor.ConsoleOutput start()
Should not be used by the programmer.- Returns:
- -
-
latestLineMatches
public boolean latestLineMatches(@Nonnull java.lang.String regexp)
Returnstrue
if the latest received line matches the given regular expression.- Specified by:
latestLineMatches
in interfaceProcessExecutor.ConsoleOutput
- Parameters:
regexp
- the regular expression- Returns:
true
in case of match
-
filteredAndSplitBy
@Nonnull public java.util.Scanner filteredAndSplitBy(@Nonnull java.lang.String filterRegexp, @Nonnull java.lang.String delimiterRegexp)
Returns aScanner
over the latest line matching a given regular expression, with the specific delimiter regular expression.- Specified by:
filteredAndSplitBy
in interfaceProcessExecutor.ConsoleOutput
- Parameters:
filterRegexp
- the regular expression for the filterdelimiterRegexp
- the regular expression for theScanner
- Returns:
- the list of matching lines
-
filteredBy
@Nonnull public java.util.List<java.lang.String> filteredBy(@Nonnull java.lang.String regexp)
Returns a list of lines that match the given regular expression.- Specified by:
filteredBy
in interfaceProcessExecutor.ConsoleOutput
- Parameters:
regexp
- the regular expression- Returns:
- the list of matching lines
-
waitFor
@Nonnull public ProcessExecutor.ConsoleOutput waitFor(@Nonnull java.lang.String regexp) throws java.lang.InterruptedException, java.io.IOException
Waits for a line matching the given regular expression to appear.- Specified by:
waitFor
in interfaceProcessExecutor.ConsoleOutput
- Parameters:
regexp
- the regular expression- Returns:
- itself for chaining methods
- Throws:
java.lang.InterruptedException
- if the wait has been interruptedjava.io.IOException
- in case the process has terminated or another I/O error
-
clear
public void clear()
Clears the buffer of lines. This means that no filtering or waiting operation can be performed on the output produced so far. It will be possible to perform further operations on the output produced from now on.- Specified by:
clear
in interfaceProcessExecutor.ConsoleOutput
-
-