java.lang.Object
de.hybris.platform.mediaconversion.os.process.StringDrain
All Implemented Interfaces:
Drain

public class StringDrain extends Object implements Drain
Drain implementation gathering all output in a StringBuffer.

The result string can be accessed through the toString() method.

  • Constructor Details

    • StringDrain

      public StringDrain()
      Constructs a new StringDrain which will append/reconstruct newlines.
    • StringDrain

      public StringDrain(boolean appendNewlines)
      Creates a new StringDrain which optionally appends newline to each processed line.
      Parameters:
      appendNewlines - whether newlines (\n) should be appended to each line, this would reconstruct the original contents of the output.
  • Method Details

    • drain

      public void drain(String line)
      Callback method to process a line outputted by the process. A trailing newline character is truncated.
      Specified by:
      drain in interface Drain
      Parameters:
      line - the output line to process.
      See Also:
    • isAppendingNewlines

      public boolean isAppendingNewlines()
      Accesses whether newline characters are appended to each consumed line.
      Returns:
      the appendNewlines flag as specified on construction time.
    • toString

      public String toString()
      Accesses the current contents of this StringDrain.
      Overrides:
      toString in class Object
      Returns:
      the current contents of the underlying StringBuffer, i.e. all data forwarded to this Drain yet.
      See Also: