Package com.ctc.wstx.io
Class UTF32Reader
java.lang.Object
java.io.Reader
com.ctc.wstx.io.BaseReader
com.ctc.wstx.io.UTF32Reader
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Readable
Since JDK does not come with UTF-32/UCS-4, let's implement a simple
decoder to use.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final boolean
protected int
Total read byte count; used for error reporting purposesprotected int
Total read character count; used for error reporting purposesprotected char
Although input is fine with full Unicode set, Java still uses 16-bit chars, so we may have to split high-order chars into surrogate pairs.protected boolean
Fields inherited from class com.ctc.wstx.io.BaseReader
CHAR_DEL, CONVERT_LSEP_TO, CONVERT_NEL_TO, mByteBuffer, mByteBufferEnd, mBytePtr, mConfig, mTmpBuf, NULL_BYTE, NULL_CHAR
-
Constructor Summary
ConstructorsConstructorDescriptionUTF32Reader
(ReaderConfig cfg, InputStream in, byte[] buf, int ptr, int len, boolean recycleBuffer, boolean isBigEndian) -
Method Summary
Modifier and TypeMethodDescriptionprivate boolean
loadMore
(int available) int
read
(char[] cbuf, int start, int len) private void
reportInvalid
(int value, int offset, String msg) private void
reportUnexpectedEOF
(int gotBytes, int needed) 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 com.ctc.wstx.io.BaseReader
canModifyBuffer, close, freeBuffers, getStream, read, readBytes, readBytesAt, reportBounds, reportInvalidXml11, reportStrangeStream
-
Field Details
-
mBigEndian
protected final boolean mBigEndian -
mXml11
protected boolean mXml11 -
mSurrogate
protected char mSurrogateAlthough input is fine with full Unicode set, Java still uses 16-bit chars, so we may have to split high-order chars into surrogate pairs. -
mCharCount
protected int mCharCountTotal read character count; used for error reporting purposes -
mByteCount
protected int mByteCountTotal read byte count; used for error reporting purposes
-
-
Constructor Details
-
UTF32Reader
public UTF32Reader(ReaderConfig cfg, InputStream in, byte[] buf, int ptr, int len, boolean recycleBuffer, boolean isBigEndian)
-
-
Method Details
-
setXmlCompliancy
public void setXmlCompliancy(int xmlVersion) Description copied from class:BaseReader
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).- Specified by:
setXmlCompliancy
in classBaseReader
-
read
- Specified by:
read
in classReader
- Throws:
IOException
-
reportUnexpectedEOF
- Throws:
IOException
-
reportInvalid
- Throws:
IOException
-
loadMore
- Parameters:
available
- Number of "unused" bytes in the input buffer- Returns:
- True, if enough bytes were read to allow decoding of at least one full character; false if EOF was encountered instead.
- Throws:
IOException
-