org.openuat.util
Class DebugOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by org.openuat.util.DebugOutputStream
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable

public class DebugOutputStream
extends java.io.OutputStream

This is a decorator for an OutputStream that will log every character written to the underlying stream at log4j trace level.

Version:
1.0
Author:
Rene Mayrhofer

Constructor Summary
DebugOutputStream(java.io.OutputStream realStream, java.lang.String loggingName)
          Initializes the decorator with the real stream.
 
Method Summary
 void close()
          Only passes through to realStream, no logging.
 void flush()
          Only passes through to realStream, no logging.
 void write(byte[] arr)
          Passes through to realStream, but logs.
 void write(byte[] arr, int off, int len)
          Passes through to realStream, but logs.
 void write(int c)
          Passes through to realStream, but logs.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DebugOutputStream

public DebugOutputStream(java.io.OutputStream realStream,
                         java.lang.String loggingName)
Initializes the decorator with the real stream.

Parameters:
realStream - The OutputStream to write to.
loggingName - The class name to use for logging purposes. This should be the full class name (including package) of the calling class.
Method Detail

write

public void write(int c)
           throws java.io.IOException
Passes through to realStream, but logs.

Specified by:
write in class java.io.OutputStream
Throws:
java.io.IOException

write

public void write(byte[] arr)
           throws java.io.IOException
Passes through to realStream, but logs.

Overrides:
write in class java.io.OutputStream
Throws:
java.io.IOException

write

public void write(byte[] arr,
                  int off,
                  int len)
           throws java.io.IOException
Passes through to realStream, but logs.

Overrides:
write in class java.io.OutputStream
Throws:
java.io.IOException

flush

public void flush()
           throws java.io.IOException
Only passes through to realStream, no logging.

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
Only passes through to realStream, no logging.

Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.OutputStream
Throws:
java.io.IOException


2005-2006, Rene Mayrhofer.