Class UTF8Reader

java.lang.Object
java.io.Reader
com.fasterxml.jackson.dataformat.toml.UTF8Reader
All Implemented Interfaces:
Closeable, AutoCloseable, Readable

public final class UTF8Reader extends Reader
Optimized Reader that reads UTF-8 encoded content from an input stream. Content may come either from a static byte[] buffer or InputStream.
  • Field Details

    • _ioContext

      private final com.fasterxml.jackson.core.io.IOContext _ioContext
      IO context to use for returning input buffer, iff buffer is to be recycled when input ends.
    • _inputSource

      private InputStream _inputSource
    • _autoClose

      private final boolean _autoClose
    • _inputBuffer

      private byte[] _inputBuffer
    • _inputPtr

      private int _inputPtr
      Pointer to the next available byte (if any), iff less than mByteBufferEnd
    • _inputEnd

      private int _inputEnd
      Pointed to the end marker, that is, position one after the last valid available byte.
    • _surrogate

      private int _surrogate
      Decoded first character of a surrogate pair, if one needs to be buffered
    • _charCount

      private int _charCount
      Total read character count; used for error reporting purposes
    • _byteCount

      private int _byteCount
      Total read byte count; used for error reporting purposes
    • _tmpBuffer

      private char[] _tmpBuffer
  • Constructor Details

    • UTF8Reader

      private UTF8Reader(com.fasterxml.jackson.core.io.IOContext ctxt, InputStream in, boolean autoClose, byte[] buf, int ptr, int end)
  • Method Details

    • construct

      public static UTF8Reader construct(com.fasterxml.jackson.core.io.IOContext ctxt, InputStream in, boolean autoClose)
    • construct

      public static UTF8Reader construct(byte[] buf, int ptr, int len)
    • freeBuffers

      private void freeBuffers()
      This method should be called along with (or instead of) normal close. After calling this method, no further reads should be tried. Method will try to recycle read buffers (if any).
    • canModifyBuffer

      protected final boolean canModifyBuffer()
      Method that can be used to see if we can actually modify the underlying buffer. This is the case if we are managing the buffer, but not if it was just given to us.
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in class Reader
      Throws:
      IOException
    • read

      public int read() throws IOException
      Overrides:
      read in class Reader
      Throws:
      IOException
    • read

      public int read(char[] cbuf) throws IOException
      Overrides:
      read in class Reader
      Throws:
      IOException
    • read

      public int read(char[] cbuf, int start, int len) throws IOException
      Specified by:
      read in class Reader
      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
    • readBytes

      protected final int readBytes() throws IOException
      Throws:
      IOException
    • readBytesAt

      protected final int readBytesAt(int offset) throws IOException
      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
    • reportBounds

      protected void reportBounds(char[] cbuf, int start, int len) throws IOException
      Throws:
      IOException
    • reportStrangeStream

      protected void reportStrangeStream() throws IOException
      Throws:
      IOException