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:
Closeable,AutoCloseable,Readable
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
FieldsModifier and TypeFieldDescription(package private) intTotal read byte count; used for error reporting purposes(package private) intTotal read character count; used for error reporting purposes(package private) char(package private) booleanFields 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
ConstructorsConstructorDescriptionUTF8Reader(ReaderConfig cfg, InputStream in, byte[] buf, int ptr, int len, boolean recycleBuffer) -
Method Summary
Modifier and TypeMethodDescriptionprivate booleanloadMore(int available) intread(char[] cbuf, int start, int len) private voidreportInvalid(int value, int offset, String msg) private voidreportInvalidInitial(int mask, int offset) private voidreportInvalidOther(int mask, int offset) private voidreportUnexpectedEOF(int gotBytes, int needed) voidsetXmlCompliancy(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, reportStrangeStreamMethods inherited from class java.io.Reader
mark, markSupported, nullReader, read, read, ready, reset, skip, transferTo
-
Field Details
-
mXml11
boolean mXml11 -
mSurrogate
char mSurrogate -
mCharCount
int mCharCountTotal read character count; used for error reporting purposes -
mByteCount
int mByteCountTotal read byte count; used for error reporting purposes
-
-
Constructor Details
-
UTF8Reader
public UTF8Reader(ReaderConfig cfg, InputStream in, byte[] buf, int ptr, int len, boolean recycleBuffer)
-
-
Method Details
-
setXmlCompliancy
public void setXmlCompliancy(int xmlVersion) Description copied from class:BaseReaderMethod 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:
setXmlCompliancyin classBaseReader
-
read
- Specified by:
readin classReader- Throws:
IOException
-
reportInvalidInitial
- Throws:
IOException
-
reportInvalidOther
- 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
-