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
ADocumentReaderandArrayReaderthat uses the Jackson library to read JSON.- Author:
- Randall Hauch
-
-
Field Summary
Fields Modifier and Type Field Description static JacksonReaderDEFAULT_INSTANCEprivate static com.fasterxml.jackson.core.JsonFactoryfactorystatic JacksonReaderFLOAT_NUMBERS_AS_TEXT_INSTANCEprivate booleanhandleFloatNumbersAsText
-
Constructor Summary
Constructors Modifier Constructor Description privateJacksonReader(boolean handleFloatNumbersAsText)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private Documentparse(com.fasterxml.jackson.core.JsonParser parser)private ArrayparseArray(com.fasterxml.jackson.core.JsonParser parser, boolean nested)private DocumentparseDocument(com.fasterxml.jackson.core.JsonParser parser, boolean nested)Documentread(byte[] rawBytes)Read a document from the supplied bytes.Documentread(File jsonFile)Read a document from the supplied file.Documentread(InputStream jsonStream)Read a document from the supplied stream.Documentread(Reader jsonReader)Read a document from the suppliedReader.Documentread(String json)Read a document from the supplied JSON-formatted string.Documentread(URL jsonUrl)Read a document from the content at the given URL.ArrayreadArray(File jsonFile)Read an array from the supplied file.ArrayreadArray(InputStream jsonStream)Read an array from the supplied stream.ArrayreadArray(Reader jsonReader)Read an array from the suppliedReader.ArrayreadArray(String jsonArray)Read an array from the supplied JSON-formatted string.ArrayreadArray(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:DocumentReaderRead a document from the supplied stream.- Specified by:
readin 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:DocumentReaderRead a document from the suppliedReader.- Specified by:
readin 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:DocumentReaderRead a document from the supplied JSON-formatted string.- Specified by:
readin 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:DocumentReaderRead a document from the supplied file.- Specified by:
readin 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:DocumentReaderRead a document from the content at the given URL.- Specified by:
readin 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:DocumentReaderRead a document from the supplied bytes.- Specified by:
readin 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:ArrayReaderRead an array from the supplied stream.- Specified by:
readArrayin 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:ArrayReaderRead an array from the suppliedReader.- Specified by:
readArrayin 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:ArrayReaderRead an array from the content at the given URL.- Specified by:
readArrayin 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:ArrayReaderRead an array from the supplied file.- Specified by:
readArrayin 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:ArrayReaderRead an array from the supplied JSON-formatted string.- Specified by:
readArrayin 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
-
-