com.ctc.wstx.io
Class UTF32Reader

java.lang.Object
  extended by java.io.Reader
      extended by com.ctc.wstx.io.UTF32Reader
All Implemented Interfaces:
java.io.Closeable, java.lang.Readable

public final class UTF32Reader
extends java.io.Reader

Since JDK does not come with UTF-32/UCS-4, let's implement a simple decoder to use.


Field Summary
protected static char CONVERT_LSEP_TO
          In xml 1.1, LSEP bit like \n, or \r.
protected static char CONVERT_NEL_TO
          In xml 1.1, NEL (0x85) behaves much the way \n does (can be follow \r as part of the linefeed
protected  byte[] mBuffer
           
protected  java.io.InputStream mIn
           
protected  int mLength
           
protected  int mPtr
           
protected static char NULL_BYTE
           
protected static char NULL_CHAR
           
 
Fields inherited from class java.io.Reader
lock
 
Constructor Summary
UTF32Reader(ReaderConfig cfg, java.io.InputStream in, byte[] buf, int ptr, int len, boolean isBigEndian)
           
 
Method Summary
 void close()
           
 void freeBuffers()
          This method should be called along with (or instead of) normal close.
 int read()
          Although this method is implemented by the base class, AND it should never be called by Woodstox code, let's still implement it bit more efficiently just in case
 int read(char[] cbuf, int start, int len)
           
protected  void reportBounds(char[] cbuf, int start, int len)
           
protected  void reportInvalidXml11(int value, int bytePos, int charPos)
           
protected  void reportStrangeStream()
           
 void setXmlCompliancy(int xmlVersion)
          Method that can be called to indicate the xml conformance used when reading content using this reader.
 
Methods inherited from class java.io.Reader
mark, markSupported, read, read, ready, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NULL_CHAR

protected static final char NULL_CHAR
See Also:
Constant Field Values

NULL_BYTE

protected static final char NULL_BYTE
See Also:
Constant Field Values

CONVERT_NEL_TO

protected static final char CONVERT_NEL_TO
In xml 1.1, NEL (0x85) behaves much the way \n does (can be follow \r as part of the linefeed

See Also:
Constant Field Values

CONVERT_LSEP_TO

protected static final char CONVERT_LSEP_TO
In xml 1.1, LSEP bit like \n, or \r. Need to choose one as the result. Let's use \n, for simplicity

See Also:
Constant Field Values

mIn

protected java.io.InputStream mIn

mBuffer

protected byte[] mBuffer

mPtr

protected int mPtr

mLength

protected int mLength
Constructor Detail

UTF32Reader

public UTF32Reader(ReaderConfig cfg,
                   java.io.InputStream in,
                   byte[] buf,
                   int ptr,
                   int len,
                   boolean isBigEndian)
Method Detail

setXmlCompliancy

public void setXmlCompliancy(int xmlVersion)
Method that can be called to indicate the xml conformance used when reading content using this reader. Some of the character validity checks need to be done at reader level, and sometimes they depend on xml level (for example, xml 1.1 has new linefeeds and both more and less restricted characters).


read

public int read(char[] cbuf,
                int start,
                int len)
         throws java.io.IOException
Specified by:
read in class java.io.Reader
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Specified by:
close in interface java.io.Closeable
Specified by:
close in class java.io.Reader
Throws:
java.io.IOException

read

public int read()
         throws java.io.IOException
Although this method is implemented by the base class, AND it should never be called by Woodstox code, let's still implement it bit more efficiently just in case

Overrides:
read in class java.io.Reader
Throws:
java.io.IOException

freeBuffers

public final void freeBuffers()
This method should be called along with (or instead of) normal close. After calling this method, no further reads should be tried. Method will try to recycle read buffers (if any).


reportBounds

protected void reportBounds(char[] cbuf,
                            int start,
                            int len)
                     throws java.io.IOException
Throws:
java.io.IOException

reportStrangeStream

protected void reportStrangeStream()
                            throws java.io.IOException
Throws:
java.io.IOException

reportInvalidXml11

protected void reportInvalidXml11(int value,
                                  int bytePos,
                                  int charPos)
                           throws java.io.IOException
Throws:
java.io.IOException