org.objectweb.cjdbc.common.util
Class LoggingOutputStream

java.lang.Object
  extended byjava.io.OutputStream
      extended byorg.objectweb.cjdbc.common.util.LoggingOutputStream

public class LoggingOutputStream
extends java.io.OutputStream

An OutputStream that flushes out to a Category.

Note that no data is written out to the Category until the stream is flushed or closed.

Author:
Jim Moore, Nicolas Modrzyk
See Also:
Category

Field Summary
protected  byte[] buf
          The internal buffer where data is stored.
private  int bufLength
          Remembers the size of the buffer for speed.
protected  org.apache.log4j.Category category
          The category to write to.
protected  int count
          The number of valid bytes in the buffer.
static int DEFAULT_BUFFER_LENGTH
          The default number of bytes in the buffer. =2048
protected  boolean hasBeenClosed
          Used to maintain the contract of close().
protected static java.lang.String LINE_SEPERATOR
           
protected  org.apache.log4j.Priority priority
          The priority to use when writing to the Category.
 
Constructor Summary
private LoggingOutputStream()
           
  LoggingOutputStream(org.apache.log4j.Category cat, org.apache.log4j.Priority priority)
          Creates the LoggingOutputStream to flush to the given Category.
 
Method Summary
 void close()
          Closes this output stream and releases any system resources associated with this stream.
 void flush()
          Flushes this output stream and forces any buffered output bytes to be written out.
private  void reset()
           
 void write(int b)
          Writes the specified byte to this output stream.
 
Methods inherited from class java.io.OutputStream
write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LINE_SEPERATOR

protected static final java.lang.String LINE_SEPERATOR

hasBeenClosed

protected boolean hasBeenClosed
Used to maintain the contract of close().


buf

protected byte[] buf
The internal buffer where data is stored.


count

protected int count
The number of valid bytes in the buffer. This value is always in the range 0 through buf.length; elements buf[0] through buf[count-1] contain valid byte data.


bufLength

private int bufLength
Remembers the size of the buffer for speed.


DEFAULT_BUFFER_LENGTH

public static final int DEFAULT_BUFFER_LENGTH
The default number of bytes in the buffer. =2048

See Also:
Constant Field Values

category

protected org.apache.log4j.Category category
The category to write to.


priority

protected org.apache.log4j.Priority priority
The priority to use when writing to the Category.

Constructor Detail

LoggingOutputStream

private LoggingOutputStream()

LoggingOutputStream

public LoggingOutputStream(org.apache.log4j.Category cat,
                           org.apache.log4j.Priority priority)
                    throws java.lang.IllegalArgumentException
Creates the LoggingOutputStream to flush to the given Category.

Parameters:
cat - the Category to write to
priority - the Priority to use when writing to the Category
Throws:
java.lang.IllegalArgumentException - if cat == null or priority == null
Method Detail

close

public void close()
Closes this output stream and releases any system resources associated with this stream. The general contract of close is that it closes the output stream. A closed stream cannot perform output operations and cannot be reopened.


write

public void write(int b)
           throws java.io.IOException
Writes the specified byte to this output stream. The general contract for write is that one byte is written to the output stream. The byte to be written is the eight low-order bits of the argument b. The 24 high-order bits of b are ignored.

Parameters:
b - the byte to write
Throws:
java.io.IOException - if an I/O error occurs. In particular, an IOException may be thrown if the output stream has been closed.

flush

public void flush()
Flushes this output stream and forces any buffered output bytes to be written out. The general contract of flush is that calling it is an indication that, if any bytes previously written have been buffered by the implementation of the output stream, such bytes should immediately be written to their intended destination.


reset

private void reset()


Copyright © 2002, 2005 - ObjectWeb Consortium - All Rights Reserved.