org.apache.tomcat.util.buf

Class C2BConverter


public final class C2BConverter
extends java.lang.Object

Efficient conversion of character to bytes. This uses the standard JDK mechansim - a writer - but provides mechanisms to recycle all the objects that are used. It is compatible with JDK1.1 and up, ( nio is better, but it's not available even in 1.2 or 1.3 )

Constructor Summary

C2BConverter(String encoding)
Create a converter
C2BConverter(ByteChunk output, String encoding)
Create a converter, with bytes going to a byte buffer

Method Summary

void
convert(String s)
Generate the bytes using the specified encoding
void
convert(c[] , int off, int len)
Generate the bytes using the specified encoding
void
convert(char c)
Generate the bytes using the specified encoding
void
convert(MessageBytes mb)
Convert a message bytes chars to bytes
void
flushBuffer()
Flush any internal buffers into the ByteOutput or the internal byte[]
ByteChunk
getByteChunk()
String
getEncoding()
void
recycle()
Reset the internal state, empty the buffers.
void
setByteChunk(ByteChunk bb)

Constructor Details

C2BConverter

public C2BConverter(String encoding)
            throws IOException
Create a converter


C2BConverter

public C2BConverter(ByteChunk output,
                    String encoding)
            throws IOException
Create a converter, with bytes going to a byte buffer

Method Details

convert

public final void convert(String s)
            throws IOException
Generate the bytes using the specified encoding


convert

public final void convert(c[] ,
                          int off,
                          int len)
            throws IOException
Generate the bytes using the specified encoding


convert

public final void convert(char c)
            throws IOException
Generate the bytes using the specified encoding


convert

public final void convert(MessageBytes mb)
            throws IOException
Convert a message bytes chars to bytes


flushBuffer

public final void flushBuffer()
            throws IOException
Flush any internal buffers into the ByteOutput or the internal byte[]


getByteChunk

public ByteChunk getByteChunk()


getEncoding

public String getEncoding()


recycle

public final void recycle()
Reset the internal state, empty the buffers. The encoding remain in effect, the internal buffers remain allocated.


setByteChunk

public void setByteChunk(ByteChunk bb)


Copyright B) 2000-2003 Apache Software Foundation. All Rights Reserved.