Package hudson.console
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
FilteringOutputStream
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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
LineTransformationOutputStream.Delegating
Convenience subclass for cases where you wish to process lines being sent to an underlying stream.
-
Constructor Summary
Constructors Constructor Description LineTransformationOutputStream()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
close()
protected abstract void
eol(byte[] b, int len)
Called for each end of the line.void
forceEol()
Forces the EOL behavior.protected String
trimEOL(String line)
void
write(byte[] b, int off, int len)
void
write(int b)
-
Methods inherited from class java.io.OutputStream
flush, nullOutputStream, write
-
-
-
-
Method Detail
-
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 classOutputStream
- Throws:
IOException
-
write
public void write(byte[] b, int off, int len) throws IOException
- Overrides:
write
in classOutputStream
- Throws:
IOException
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classOutputStream
- 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
-
-