org.apache.tomcat.util.buf

Class C2BConverter

public final class C2BConverter extends 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(ByteChunk output, String encoding)
Create a converter, with bytes going to a byte buffer
C2BConverter(String encoding)
Create a converter
Method Summary
voidconvert(char[] c, int off, int len)
Generate the bytes using the specified encoding
voidconvert(String s, int off, int len)
Generate the bytes using the specified encoding
voidconvert(String s)
Generate the bytes using the specified encoding
voidconvert(char c)
Generate the bytes using the specified encoding
voidconvert(MessageBytes mb)
Convert a message bytes chars to bytes
voidflushBuffer()
Flush any internal buffers into the ByteOutput or the internal byte[]
ByteChunkgetByteChunk()
StringgetEncoding()
voidrecycle()
Reset the internal state, empty the buffers.
voidsetByteChunk(ByteChunk bb)

Constructor Detail

C2BConverter

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

C2BConverter

public C2BConverter(String encoding)
Create a converter

Method Detail

convert

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

convert

public final void convert(String s, int off, int len)
Generate the bytes using the specified encoding

convert

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

convert

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

convert

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

flushBuffer

public final void flushBuffer()
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 © 2000-2011 Apache Software Foundation. All Rights Reserved.