hudson.console
Class LineTransformationOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by hudson.console.LineTransformationOutputStream
All Implemented Interfaces:
Closeable, Flushable
Direct Known Subclasses:
ConsoleAnnotationOutputStream, MavenConsoleAnnotator, PlainTextConsoleOutputStream

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. TODO: Mac is supposed to be CR-only. This class needs to handle that.

Since:
1.349
Author:
Kohsuke Kawaguchi

Constructor Summary
LineTransformationOutputStream()
           
 
Method Summary
 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, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LineTransformationOutputStream

public LineTransformationOutputStream()
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 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 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)


Copyright © 2004-2013. All Rights Reserved.