Top Description Fields Constructors Methods
com.ctc.wstx.io

public final Class UTF32Reader

extends BaseReader
Class Inheritance
Imports
java.io.*, com.ctc.wstx.api.ReaderConfig, com.ctc.wstx.cfg.XmlConsts

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

Field Summary

Modifier and TypeField and Description
protected final boolean
protected int
mByteCount

Total read byte count; used for error reporting purposes

protected int
mCharCount

Total read character count; used for error reporting purposes

protected char
mSurrogate

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
Inherited from com.ctc.wstx.io.BaseReader:
CHAR_DELCONVERT_LSEP_TOCONVERT_NEL_TOmByteBuffermByteBufferEndmBytePtrmConfigmTmpBufNULL_BYTENULL_CHAR

Constructor Summary

AccessConstructor and Description
public
UTF32Reader(ReaderConfig cfg, InputStream in, byte[] buf, int ptr, int len, boolean recycleBuffer, boolean isBigEndian)

Method Summary

Modifier and TypeMethod and Description
private boolean

Returns:

True, if enough bytes were read to allow decoding of at least one full character; false if EOF was encountered instead.
loadMore
(int
Number of "unused" bytes in the input buffer
available
)

public int
read(char[]
Destination buffer
cbuf
,
int
Offset at which to start storing characters
start
,
int
Maximum number of characters to read
len
)

Implements abstract java.io.Reader.read.

Reads characters into a portion of an array.

private void
reportInvalid(int value, int offset, String msg)

private void
reportUnexpectedEOF(int gotBytes, int needed)

public void
setXmlCompliancy(int xmlVersion)

Implements abstract com.ctc.wstx.io.BaseReader.setXmlCompliancy.

Method that can be called to indicate the xml conformance used when reading content using this reader.

Inherited from com.ctc.wstx.io.BaseReader:
canModifyBufferclosefreeBuffersgetStreamreadreadBytesreadBytesAtreportBoundsreportInvalidXml11reportStrangeStream

Field Detail

mBigEndianback to summary
protected final boolean mBigEndian
mByteCountback to summary
protected int mByteCount

Total read byte count; used for error reporting purposes

mCharCountback to summary
protected int mCharCount

Total read character count; used for error reporting purposes

mSurrogateback to summary
protected char mSurrogate

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.

mXml11back to summary
protected boolean mXml11

Constructor Detail

UTF32Readerback to summary
public UTF32Reader(ReaderConfig cfg, InputStream in, byte[] buf, int ptr, int len, boolean recycleBuffer, boolean isBigEndian)

Method Detail

loadMoreback to summary
private boolean loadMore(int available) throws IOException
Parameters
available:int

Number of "unused" bytes in the input buffer

Returns:boolean

True, if enough bytes were read to allow decoding of at least one full character; false if EOF was encountered instead.

readback to summary
public int read(char[] cbuf, int start, int len) throws IOException

Implements abstract java.io.Reader.read.

Doc from java.io.Reader.read.

Reads characters into a portion of an array. This method will block until some input is available, an I/O error occurs, or the end of the stream is reached.

If len is zero, then no characters are read and 0 is returned; otherwise, there is an attempt to read at least one character. If no character is available because the stream is at its end, the value -1 is returned; otherwise, at least one character is read and stored into cbuf.

Parameters
cbuf:char[]

Destination buffer

start:int

Offset at which to start storing characters

len:int

Maximum number of characters to read

Returns:int

The number of characters read, or -1 if the end of the stream has been reached

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
reportInvalidback to summary
private void reportInvalid(int value, int offset, String msg) throws IOException
reportUnexpectedEOFback to summary
private void reportUnexpectedEOF(int gotBytes, int needed) throws IOException
setXmlCompliancyback to summary
public void setXmlCompliancy(int xmlVersion)

Implements abstract com.ctc.wstx.io.BaseReader.setXmlCompliancy.

Doc from com.ctc.wstx.io.BaseReader.setXmlCompliancy.

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).

Annotations
@Override