Class JsonNodeDecoder

java.lang.Object
io.micronaut.serde.LimitingStream
io.micronaut.serde.support.util.JsonNodeDecoder
All Implemented Interfaces:
Decoder, AutoCloseable

@Internal public abstract sealed class JsonNodeDecoder extends LimitingStream implements Decoder
Implementation of the Decoder interface that uses the JsonNode abstraction.
  • Method Details

    • create

      public static JsonNodeDecoder create(io.micronaut.json.tree.JsonNode node, LimitingStream.RemainingLimits remainingLimits)
    • peekValue

      protected abstract io.micronaut.json.tree.JsonNode peekValue() throws IOException
      Throws:
      IOException
    • decodeArray

      public Decoder decodeArray(io.micronaut.core.type.Argument<?> type) throws IOException
      Description copied from interface: Decoder
      Start decoding an array.
      Specified by:
      decodeArray in interface Decoder
      Parameters:
      type - The array type
      Returns:
      The array decoder
      Throws:
      IOException - If an unrecoverable error occurs
    • decodeObject

      public Decoder decodeObject(io.micronaut.core.type.Argument<?> type) throws IOException
      Description copied from interface: Decoder
      Decodes an object.
      Specified by:
      decodeObject in interface Decoder
      Parameters:
      type - The type, never null
      Returns:
      The object decoder
      Throws:
      IOException - If an unrecoverable error occurs
    • decodeString

      public String decodeString() throws IOException
      Description copied from interface: Decoder
      Decodes a string.
      Specified by:
      decodeString in interface Decoder
      Returns:
      The string, never null
      Throws:
      IOException - If an unrecoverable error occurs
    • decodeBoolean

      public boolean decodeBoolean() throws IOException
      Description copied from interface: Decoder
      Decodes a boolean.
      Specified by:
      decodeBoolean in interface Decoder
      Returns:
      The boolean
      Throws:
      IOException - If an unrecoverable error occurs
    • decodeByte

      public byte decodeByte() throws IOException
      Description copied from interface: Decoder
      Decodes a byte.
      Specified by:
      decodeByte in interface Decoder
      Returns:
      The byte
      Throws:
      IOException - If an unrecoverable error occurs
    • decodeShort

      public short decodeShort() throws IOException
      Description copied from interface: Decoder
      Decodes a short.
      Specified by:
      decodeShort in interface Decoder
      Returns:
      The short
      Throws:
      IOException - If an unrecoverable error occurs
    • decodeChar

      public char decodeChar() throws IOException
      Description copied from interface: Decoder
      Decodes a char.
      Specified by:
      decodeChar in interface Decoder
      Returns:
      The char
      Throws:
      IOException - If an unrecoverable error occurs
    • decodeInt

      public int decodeInt() throws IOException
      Description copied from interface: Decoder
      Decodes a int.
      Specified by:
      decodeInt in interface Decoder
      Returns:
      The int
      Throws:
      IOException - If an unrecoverable error occurs
    • decodeLong

      public long decodeLong() throws IOException
      Description copied from interface: Decoder
      Decodes a long.
      Specified by:
      decodeLong in interface Decoder
      Returns:
      The long
      Throws:
      IOException - If an unrecoverable error occurs
    • decodeFloat

      public float decodeFloat() throws IOException
      Description copied from interface: Decoder
      Decodes a float.
      Specified by:
      decodeFloat in interface Decoder
      Returns:
      The float
      Throws:
      IOException - If an unrecoverable error occurs
    • decodeDouble

      public double decodeDouble() throws IOException
      Description copied from interface: Decoder
      Decodes a double.
      Specified by:
      decodeDouble in interface Decoder
      Returns:
      The double
      Throws:
      IOException - If an unrecoverable error occurs
    • decodeBigInteger

      public BigInteger decodeBigInteger() throws IOException
      Description copied from interface: Decoder
      Decodes a BigInteger.
      Specified by:
      decodeBigInteger in interface Decoder
      Returns:
      The BigInteger, never null
      Throws:
      IOException - If an unrecoverable error occurs
    • decodeBigDecimal

      public BigDecimal decodeBigDecimal() throws IOException
      Description copied from interface: Decoder
      Decodes a BigDecimal.
      Specified by:
      decodeBigDecimal in interface Decoder
      Returns:
      The BigDecimal, never null
      Throws:
      IOException - If an unrecoverable error occurs
    • decodeBinary

      public byte @NonNull [] decodeBinary() throws IOException
      Description copied from interface: Decoder
      Decode binary data from this stream. Binary data can be serialized in multiple different ways that differ by format.
      • An array of numbers must be supported by all implementations, for compatibility. This is also the default implementation.
      • A base64 string. This is convenient for text-based formats like json, and is supported by jackson.
      • A format-specific type, for binary formats such as bson.
      • Other format specific behavior. Oracle JDBC Json will parse strings as hex, for example.
      Implementations must support the array shape, but the other shapes are optional.
      Specified by:
      decodeBinary in interface Decoder
      Returns:
      The decoded byte array
      Throws:
      IOException
    • decodeNull

      public boolean decodeNull() throws IOException
      Description copied from interface: Decoder
      Attempt to decode a null value. Returns false if this value is not null, and another method should be used for decoding. Returns true if this value was null, and the cursor has been advanced to the next value.
      Specified by:
      decodeNull in interface Decoder
      Returns:
      Returns true if the value was null
      Throws:
      IOException - If an unrecoverable error occurs
    • decodeArbitrary

      public Object decodeArbitrary() throws IOException
      Description copied from interface: Decoder
      Decodes the current state into an arbitrary object.

      The following should be decoded by this method:

      • Object types will be decoded into a Map
      • Array types will be decoded into a List
      • JSON primitive types into the equivalent Java wrapper type
      Specified by:
      decodeArbitrary in interface Decoder
      Returns:
      The decoded object
      Throws:
      IOException - If an unrecoverable error occurs
    • decodeNode

      @NonNull public @NonNull io.micronaut.json.tree.JsonNode decodeNode() throws IOException
      Description copied from interface: Decoder
      Decodes the current state into a JsonNode.
      Specified by:
      decodeNode in interface Decoder
      Returns:
      The decoded node
      Throws:
      IOException - If an unrecoverable error occurs
    • decodeBuffer

      public Decoder decodeBuffer() throws IOException
      Description copied from interface: Decoder
      Buffer the whole subtree of this value and return it as a new Decoder. The returned Decoder can be used independently to this Decoder. This means actual parsing of the subtree can be delayed.

      The returned Decoder should behave identically to this Decoder. This means that for example decoder.decodeDouble() should be equivalent to decoder.decodeBuffer().decodeDouble().

      Specified by:
      decodeBuffer in interface Decoder
      Returns:
      An independent decoder that visits this subtree.
      Throws:
      IOException - If an unrecoverable error occurs
    • createDeserializationException

      public IOException createDeserializationException(String message, Object invalidValue)
      Description copied from interface: Decoder
      Creates an exception for the given message.
      Specified by:
      createDeserializationException in interface Decoder
      Parameters:
      message - The message, never null
      invalidValue - The invalid value. Can be null.
      Returns:
      The exception, never null