gumbo.util
Class TeeReader

java.lang.Object
  |
  +--java.io.Reader
        |
        +--gumbo.util.TeeReader

public class TeeReader
extends java.io.Reader

Reader wrapper that copies through data to a "tee" writer. The tee writer closes when the reader closes.

Version:
$Revision: 1.6 $
Author:
Jon Barrilleaux (jonb@jmbaai.com) of JMB and Associates Inc.

Field Summary
 
Fields inherited from class java.io.Reader
lock
 
Constructor Summary
TeeReader(java.io.Reader sourceReader)
           
TeeReader(java.io.Reader sourceReader, java.io.Writer teeWriter)
           
TeeReader(java.io.Reader sourceReader, java.io.Writer teeWriter, boolean autoFlushTee)
           
 
Method Summary
 void close()
           
 int read(char[] cbuf, int off, int len)
           
 void setTeeWriter(java.io.Writer teeWriter)
           
 
Methods inherited from class java.io.Reader
mark, markSupported, read, read, ready, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TeeReader

public TeeReader(java.io.Reader sourceReader)
Parameters:
sourceReader - Reader being wrapped. Never null.

TeeReader

public TeeReader(java.io.Reader sourceReader,
                 java.io.Writer teeWriter)
Parameters:
sourceReader - Reader being wrapped. Never null.
teeWriter - Writer that will receive a copy of the through data. Null if none.

TeeReader

public TeeReader(java.io.Reader sourceReader,
                 java.io.Writer teeWriter,
                 boolean autoFlushTee)
Parameters:
sourceReader - Reader being wrapped. Never null.
teeWriter - Writer that will receive a copy of the through data. Null if none.
autoFlushTee - If true, the tee writer flushes after each write. Defaults to false.
Method Detail

setTeeWriter

public void setTeeWriter(java.io.Writer teeWriter)
Parameters:
teeWriter - Writer that will receive a copy of the through data. Null if none.

read

public int read(char[] cbuf,
                int off,
                int len)
         throws java.io.IOException
Specified by:
read in class java.io.Reader
java.io.IOException

close

public void close()
           throws java.io.IOException
Specified by:
close in class java.io.Reader
java.io.IOException