bb.util
Class JUnitExecutor.BufferWithEcho

java.lang.Object
  extended by java.io.OutputStream
      extended by java.io.ByteArrayOutputStream
          extended by bb.util.JUnitExecutor.BufferWithEcho
All Implemented Interfaces:
Closeable, Flushable
Enclosing class:
JUnitExecutor

private static class JUnitExecutor.BufferWithEcho
extends ByteArrayOutputStream

Modifies superclass to echo the last line stored in the buffer to the console after byte(s) are written to it. This gives the user some amount of feedback as to what is going on.

The console output is continuously overwritten on the same line in order to reduce clutter, just like the ConsoleUtil class does.

It is critical that this stream be closed when its use is over, since the close method has been overridden to erase the console line that it has been writing to.

This class is multithread safe: every public method is synchronized.


Field Summary
private  PrintStream stdStreamOriginal
           
 
Fields inherited from class java.io.ByteArrayOutputStream
buf, count
 
Constructor Summary
private JUnitExecutor.BufferWithEcho(PrintStream stdStreamOriginal)
           
 
Method Summary
 void close()
          Overrides superclass method to additionally erase the console line that this instance has been writing to.
private  void echoLastLine()
           
private  void eraseLine()
           
 void write(byte[] b, int off, int len)
           
 void write(int b)
           
private  void writeLine(String line)
           
 
Methods inherited from class java.io.ByteArrayOutputStream
reset, size, toByteArray, toString, toString, toString, writeTo
 
Methods inherited from class java.io.OutputStream
flush, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

stdStreamOriginal

private final PrintStream stdStreamOriginal
Constructor Detail

JUnitExecutor.BufferWithEcho

private JUnitExecutor.BufferWithEcho(PrintStream stdStreamOriginal)
Method Detail

write

public void write(int b)
Overrides:
write in class ByteArrayOutputStream

write

public void write(byte[] b,
                  int off,
                  int len)
Overrides:
write in class ByteArrayOutputStream

echoLastLine

private void echoLastLine()

eraseLine

private void eraseLine()

writeLine

private void writeLine(String line)

close

public void close()
           throws IOException
Overrides superclass method to additionally erase the console line that this instance has been writing to.

Specified by:
close in interface Closeable
Overrides:
close in class ByteArrayOutputStream
Throws:
IOException