Package com.ctc.wstx.io
Class UTF8Reader
- java.lang.Object
-
- java.io.Reader
-
- com.ctc.wstx.io.BaseReader
-
- com.ctc.wstx.io.UTF8Reader
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,java.lang.Readable
public final class UTF8Reader extends BaseReader
Optimized Reader that reads UTF-8 encoded content from an input stream. In addition to doing (hopefully) optimal conversion, it can also take array of "pre-read" (leftover) bytes; this is necessary when preliminary stream/reader is trying to figure out XML encoding.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) int
mByteCount
Total read byte count; used for error reporting purposes(package private) int
mCharCount
Total read character count; used for error reporting purposes(package private) char
mSurrogate
(package private) boolean
mXml11
-
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
Constructors Constructor Description UTF8Reader(ReaderConfig cfg, java.io.InputStream in, byte[] buf, int ptr, int len, boolean recycleBuffer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private boolean
loadMore(int available)
int
read(char[] cbuf, int start, int len)
private void
reportInvalid(int value, int offset, java.lang.String msg)
private void
reportInvalidInitial(int mask, int offset)
private void
reportInvalidOther(int mask, int offset)
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
-
-
-
-
Constructor Detail
-
UTF8Reader
public UTF8Reader(ReaderConfig cfg, java.io.InputStream in, byte[] buf, int ptr, int len, boolean recycleBuffer)
-
-
Method Detail
-
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
public int read(char[] cbuf, int start, int len) throws java.io.IOException
- Specified by:
read
in classjava.io.Reader
- Throws:
java.io.IOException
-
reportInvalidInitial
private void reportInvalidInitial(int mask, int offset) throws java.io.IOException
- Throws:
java.io.IOException
-
reportInvalidOther
private void reportInvalidOther(int mask, int offset) throws java.io.IOException
- Throws:
java.io.IOException
-
reportUnexpectedEOF
private void reportUnexpectedEOF(int gotBytes, int needed) throws java.io.IOException
- Throws:
java.io.IOException
-
reportInvalid
private void reportInvalid(int value, int offset, java.lang.String msg) throws java.io.IOException
- Throws:
java.io.IOException
-
loadMore
private boolean loadMore(int available) throws java.io.IOException
- 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:
java.io.IOException
-
-