Class JacksonReader

java.lang.Object
io.debezium.document.JacksonReader
All Implemented Interfaces:
ArrayReader, DocumentReader

@ThreadSafe final class JacksonReader extends Object implements DocumentReader, ArrayReader
A DocumentReader and ArrayReader that uses the Jackson library to read JSON.
Author:
Randall Hauch
  • Field Details

    • DEFAULT_INSTANCE

      public static final JacksonReader DEFAULT_INSTANCE
    • FLOAT_NUMBERS_AS_TEXT_INSTANCE

      public static final JacksonReader FLOAT_NUMBERS_AS_TEXT_INSTANCE
    • factory

      private static final com.fasterxml.jackson.core.JsonFactory factory
    • handleFloatNumbersAsText

      private final boolean handleFloatNumbersAsText
  • Constructor Details

    • JacksonReader

      private JacksonReader(boolean handleFloatNumbersAsText)
  • Method Details

    • read

      public Document read(InputStream jsonStream) throws IOException
      Description copied from interface: DocumentReader
      Read a document from the supplied stream.
      Specified by:
      read in interface DocumentReader
      Parameters:
      jsonStream - the input stream to be read; may not be null
      Returns:
      the document instance; never null
      Throws:
      IOException - if a document could not be read from the supplied stream
    • read

      public Document read(Reader jsonReader) throws IOException
      Description copied from interface: DocumentReader
      Read a document from the supplied Reader.
      Specified by:
      read in interface DocumentReader
      Parameters:
      jsonReader - the reader to be read; may not be null
      Returns:
      the document instance; never null
      Throws:
      IOException - if a document could not be read from the supplied reader
    • read

      public Document read(String json) throws IOException
      Description copied from interface: DocumentReader
      Read a document from the supplied JSON-formatted string.
      Specified by:
      read in interface DocumentReader
      Parameters:
      json - the JSON string representation to be read; may not be null
      Returns:
      the document instance; never null
      Throws:
      IOException - if a document could not be read from the supplied string
    • read

      public Document read(File jsonFile) throws IOException
      Description copied from interface: DocumentReader
      Read a document from the supplied file.
      Specified by:
      read in interface DocumentReader
      Parameters:
      jsonFile - the file to be read; may not be null
      Returns:
      the document instance; never null
      Throws:
      IOException - if a document could not be read from the supplied file
    • read

      public Document read(URL jsonUrl) throws IOException
      Description copied from interface: DocumentReader
      Read a document from the content at the given URL.
      Specified by:
      read in interface DocumentReader
      Parameters:
      jsonUrl - the URL to the content that is to be read; may not be null
      Returns:
      the document instance; never null
      Throws:
      IOException - if a document could not be read from the supplied content
    • read

      public Document read(byte[] rawBytes) throws IOException
      Description copied from interface: DocumentReader
      Read a document from the supplied bytes.
      Specified by:
      read in interface DocumentReader
      Parameters:
      rawBytes - the UTF-8 bytes to be read; may not be null
      Returns:
      the document instance; never null
      Throws:
      IOException - if a document could not be read from the supplied bytes
    • readArray

      public Array readArray(InputStream jsonStream) throws IOException
      Description copied from interface: ArrayReader
      Read an array from the supplied stream.
      Specified by:
      readArray in interface ArrayReader
      Parameters:
      jsonStream - the input stream to be read; may not be null
      Returns:
      the array instance; never null
      Throws:
      IOException - if an array could not be read from the supplied stream
    • readArray

      public Array readArray(Reader jsonReader) throws IOException
      Description copied from interface: ArrayReader
      Read an array from the supplied Reader.
      Specified by:
      readArray in interface ArrayReader
      Parameters:
      jsonReader - the reader to be read; may not be null
      Returns:
      the array instance; never null
      Throws:
      IOException - if an array could not be read from the supplied reader
    • readArray

      public Array readArray(URL jsonUrl) throws IOException
      Description copied from interface: ArrayReader
      Read an array from the content at the given URL.
      Specified by:
      readArray in interface ArrayReader
      Parameters:
      jsonUrl - the URL to the content that is to be read; may not be null
      Returns:
      the array instance; never null
      Throws:
      IOException - if an array could not be read from the supplied content
    • readArray

      public Array readArray(File jsonFile) throws IOException
      Description copied from interface: ArrayReader
      Read an array from the supplied file.
      Specified by:
      readArray in interface ArrayReader
      Parameters:
      jsonFile - the file to be read; may not be null
      Returns:
      the array instance; never null
      Throws:
      IOException - if an array could not be read from the supplied file
    • readArray

      public Array readArray(String jsonArray) throws IOException
      Description copied from interface: ArrayReader
      Read an array from the supplied JSON-formatted string.
      Specified by:
      readArray in interface ArrayReader
      Parameters:
      jsonArray - the JSON string representation to be read; may not be null
      Returns:
      the array instance; never null
      Throws:
      IOException - if an array could not be read from the supplied string
    • parse

      private Document parse(com.fasterxml.jackson.core.JsonParser parser) throws IOException
      Throws:
      IOException
    • parseDocument

      private Document parseDocument(com.fasterxml.jackson.core.JsonParser parser, boolean nested) throws IOException
      Throws:
      IOException
    • parseArray

      private Array parseArray(com.fasterxml.jackson.core.JsonParser parser, boolean nested) throws IOException
      Throws:
      IOException