gumbo.util
Class TeeWriter

java.lang.Object
  |
  +--java.io.Writer
        |
        +--gumbo.util.TeeWriter

public class TeeWriter
extends java.io.Writer

Writer 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.Writer
lock
 
Constructor Summary
TeeWriter(java.io.Writer targetWriter)
           
TeeWriter(java.io.Writer targetWriter, java.io.Writer teeWriter)
           
TeeWriter(java.io.Writer targetWriter, java.io.Writer teeWriter, boolean autoFlushTee, boolean autoFlushTarget)
           
 
Method Summary
 void close()
           
 void flush()
           
 void setTeeWriter(java.io.Writer teeWriter)
           
 void write(char[] cbuf, int off, int len)
           
 
Methods inherited from class java.io.Writer
write, write, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TeeWriter

public TeeWriter(java.io.Writer targetWriter)
Parameters:
targetWriter - Writer being wrapped. Never null.

TeeWriter

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

TeeWriter

public TeeWriter(java.io.Writer targetWriter,
                 java.io.Writer teeWriter,
                 boolean autoFlushTee,
                 boolean autoFlushTarget)
Parameters:
targetWriter - Writer 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.
autoFlushTarget - If true, the target 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.

write

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

close

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

flush

public void flush()
           throws java.io.IOException
Specified by:
flush in class java.io.Writer
java.io.IOException