Class OracleJdbcJsonBinaryObjectMapper

java.lang.Object
io.micronaut.serde.oracle.jdbc.json.OracleJdbcJsonBinaryObjectMapper
All Implemented Interfaces:
io.micronaut.json.JsonMapper, ObjectMapper

@Singleton @Order(200) public final class OracleJdbcJsonBinaryObjectMapper extends Object
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
  • Field Details

    • registry

      protected final SerdeRegistry registry
    • serdeConfiguration

      protected final @Nullable SerdeConfiguration serdeConfiguration
    • view

      protected final @Nullable Class<?> view
    • oracleJsonFactory

      protected final oracle.sql.json.OracleJsonFactory oracleJsonFactory
  • Constructor Details

    • OracleJdbcJsonBinaryObjectMapper

      @Internal @Inject public OracleJdbcJsonBinaryObjectMapper(SerdeRegistry registry, SerdeConfiguration serdeConfiguration)
  • Method Details

    • cloneWithViewClass

      public io.micronaut.json.JsonMapper cloneWithViewClass(Class<?> viewClass)
    • 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. The OracleJsonValue tree types are read with the OracleJsonParser instead, as the native decoder has no tree.
      Specified by:
      readValue in interface io.micronaut.json.JsonMapper
      Type Parameters:
      T - the type
      Parameters:
      byteArray - the OSON document
      type - 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 with resultSet.getObject(column, OracleJsonDatum.class).
      Type Parameters:
      T - the type
      Parameters:
      datum - the column value
      type - 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 array
      offset - the offset of the document
      length - the length of the document
      type - the type to read
      Returns:
      the value
      Throws:
      IOException - if the document cannot be decoded
      Since:
      3.3.0
    • getSerdeRegistry

      public SerdeRegistry getSerdeRegistry()
      Description copied from interface: ObjectMapper
      Returns the SerdeRegistry used by this object mapper, if possible.
      Specified by:
      getSerdeRegistry in interface ObjectMapper
      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:
      readValueFromTree in interface io.micronaut.json.JsonMapper
      Throws:
      IOException
    • readValue

      public <T> @Nullable T readValue(InputStream inputStream, io.micronaut.core.type.Argument<T> type) throws IOException
      Specified by:
      readValue in interface io.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 parser
      type - 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:
      createReactiveParser in interface io.micronaut.json.JsonMapper
    • writeValueToTree

      public io.micronaut.json.tree.JsonNode writeValueToTree(@Nullable Object value) throws IOException
      Specified by:
      writeValueToTree in interface io.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:
      writeValueToTree in interface io.micronaut.json.JsonMapper
      Throws:
      IOException
    • writeValue

      public void writeValue(OutputStream outputStream, @Nullable Object object) throws IOException
      Specified by:
      writeValue in interface io.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:
      writeValue in interface io.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 generator
      value - The value
      type - The argument
      Throws:
      IOException
    • writeValueAsBytes

      public byte[] writeValueAsBytes(@Nullable Object object) throws IOException
      Specified by:
      writeValueAsBytes in interface io.micronaut.json.JsonMapper
      Throws:
      IOException
    • writeValueAsBytes

      public <T> byte[] writeValueAsBytes(io.micronaut.core.type.Argument<T> type, @Nullable T object) throws IOException
      Specified by:
      writeValueAsBytes in interface io.micronaut.json.JsonMapper
      Throws:
      IOException
    • getStreamConfig

      public io.micronaut.json.JsonStreamConfig getStreamConfig()
      Specified by:
      getStreamConfig in interface io.micronaut.json.JsonMapper