org.glassfish.grizzly.http.util
Class UTF8Decoder

java.lang.Object
  extended by org.glassfish.grizzly.http.util.B2CConverter
      extended by org.glassfish.grizzly.http.util.UTF8Decoder

public final class UTF8Decoder
extends B2CConverter

Moved from ByteChunk - code to convert from UTF8 bytes to chars. Not used in the current tomcat3.3 : the performance gain is not very big if the String is created, only if we avoid that and work only on char[]. Until than, it's better to be safe. ( I tested this code with 2 and 3 bytes chars, and it works fine in xerces ) Cut from xerces' UTF8Reader.copyMultiByteCharData()

Author:
Costin Manolache, ( Xml-Xerces )

Constructor Summary
UTF8Decoder()
           
 
Method Summary
 int convert(BufferChunk bc, char[] c, int offset)
          Converts the BufferChunk to char[] using UTF8 encoding.
 void convert(BufferChunk bc, CharChunk cc)
           
 void convert(ByteChunk mb, CharChunk cb)
          Convert a buffer of bytes into a chars
 void recycle()
          Reset the internal state, empty the buffers.
 
Methods inherited from class org.glassfish.grizzly.http.util.B2CConverter
convert, convertASCII, init, reset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UTF8Decoder

public UTF8Decoder()
Method Detail

recycle

public void recycle()
Description copied from class: B2CConverter
Reset the internal state, empty the buffers. The encoding remain in effect, the internal buffers remain allocated.

Overrides:
recycle in class B2CConverter

convert

public void convert(ByteChunk mb,
                    CharChunk cb)
             throws IOException
Description copied from class: B2CConverter
Convert a buffer of bytes into a chars

Overrides:
convert in class B2CConverter
Throws:
IOException

convert

public void convert(BufferChunk bc,
                    CharChunk cc)
             throws IOException
Throws:
IOException

convert

public int convert(BufferChunk bc,
                   char[] c,
                   int offset)
            throws IOException
Converts the BufferChunk to char[] using UTF8 encoding.

Parameters:
bc - source BufferChunk
c - dest. char array
offset - initial offset in the dest. char array
Returns:
the "end" offset in the char array. (last char was added at c[end - 1])
Throws:
IOException


Copyright © 2012 Oracle Corporation. All Rights Reserved.