Package it.tidalwave.util
Interface ProcessExecutor.ConsoleOutput
-
- All Known Implementing Classes:
DefaultProcessExecutor.DefaultConsoleOutput
- Enclosing interface:
- ProcessExecutor
public static interface ProcessExecutor.ConsoleOutput
This interface provides operations that can be performed on the stdout or stderr consoles attached to the external process.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
ProcessExecutor.ConsoleOutput.Listener
A listener that is invoked whenever a line is read from the console.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
clear()
Clears the buffer of lines.java.util.Scanner
filteredAndSplitBy(java.lang.String regexp, 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.ProcessExecutor.ConsoleOutput.Listener
getListener()
Returns the set listenerboolean
latestLineMatches(java.lang.String regexp)
Returnstrue
if the latest received line matches the given regular expression.void
setListener(ProcessExecutor.ConsoleOutput.Listener listener)
Sets a listener.ProcessExecutor.ConsoleOutput
waitFor(java.lang.String regexp)
Waits for a line matching the given regular expression to appear.
-
-
-
Method Detail
-
latestLineMatches
boolean latestLineMatches(@Nonnull java.lang.String regexp)
Returnstrue
if the latest received line matches the given regular expression.- Parameters:
regexp
- the regular expression- Returns:
true
in case of match
-
filteredBy
@Nonnull java.util.List<java.lang.String> filteredBy(@Nonnull java.lang.String regexp)
Returns a list of lines that match the given regular expression.- Parameters:
regexp
- the regular expression- Returns:
- the list of matching lines
-
filteredAndSplitBy
@Nonnull java.util.Scanner filteredAndSplitBy(@Nonnull java.lang.String regexp, @Nonnull java.lang.String delimiterRegexp)
Returns aScanner
over the latest line matching a given regular expression, with the specific delimiter regular expression.- Parameters:
regexp
- the regular expression for the filterdelimiterRegexp
- the regular expression for theScanner
- Returns:
- the list of matching lines
-
waitFor
@Nonnull 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.- 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
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.
-
setListener
void setListener(@Nonnull ProcessExecutor.ConsoleOutput.Listener listener)
Sets a listener.- Parameters:
listener
- the listener- See Also:
ProcessExecutor.ConsoleOutput.Listener
-
getListener
@CheckForNull ProcessExecutor.ConsoleOutput.Listener getListener()
Returns the set listener- Returns:
- the listener
- See Also:
ProcessExecutor.ConsoleOutput.Listener
-
-