Package io.debezium.document
Class JacksonReader
- java.lang.Object
-
- io.debezium.document.JacksonReader
-
- All Implemented Interfaces:
ArrayReader
,DocumentReader
@ThreadSafe final class JacksonReader extends Object implements DocumentReader, ArrayReader
ADocumentReader
andArrayReader
that uses the Jackson library to read JSON.- Author:
- Randall Hauch
-
-
Field Summary
Fields Modifier and Type Field Description static JacksonReader
DEFAULT_INSTANCE
private static com.fasterxml.jackson.core.JsonFactory
factory
static JacksonReader
FLOAT_NUMBERS_AS_TEXT_INSTANCE
private boolean
handleFloatNumbersAsText
-
Constructor Summary
Constructors Modifier Constructor Description private
JacksonReader(boolean handleFloatNumbersAsText)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private Document
parse(com.fasterxml.jackson.core.JsonParser parser)
private Array
parseArray(com.fasterxml.jackson.core.JsonParser parser, boolean nested)
private Document
parseDocument(com.fasterxml.jackson.core.JsonParser parser, boolean nested)
Document
read(byte[] rawBytes)
Read a document from the supplied bytes.Document
read(File jsonFile)
Read a document from the supplied file.Document
read(InputStream jsonStream)
Read a document from the supplied stream.Document
read(Reader jsonReader)
Read a document from the suppliedReader
.Document
read(String json)
Read a document from the supplied JSON-formatted string.Document
read(URL jsonUrl)
Read a document from the content at the given URL.Array
readArray(File jsonFile)
Read an array from the supplied file.Array
readArray(InputStream jsonStream)
Read an array from the supplied stream.Array
readArray(Reader jsonReader)
Read an array from the suppliedReader
.Array
readArray(String jsonArray)
Read an array from the supplied JSON-formatted string.Array
readArray(URL jsonUrl)
Read an array from the content at the given URL.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.debezium.document.ArrayReader
readArray
-
-
-
-
Field Detail
-
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
-
-
Method Detail
-
read
public Document read(InputStream jsonStream) throws IOException
Description copied from interface:DocumentReader
Read a document from the supplied stream.- Specified by:
read
in interfaceDocumentReader
- 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 suppliedReader
.- Specified by:
read
in interfaceDocumentReader
- 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 interfaceDocumentReader
- 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 interfaceDocumentReader
- 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 interfaceDocumentReader
- 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 interfaceDocumentReader
- 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 interfaceArrayReader
- 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 suppliedReader
.- Specified by:
readArray
in interfaceArrayReader
- 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 interfaceArrayReader
- 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 interfaceArrayReader
- 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 interfaceArrayReader
- 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
-
-