intarsys runtime library

de.intarsys.tools.reader
Class LogReader

java.lang.Object
  extended by java.io.Reader
      extended by java.io.FilterReader
          extended by de.intarsys.tools.reader.LogReader
All Implemented Interfaces:
Closeable, Readable

public class LogReader
extends FilterReader

A reader that logs any char read.

The reader is piped in the reading process, any characters read are written to an associated writer object.

 Client -> LogReader -> Reader -> Source
            |
            v
           Writer
 
todo make closing of associated writer configurable


Constructor Summary
LogReader(Reader in, Writer w)
           
 
Method Summary
 void close()
           
 Writer getLog()
           
 int read()
           
 int read(char[] cbuf, int off, int len)
          Read characters into a portion of an array.
 void setLog(Writer newLog)
           
 
Methods inherited from class java.io.FilterReader
mark, markSupported, ready, reset, skip
 
Methods inherited from class java.io.Reader
read, read
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LogReader

public LogReader(Reader in,
                 Writer w)
Method Detail

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Overrides:
close in class FilterReader
Throws:
IOException

getLog

public Writer getLog()

read

public int read()
         throws IOException
Overrides:
read in class FilterReader
Throws:
IOException

read

public int read(char[] cbuf,
                int off,
                int len)
         throws IOException
Read characters into a portion of an array. This method will block until some input is available, an I/O error occurs, or the end of the stream is reached.

Overrides:
read in class FilterReader
Parameters:
cbuf - Destination buffer
off - Offset at which to start storing characters
len - Maximum number of characters to read
Returns:
The number of characters read, or -1 if the end of the stream has been reached
Throws:
IOException - If an I/O error occurs

setLog

public void setLog(Writer newLog)

intarsys runtime library

Copyright © 2008 intarsys consulting GmbH. All Rights Reserved.