Class UTF8Reader

java.lang.Object
java.io.Reader
com.fasterxml.jackson.dataformat.csv.impl.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. 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 underlying character encoding.
  • Field Summary

    Fields inherited from class java.io.Reader

    lock
  • Constructor Summary

    Constructors
    Constructor
    Description
    UTF8Reader(com.fasterxml.jackson.core.io.IOContext ctxt, byte[] buf, int ptr, int len)
     
    UTF8Reader(com.fasterxml.jackson.core.io.IOContext ctxt, InputStream in, boolean autoClose)
     
    UTF8Reader(com.fasterxml.jackson.core.io.IOContext ctxt, InputStream in, boolean autoClose, byte[] buf, int ptr, int len)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected final boolean
    Method that can be used to see if we can actually modify the underlying buffer.
    void
     
    final void
    This method should be called along with (or instead of) normal close.
    protected final InputStream
     
    int
    Although this method is implemented by the base class, AND it should never be called by parser code, let's still implement it bit more efficiently just in case
    int
    read(char[] cbuf)
     
    int
    read(char[] cbuf, int start, int len)
     
    protected final int
    Method for reading as many bytes from the underlying stream as possible (that fit in the buffer), to the beginning of the buffer.
    protected final int
    readBytesAt(int offset)
    Method for reading as many bytes from the underlying stream as possible (that fit in the buffer considering offset), to the specified offset.
    protected void
    reportBounds(char[] cbuf, int start, int len)
     
    protected void
     
    protected void
    reportInvalidInitial(int mask, int outputDecoded)
     
    protected void
    reportInvalidOther(int mask, int outputDecoded, int errorPosition)
     
    protected void
     
    protected void
    reportUnexpectedEOF(int gotBytes, int needed)
     

    Methods inherited from class java.io.Reader

    mark, markSupported, nullReader, read, ready, reset, skip, transferTo

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • UTF8Reader

      public UTF8Reader(com.fasterxml.jackson.core.io.IOContext ctxt, InputStream in, boolean autoClose, byte[] buf, int ptr, int len)
    • UTF8Reader

      public UTF8Reader(com.fasterxml.jackson.core.io.IOContext ctxt, byte[] buf, int ptr, int len)
    • UTF8Reader

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

    • 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
      Although this method is implemented by the base class, AND it should never be called by parser code, let's still implement it bit more efficiently just in case
      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
    • getStream

      protected final InputStream getStream()
    • readBytes

      protected final int readBytes() throws IOException
      Method for reading as many bytes from the underlying stream as possible (that fit in the buffer), to the beginning of the buffer.
      Throws:
      IOException
    • readBytesAt

      protected final int readBytesAt(int offset) throws IOException
      Method for reading as many bytes from the underlying stream as possible (that fit in the buffer considering offset), to the specified offset.
      Returns:
      Number of bytes read, if any; -1 to indicate none available (that is, end of input)
      Throws:
      IOException
    • freeBuffers

      public final 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).
    • reportBounds

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

      protected void reportStrangeStream() throws IOException
      Throws:
      IOException
    • reportInvalidInitial

      protected void reportInvalidInitial(int mask, int outputDecoded) throws IOException
      Throws:
      IOException
    • reportInvalidOther

      protected void reportInvalidOther(int mask, int outputDecoded, int errorPosition) throws IOException
      Throws:
      IOException
    • reportDeferredInvalid

      protected void reportDeferredInvalid() throws IOException
      Throws:
      IOException
    • reportUnexpectedEOF

      protected void reportUnexpectedEOF(int gotBytes, int needed) throws IOException
      Throws:
      IOException