Class UTF8Reader

All Implemented Interfaces:
Closeable, AutoCloseable, 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 Details

    • mXml11

      boolean mXml11
    • mSurrogate

      char mSurrogate
    • mCharCount

      int mCharCount
      Total read character count; used for error reporting purposes
    • mByteCount

      int mByteCount
      Total 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: 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 class BaseReader
    • read

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

      private void reportInvalidInitial(int mask, int offset) throws IOException
      Throws:
      IOException
    • reportInvalidOther

      private void reportInvalidOther(int mask, int offset) throws IOException
      Throws:
      IOException
    • reportUnexpectedEOF

      private void reportUnexpectedEOF(int gotBytes, int needed) throws IOException
      Throws:
      IOException
    • reportInvalid

      private void reportInvalid(int value, int offset, String msg) throws IOException
      Throws:
      IOException
    • loadMore

      private boolean loadMore(int available) throws 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:
      IOException