Class OracleJdbcJsonBinaryObjectMapper
java.lang.Object
io.micronaut.serde.oracle.jdbc.json.OracleJdbcJsonBinaryObjectMapper
- All Implemented Interfaces:
io.micronaut.json.JsonMapper, ObjectMapper
Implementation of the
JsonMapper interface for Oracle JDBC Binary JSON (OSON).
Documents given as bytes are decoded by the native OracleOsonDecoder, which reads the encoded form in
place; readValue(OracleJsonDatum, Argument) does the same over the bytes the JDBC driver already
holds for a JSON column. The OracleJsonParser path stays in use for streams, for the
OracleJsonValue tree types and through readValue(OracleJsonParser, Argument).
- Since:
- 1.2.0
- Author:
- Denis Stepanov
-
Nested Class Summary
Nested classes/interfaces inherited from interface ObjectMapper
ObjectMapper.CloseableObjectMapper -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final oracle.sql.json.OracleJsonFactoryprotected final SerdeRegistryprotected final @Nullable SerdeConfigurationprotected final @Nullable Class<?> -
Constructor Summary
ConstructorsConstructorDescriptionOracleJdbcJsonBinaryObjectMapper(SerdeRegistry registry, SerdeConfiguration serdeConfiguration) -
Method Summary
Modifier and TypeMethodDescriptionio.micronaut.json.JsonMappercloneWithViewClass(Class<?> viewClass) org.reactivestreams.Processor<byte[], io.micronaut.json.tree.JsonNode> createReactiveParser(Consumer<org.reactivestreams.Processor<byte[], io.micronaut.json.tree.JsonNode>> onSubscribe, boolean streamArray) Returns theSerdeRegistryused by this object mapper, if possible.io.micronaut.json.JsonStreamConfig<T> @Nullable TreadValue(byte[] byteArray, int offset, int length, io.micronaut.core.type.Argument<T> type) Reads an OSON document held in a slice of an array with the native decoder.<T> @Nullable TreadValue(byte[] byteArray, io.micronaut.core.type.Argument<T> type) Reads an OSON document with the native decoder.<T> @Nullable TreadValue(InputStream inputStream, io.micronaut.core.type.Argument<T> type) <T> @Nullable TreadValue(oracle.sql.json.OracleJsonDatum datum, io.micronaut.core.type.Argument<T> type) Reads a JSON column value with the native decoder, straight over the bytes the driver holds; obtain the datum withresultSet.getObject(column, OracleJsonDatum.class).<T> @Nullable TreadValue(oracle.sql.json.OracleJsonParser parser, io.micronaut.core.type.Argument<T> type) Read the value using the oracle parser.<T> @Nullable TreadValueFromTree(io.micronaut.json.tree.JsonNode tree, io.micronaut.core.type.Argument<T> type) <T> voidwriteValue(OutputStream outputStream, io.micronaut.core.type.Argument<T> type, @Nullable T object) voidwriteValue(OutputStream outputStream, @Nullable Object object) <T> voidwriteValue(oracle.sql.json.OracleJsonGenerator generator, @Nullable T value, io.micronaut.core.type.Argument<T> type) Writes the value to the json generator.<T> byte[]writeValueAsBytes(io.micronaut.core.type.Argument<T> type, @Nullable T object) byte[]writeValueAsBytes(@Nullable Object object) <T> io.micronaut.json.tree.JsonNodewriteValueToTree(io.micronaut.core.type.Argument<T> type, @Nullable T value) io.micronaut.json.tree.JsonNodewriteValueToTree(@Nullable Object value) Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.micronaut.json.JsonMapper
createSpecific, detectFeatures, readValue, readValue, readValue, readValue, readValue, readValue, readValueFromTree, updateValueFromTree, writeValueAsString, writeValueAsString, writeValueAsStringMethods inherited from interface ObjectMapper
cloneWithConfiguration, cloneWithConfiguration, cloneWithFeatures, updateValue, updateValue, updateValue, updateValue, updateValue
-
Field Details
-
registry
-
serdeConfiguration
-
view
-
oracleJsonFactory
protected final oracle.sql.json.OracleJsonFactory oracleJsonFactory
-
-
Constructor Details
-
OracleJdbcJsonBinaryObjectMapper
@Internal @Inject public OracleJdbcJsonBinaryObjectMapper(SerdeRegistry registry, SerdeConfiguration serdeConfiguration)
-
-
Method Details
-
cloneWithViewClass
-
readValue
public <T> @Nullable T readValue(byte[] byteArray, io.micronaut.core.type.Argument<T> type) throws IOException Reads an OSON document with the native decoder. TheOracleJsonValuetree types are read with theOracleJsonParserinstead, as the native decoder has no tree.- Specified by:
readValuein interfaceio.micronaut.json.JsonMapper- Type Parameters:
T- the type- Parameters:
byteArray- the OSON documenttype- the type to read- Returns:
- the value
- Throws:
IOException- if the document cannot be decoded
-
readValue
public <T> @Nullable T readValue(oracle.sql.json.OracleJsonDatum datum, io.micronaut.core.type.Argument<T> type) throws IOException Reads a JSON column value with the native decoder, straight over the bytes the driver holds; obtain the datum withresultSet.getObject(column, OracleJsonDatum.class).- Type Parameters:
T- the type- Parameters:
datum- the column valuetype- the type to read- Returns:
- the value
- Throws:
IOException- if the document cannot be decoded- Since:
- 3.3.0
-
readValue
public <T> @Nullable T readValue(byte[] byteArray, int offset, int length, io.micronaut.core.type.Argument<T> type) throws IOException Reads an OSON document held in a slice of an array with the native decoder.- Type Parameters:
T- the type- Parameters:
byteArray- the arrayoffset- the offset of the documentlength- the length of the documenttype- the type to read- Returns:
- the value
- Throws:
IOException- if the document cannot be decoded- Since:
- 3.3.0
-
getSerdeRegistry
Description copied from interface:ObjectMapperReturns theSerdeRegistryused by this object mapper, if possible.- Specified by:
getSerdeRegistryin interfaceObjectMapper- Returns:
- The serde registry
-
readValueFromTree
public <T> @Nullable T readValueFromTree(io.micronaut.json.tree.JsonNode tree, io.micronaut.core.type.Argument<T> type) throws IOException - Specified by:
readValueFromTreein interfaceio.micronaut.json.JsonMapper- Throws:
IOException
-
readValue
public <T> @Nullable T readValue(InputStream inputStream, io.micronaut.core.type.Argument<T> type) throws IOException - Specified by:
readValuein interfaceio.micronaut.json.JsonMapper- Throws:
IOException
-
readValue
public <T> @Nullable T readValue(oracle.sql.json.OracleJsonParser parser, io.micronaut.core.type.Argument<T> type) throws IOException Read the value using the oracle parser.- Type Parameters:
T- The type- Parameters:
parser- The parsertype- The argument- Returns:
- The value
- Throws:
IOException
-
createReactiveParser
public org.reactivestreams.Processor<byte[], io.micronaut.json.tree.JsonNode> createReactiveParser(Consumer<org.reactivestreams.Processor<byte[], io.micronaut.json.tree.JsonNode>> onSubscribe, boolean streamArray) - Specified by:
createReactiveParserin interfaceio.micronaut.json.JsonMapper
-
writeValueToTree
- Specified by:
writeValueToTreein interfaceio.micronaut.json.JsonMapper- Throws:
IOException
-
writeValueToTree
public <T> io.micronaut.json.tree.JsonNode writeValueToTree(io.micronaut.core.type.Argument<T> type, @Nullable T value) throws IOException - Specified by:
writeValueToTreein interfaceio.micronaut.json.JsonMapper- Throws:
IOException
-
writeValue
- Specified by:
writeValuein interfaceio.micronaut.json.JsonMapper- Throws:
IOException
-
writeValue
public <T> void writeValue(OutputStream outputStream, io.micronaut.core.type.Argument<T> type, @Nullable T object) throws IOException - Specified by:
writeValuein interfaceio.micronaut.json.JsonMapper- Throws:
IOException
-
writeValue
public <T> void writeValue(oracle.sql.json.OracleJsonGenerator generator, @Nullable T value, io.micronaut.core.type.Argument<T> type) throws IOException Writes the value to the json generator.- Type Parameters:
T- The type- Parameters:
generator- The generatorvalue- The valuetype- The argument- Throws:
IOException
-
writeValueAsBytes
- Specified by:
writeValueAsBytesin interfaceio.micronaut.json.JsonMapper- Throws:
IOException
-
writeValueAsBytes
public <T> byte[] writeValueAsBytes(io.micronaut.core.type.Argument<T> type, @Nullable T object) throws IOException - Specified by:
writeValueAsBytesin interfaceio.micronaut.json.JsonMapper- Throws:
IOException
-
getStreamConfig
public io.micronaut.json.JsonStreamConfig getStreamConfig()- Specified by:
getStreamConfigin interfaceio.micronaut.json.JsonMapper
-