org.openuat.util
Class DebugInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by org.openuat.util.DebugInputStream
All Implemented Interfaces:
java.io.Closeable

public class DebugInputStream
extends java.io.InputStream

This is a decorator for an InputStream that will log every character read from the underlying stream at log4j trace level.

Version:
1.0
Author:
Rene Mayrhofer

Constructor Summary
DebugInputStream(java.io.InputStream realStream, java.lang.String loggingName)
          Initializes the decorator with the real stream.
 
Method Summary
 int available()
          Only passes through to realStream, no logging.
 void close()
          Only passes through to realStream, no logging.
 void mark(int arg0)
          Only passes through to realStream, no logging.
 boolean markSupported()
          Only passes through to realStream, no logging.
 int read()
          Passes through to realStream, but logs.
 int read(byte[] arr)
          Passes through to realStream, but logs.
 int read(byte[] arr, int off, int len)
          Passes through to realStream, but logs.
 void reset()
          Only passes through to realStream, no logging.
 long skip(long arg0)
          Only passes through to realStream, no logging.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DebugInputStream

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

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

read

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

Specified by:
read in class java.io.InputStream
Throws:
java.io.IOException

read

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

Overrides:
read in class java.io.InputStream
Throws:
java.io.IOException

read

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

Overrides:
read in class java.io.InputStream
Throws:
java.io.IOException

skip

public long skip(long arg0)
          throws java.io.IOException
Only passes through to realStream, no logging.

Overrides:
skip in class java.io.InputStream
Throws:
java.io.IOException

available

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

Overrides:
available in class java.io.InputStream
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.InputStream
Throws:
java.io.IOException

mark

public void mark(int arg0)
Only passes through to realStream, no logging.

Overrides:
mark in class java.io.InputStream

reset

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

Overrides:
reset in class java.io.InputStream
Throws:
java.io.IOException

markSupported

public boolean markSupported()
Only passes through to realStream, no logging.

Overrides:
markSupported in class java.io.InputStream


2005-2009, Rene Mayrhofer.