com.pmease.quickbuild.execution
Class LineConsumer

java.lang.Object
  extended by java.io.OutputStream
      extended by com.pmease.quickbuild.execution.LineConsumer
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable
Direct Known Subclasses:
LineConsumer.DebugLogger, LineConsumer.ErrorLogger, LineConsumer.InfoLogger, LineConsumer.NoOp, LineConsumer.TraceLogger, LineConsumer.WarnLogger

public abstract class LineConsumer
extends java.io.OutputStream

heavily inspired from LogOutputStream this stream class calls back the P4Handler on each line of stdout or stderr read


Nested Class Summary
static class LineConsumer.DebugLogger
           
static class LineConsumer.ErrorLogger
           
static class LineConsumer.InfoLogger
           
static class LineConsumer.NoOp
           
static class LineConsumer.TraceLogger
           
static class LineConsumer.WarnLogger
           
 
Constructor Summary
LineConsumer()
           
LineConsumer(java.lang.String encoding)
           
 
Method Summary
 void close()
          Writes all remaining
abstract  void consume(java.lang.String line)
          Sub class must implement this method to handle a line of output
 void flush()
           
 java.lang.String getEncoding()
           
protected  void processBuffer()
          Converts the buffer to a string and sends it to processLine
 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, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LineConsumer

public LineConsumer(java.lang.String encoding)

LineConsumer

public LineConsumer()
Method Detail

getEncoding

public java.lang.String getEncoding()

write

public 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 - IOException if an I/O error occurs. In particular, an IOException may be thrown if the output stream has been closed.

processBuffer

protected void processBuffer()
Converts the buffer to a string and sends it to processLine


consume

public abstract void consume(java.lang.String line)
Sub class must implement this method to handle a line of output

Parameters:
line -

flush

public void flush()
           throws java.io.IOException
Specified by:
flush in interface java.io.Flushable
Overrides:
flush in class java.io.OutputStream
Throws:
java.io.IOException

close

public 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 an I/O error occurs.


Copyright © 2005-2010 PMEase Inc. All Rights Reserved.