Class LineTransformationOutputStream

java.lang.Object
java.io.OutputStream
hudson.console.LineTransformationOutputStream
All Implemented Interfaces:
Closeable, Flushable, AutoCloseable
Direct Known Subclasses:
ConsoleAnnotationOutputStream, LineTransformationOutputStream.Delegating

public abstract class LineTransformationOutputStream extends OutputStream
Filtering OutputStream that buffers text by line, so that the derived class can perform some manipulation based on the contents of the whole line.

Subclass LineTransformationOutputStream.Delegating in the typical case that you are decorating an underlying stream.

Since:
1.349
Author:
Kohsuke Kawaguchi
  • Constructor Details

    • LineTransformationOutputStream

      public LineTransformationOutputStream()
  • Method Details

    • eol

      protected abstract void eol(byte[] b, int len) throws IOException
      Called for each end of the line.
      Parameters:
      b - Contents of the whole line, including the EOL code like CR/LF.
      len - Specifies the length of the valid contents in 'b'. The rest is garbage. This is so that the caller doesn't have to allocate an array of the exact size.
      Throws:
      IOException
    • write

      public void write(int b) throws IOException
      Specified by:
      write in class OutputStream
      Throws:
      IOException
    • write

      public void write(byte[] b, int off, int len) throws IOException
      Overrides:
      write in class OutputStream
      Throws:
      IOException
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class OutputStream
      Throws:
      IOException
    • forceEol

      public void forceEol() throws IOException
      Forces the EOL behavior. Useful if the caller wants to make sure the buffered content is all processed, but without actually neither flushing nor closing the stream.
      Throws:
      IOException
    • trimEOL

      protected String trimEOL(String line)