com.bluecast.xml
Class UTF8XMLDecoder

java.lang.Object
  extended by com.bluecast.xml.UTF8XMLDecoder
All Implemented Interfaces:
CharsetDecoder, XMLDecoder

public final class UTF8XMLDecoder
extends java.lang.Object
implements XMLDecoder

A decoder for UTF-8 text. Also converts carriage returns into linefeeds and CRLF into LF.

Version:
$Revision: 1.5 $
Author:
Yuval Oren, yuval@bluecast.com

Constructor Summary
UTF8XMLDecoder()
           
 
Method Summary
 void decode(byte[] in_buf, int in_off, int in_len, char[] out_buf, int out_off, int out_len, int[] result)
          Decodes an array of bytes into characters.
 void decodeXMLDecl(byte[] in_buf, int in_off, int in_len, char[] out_buf, int out_off, int out_len, int[] result)
          Decodes the XML declaration from an array of bytes into characters.
 int maxBytesPerChar()
          Minimum number of characters produced per byte using this decoder.
 int minBytesPerChar()
          Minimum number of characters produced per byte using this decoder.
 CharsetDecoder newCharsetDecoder()
           
 XMLDecoder newXMLDecoder()
           
 void reset()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UTF8XMLDecoder

public UTF8XMLDecoder()
Method Detail

newCharsetDecoder

public CharsetDecoder newCharsetDecoder()
Specified by:
newCharsetDecoder in interface CharsetDecoder

newXMLDecoder

public XMLDecoder newXMLDecoder()
Specified by:
newXMLDecoder in interface XMLDecoder

minBytesPerChar

public int minBytesPerChar()
Description copied from interface: CharsetDecoder
Minimum number of characters produced per byte using this decoder.

Specified by:
minBytesPerChar in interface CharsetDecoder

maxBytesPerChar

public int maxBytesPerChar()
Description copied from interface: CharsetDecoder
Minimum number of characters produced per byte using this decoder.

Specified by:
maxBytesPerChar in interface CharsetDecoder

reset

public void reset()
Specified by:
reset in interface CharsetDecoder

decode

public void decode(byte[] in_buf,
                   int in_off,
                   int in_len,
                   char[] out_buf,
                   int out_off,
                   int out_len,
                   int[] result)
            throws java.io.CharConversionException
Description copied from interface: CharsetDecoder
Decodes an array of bytes into characters.

Specified by:
decode in interface CharsetDecoder
Parameters:
in_buf - input byte buffer
in_off - starting byte buffer offset
in_len - max number of bytes to read
out_buf - output character buffer
out_off - char buffer offset at which to start writing
out_len - max number of chars to write
result - an array of size >= 2 where results are returned: result[0] = number of bytes read. result[1] = number of chars written
Throws:
java.io.CharConversionException

decodeXMLDecl

public void decodeXMLDecl(byte[] in_buf,
                          int in_off,
                          int in_len,
                          char[] out_buf,
                          int out_off,
                          int out_len,
                          int[] result)
                   throws java.io.CharConversionException
Description copied from interface: XMLDecoder
Decodes the XML declaration from an array of bytes into characters. This method will read at least until a '>' character is found or until a decoding error occurs. Additional bytes may be decoded, up to a total of in_len.

Specified by:
decodeXMLDecl in interface XMLDecoder
Parameters:
in_buf - input byte buffer
in_off - starting byte buffer offset
in_len - max number of bytes to read
out_buf - output character buffer
out_off - char buffer offset at which to start writing
out_len - max number of chars to write
result - an array of size >= 2 where results are returned: result[0] = number of bytes read. result[1] = number of chars written
Throws:
java.io.CharConversionException