Save This Page
Home » apache-tomcat-6.0.16-src » org.apache » tomcat » util » buf » [javadoc | source]
org.apache.tomcat.util.buf
final class: WriteConvertor [javadoc | source]
java.lang.Object
   java.io.Writer
      java.io.OutputStreamWriter
         org.apache.tomcat.util.buf.WriteConvertor

All Implemented Interfaces:
    Closeable, Flushable, Appendable

Special writer class, where close() is overritten. The default implementation would set byteOutputter to null, and the writter can't be recycled. Note that the flush method will empty the internal buffers _and_ call flush on the output stream - that's why we use an intermediary output stream that overrides flush(). The idea is to have full control: flushing the char->byte converter should be independent of flushing the OutputStream. When a WriteConverter is created, it'll allocate one or 2 byte buffers, with a 8k size that can't be changed ( at least in JDK1.1 -> 1.4 ). It would also allocate a ByteOutputter or equivalent - again some internal buffers. It is essential to keep this object around and reuse it. You can use either pools or per thread data - but given that in most cases a converter will be needed for every thread and most of the time only 1 ( or 2 ) encodings will be used, it is far better to keep it per thread and eliminate the pool overhead too.
Constructor:
 public WriteConvertor(IntermediateOutputStream out,
    String enc) throws UnsupportedEncodingException 
    Create a converter.
Method from org.apache.tomcat.util.buf.WriteConvertor Summary:
close,   flush,   recycle,   write
Methods from java.io.OutputStreamWriter:
close,   flush,   getEncoding,   write,   write,   write
Methods from java.io.Writer:
append,   append,   append,   append,   append,   append,   close,   flush,   write,   write,   write,   write,   write
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.tomcat.util.buf.WriteConvertor Detail:
 public final  void close() throws IOException 
    Overriden - will do nothing but reset internal state.
 public final  void flush() throws IOException 
    Flush the characters only
 public final  void recycle() 
    Reset the buffer
 public final  void write(char[] cbuf,
    int off,
    int len) throws IOException