com.sun.grizzly.util.buf
Class C2BConverter

java.lang.Object
  extended by com.sun.grizzly.util.buf.C2BConverter

public class C2BConverter
extends Object

Efficient conversion of character to bytes. Now uses NIO directly


Field Summary
protected  ByteChunk bb
           
protected  String enc
           
protected  CharsetEncoder encoder
           
 
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
 void convert(char c)
          Generate the bytes using the specified encoding
 void convert(char[] c, int off, int len)
          Generate the bytes using the specified encoding
 void convert(MessageBytes mb)
          Convert a message bytes chars to bytes
 void convert(String s)
          Generate the bytes using the specified encoding
 void convert(String s, int off, int len)
          Generate the bytes using the specified encoding
 void flushBuffer()
          Flush any internal buffers into the ByteOutput or the internal byte[]
 ByteChunk getByteChunk()
           
 String getEncoding()
           
static C2BConverter getInstance(ByteChunk output, String encoding)
           
 void recycle()
          Reset the internal state, empty the buffers.
 void setByteChunk(ByteChunk bb)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

bb

protected ByteChunk bb

enc

protected String enc

encoder

protected CharsetEncoder encoder
Constructor Detail

C2BConverter

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

Throws:
IOException

C2BConverter

public C2BConverter(String encoding)
             throws IOException
Create a converter

Throws:
IOException
Method Detail

getInstance

public static C2BConverter getInstance(ByteChunk output,
                                       String encoding)
                                throws IOException
Throws:
IOException

getByteChunk

public ByteChunk getByteChunk()

getEncoding

public String getEncoding()

setByteChunk

public void setByteChunk(ByteChunk bb)

recycle

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


convert

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

Throws:
IOException

convert

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

Throws:
IOException

convert

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

Throws:
IOException

convert

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

Throws:
IOException

convert

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

Throws:
IOException

flushBuffer

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

Throws:
IOException


Copyright © 2012 Oracle Corporation. All Rights Reserved.