org.cdlib.xtf.util
Class TraceWriter

Object
  extended by Writer
      extended by TraceWriter
All Implemented Interfaces:
Closeable, Flushable, Appendable

public class TraceWriter
extends Writer

This is a simple PrintStream derivative that sends its output to the XTF Trace class instead of stdout or stderr.


Field Summary
private  StringBuffer buf
          Buffer to build up each line, flushed at newline
private  int traceLevel
          What level to output messages at
 
Fields inherited from class Writer
lock
 
Constructor Summary
TraceWriter(int traceLevel)
          Construct a TraceWriter, recording the Trace level that future messages written to the stream will be output at.
 
Method Summary
 void close()
          Close the stream
 void flush()
          Flush any remaining output in the buffer
private  void output(String str)
          Output a string at the configured debug level
 void write(char[] cbuf, int off, int len)
          Write a series of characters.
 
Methods inherited from class Writer
append, append, append, write, write, write, write
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

traceLevel

private int traceLevel
What level to output messages at


buf

private StringBuffer buf
Buffer to build up each line, flushed at newline

Constructor Detail

TraceWriter

public TraceWriter(int traceLevel)
Construct a TraceWriter, recording the Trace level that future messages written to the stream will be output at.

Parameters:
traceLevel - Level to output future messages.
Method Detail

write

public void write(char[] cbuf,
                  int off,
                  int len)
           throws IOException
Write a series of characters. Each newline-separated line is written to the Trace stream at the configured debug level.

Specified by:
write in class Writer
Throws:
IOException

output

private void output(String str)
Output a string at the configured debug level


flush

public void flush()
           throws IOException
Flush any remaining output in the buffer

Specified by:
flush in interface Flushable
Specified by:
flush in class Writer
Throws:
IOException

close

public void close()
           throws IOException
Close the stream

Specified by:
close in interface Closeable
Specified by:
close in class Writer
Throws:
IOException