Top Description Fields Constructors Methods
org.glassfish.grizzly.http.util

public Class C2BConverter

extends Object
Class Inheritance
Imports
java.io.IOException, java.nio.ByteBuffer, .CharBuffer, java.nio.charset.CharsetEncoder, .CoderResult, .CodingErrorAction, java.util.logging.Level, .Logger, org.glassfish.grizzly.Grizzly, org.glassfish.grizzly.utils.Charsets

Efficient conversion of character to bytes. Now uses NIO directly

Field Summary

Modifier and TypeField and Description
protected ByteChunk
protected final String
protected final CharsetEncoder
private static final Logger

Constructor Summary

AccessConstructor and Description
public
C2BConverter(ByteChunk output, String encoding)

Create a converter, with bytes going to a byte buffer

public
C2BConverter(String encoding)

Create a converter

Method Summary

Modifier and TypeMethod and Description
public void
convert(char[] c, int off, int len)

Generate the bytes using the specified encoding

public void
convert(String s)

Generate the bytes using the specified encoding

public void
convert(String s, int off, int len)

Generate the bytes using the specified encoding

public void
convert(char c)

Generate the bytes using the specified encoding

public void
convert(MessageBytes mb)

Convert a message bytes chars to bytes

public void
flushBuffer()

Flush any internal buffers into the ByteOutput or the internal byte[]

public ByteChunk
public String
public static C2BConverter
getInstance(ByteChunk output, String encoding)

public void
recycle()

Reset the internal state, empty the buffers.

public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bbback to summary
protected ByteChunk bb
encback to summary
protected final String enc
encoderback to summary
protected final CharsetEncoder encoder
loggerback to summary
private static final Logger logger

Constructor Detail

C2BConverterback to summary
public C2BConverter(ByteChunk output, String encoding) throws IOException

Create a converter, with bytes going to a byte buffer

C2BConverterback to summary
public C2BConverter(String encoding) throws IOException

Create a converter

Method Detail

convertback to summary
public void convert(char[] c, int off, int len) throws IOException

Generate the bytes using the specified encoding

convertback to summary
public void convert(String s) throws IOException

Generate the bytes using the specified encoding

convertback to summary
public void convert(String s, int off, int len) throws IOException

Generate the bytes using the specified encoding

convertback to summary
public void convert(char c) throws IOException

Generate the bytes using the specified encoding

convertback to summary
public void convert(MessageBytes mb) throws IOException

Convert a message bytes chars to bytes

flushBufferback to summary
public void flushBuffer() throws IOException

Flush any internal buffers into the ByteOutput or the internal byte[]

getByteChunkback to summary
public ByteChunk getByteChunk()
getEncodingback to summary
public String getEncoding()
getInstanceback to summary
public static C2BConverter getInstance(ByteChunk output, String encoding) throws IOException
recycleback to summary
public void recycle()

Reset the internal state, empty the buffers. The encoding remain in effect, the internal buffers remain allocated.

setByteChunkback to summary
public void setByteChunk(ByteChunk bb)