org.apache.tools.ant.util
Class LineOrientedOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by org.apache.tools.ant.util.LineOrientedOutputStream
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable
Direct Known Subclasses:
LogOutputStream

public abstract class LineOrientedOutputStream
extends java.io.OutputStream

Invokes processLine whenever a full line has been written to this stream.

Tries to be smart about line separators.


Constructor Summary
LineOrientedOutputStream()
           
 
Method Summary
 void close()
          Writes all remaining
 void flush()
          Flush this log stream
protected  void processBuffer()
          Converts the buffer to a string and sends it to processLine
protected abstract  void processLine(java.lang.String line)
          Processes a line.
 void write(byte[] b, int off, int len)
          Write a block of characters to the output stream
 void write(int cc)
          Write the data to the buffer and flush the buffer, if a line separator is detected.
 
Methods inherited from class java.io.OutputStream
write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LineOrientedOutputStream

public LineOrientedOutputStream()
Method Detail

write

public final void write(int cc)
                 throws java.io.IOException
Write the data to the buffer and flush the buffer, if a line separator is detected.

Specified by:
write in class java.io.OutputStream
Parameters:
cc - data to log (byte).
Throws:
java.io.IOException - if there is an error.

flush

public final void flush()
                 throws java.io.IOException
Flush this log stream

Specified by:
flush in interface java.io.Flushable
Overrides:
flush in class java.io.OutputStream
Throws:
java.io.IOException - if there is an error.

processBuffer

protected void processBuffer()
                      throws java.io.IOException
Converts the buffer to a string and sends it to processLine

Throws:
java.io.IOException - if there is an error.

processLine

protected abstract void processLine(java.lang.String line)
                             throws java.io.IOException
Processes a line.

Parameters:
line - the line to log.
Throws:
java.io.IOException - if there is an error.

close

public final void close()
                 throws java.io.IOException
Writes all remaining

Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.OutputStream
Throws:
java.io.IOException - if there is an error.

write

public final void write(byte[] b,
                        int off,
                        int len)
                 throws java.io.IOException
Write a block of characters to the output stream

Overrides:
write in class java.io.OutputStream
Parameters:
b - the array containing the data
off - the offset into the array where data starts
len - the length of block
Throws:
java.io.IOException - if the data cannot be written into the stream.