Package io.micronaut.serde.jackson
Class JacksonDecoder
java.lang.Object
io.micronaut.serde.LimitingStream
io.micronaut.serde.jackson.JacksonDecoder
- All Implemented Interfaces:
Decoder
,AutoCloseable
Implementation of the
Decoder
interface for Jackson.- Author:
- Denis Stepanov
-
Nested Class Summary
Nested classes/interfaces inherited from class io.micronaut.serde.LimitingStream
LimitingStream.RemainingLimits
-
Field Summary
Fields inherited from class io.micronaut.serde.LimitingStream
DEFAULT_LIMITS, DEFAULT_MAXIMUM_DEPTH
-
Method Summary
Modifier and TypeMethodDescriptionstatic Decoder
create
(com.fasterxml.jackson.core.JsonParser parser, LimitingStream.RemainingLimits remainingLimits) createDeserializationException
(String message, Object invalidValue) Creates an exception for the given message.@Nullable Object
Decodes the current state into an arbitrary object.Start decoding an array.@NonNull JacksonDecoder
decodeArray
(io.micronaut.core.type.Argument<?> type) Start decoding an array.@NonNull BigDecimal
Decodes a BigDecimal.@Nullable BigDecimal
Equivalent todecodeNull() ? null : decodeBigDecimal()
.@NonNull BigInteger
Decodes a BigInteger.@Nullable BigInteger
Equivalent todecodeNull() ? null : decodeBigInteger()
.byte @NonNull []
Decode binary data from this stream.boolean
Decodes a boolean.@Nullable Boolean
Equivalent todecodeNull() ? null : decodeBoolean()
.Buffer the whole subtree of this value and return it as a newDecoder
.byte
Decodes a byte.@Nullable Byte
Equivalent todecodeNull() ? null : decodeByte()
.char
Decodes a char.@Nullable Character
Equivalent todecodeNull() ? null : decodeChar()
.double
Decodes a double.@Nullable Double
Equivalent todecodeNull() ? null : decodeDouble()
.float
Decodes a float.@Nullable Float
Equivalent todecodeNull() ? null : decodeFloat()
.int
Decodes a int.@Nullable Integer
Equivalent todecodeNull() ? null : decodeInt()
.@Nullable String
Decodes a key, if there are no more keys to decode returnsnull
.long
Decodes a long.@Nullable Long
Equivalent todecodeNull() ? null : decodeLong()
.@NonNull io.micronaut.json.tree.JsonNode
Decodes the current state into aJsonNode
.boolean
Attempt to decode a null value.Decodes a number.Decodes an object.@NonNull JacksonDecoder
decodeObject
(io.micronaut.core.type.Argument<?> type) Decodes an object.short
Decodes a short.@Nullable Short
Equivalent todecodeNull() ? null : decodeShort()
.@NonNull String
Decodes a string.@Nullable String
Equivalent todecodeNull() ? null : decodeString()
.void
void
finishStructure
(boolean consumeLeftElements) boolean
void
Skips the current value.Methods inherited from class io.micronaut.serde.LimitingStream
childLimits, decreaseDepth, increaseDepth, limitsFromConfiguration, ourLimits
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.micronaut.serde.Decoder
close, decodeBinaryNullable, decodeNumberNullable
-
Method Details
-
create
public static Decoder create(com.fasterxml.jackson.core.JsonParser parser, LimitingStream.RemainingLimits remainingLimits) throws IOException - Throws:
IOException
-
createDeserializationException
Description copied from interface:Decoder
Creates an exception for the given message.- Specified by:
createDeserializationException
in interfaceDecoder
- Parameters:
message
- The message, nevernull
invalidValue
- The invalid value. Can benull
.- Returns:
- The exception, never
null
-
finishStructure
- Specified by:
finishStructure
in interfaceDecoder
- Parameters:
consumeLeftElements
- True to consume left elements- Throws:
IOException
- If an unrecoverable error occurs
-
finishStructure
- Specified by:
finishStructure
in interfaceDecoder
- Throws:
IOException
- If an unrecoverable error occurs
-
hasNextArrayValue
- Specified by:
hasNextArrayValue
in interfaceDecoder
- Returns:
- Returns
true
if another array value is available. - Throws:
IOException
- If an unrecoverable error occurs
-
decodeKey
Description copied from interface:Decoder
Decodes a key, if there are no more keys to decode returnsnull
.- Specified by:
decodeKey
in interfaceDecoder
- Returns:
- The key or
null
if there aren't any more keys - Throws:
IOException
- If an unrecoverable error occurs
-
decodeArray
@NonNull public @NonNull JacksonDecoder decodeArray(io.micronaut.core.type.Argument<?> type) throws IOException Description copied from interface:Decoder
Start decoding an array.- Specified by:
decodeArray
in interfaceDecoder
- Parameters:
type
- The array type- Returns:
- The array decoder
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeArray
Description copied from interface:Decoder
Start decoding an array.- Specified by:
decodeArray
in interfaceDecoder
- Returns:
- The array decoder
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeObject
@NonNull public @NonNull JacksonDecoder decodeObject(io.micronaut.core.type.Argument<?> type) throws IOException Description copied from interface:Decoder
Decodes an object.- Specified by:
decodeObject
in interfaceDecoder
- Parameters:
type
- The type, nevernull
- Returns:
- The object decoder
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeObject
Description copied from interface:Decoder
Decodes an object.- Specified by:
decodeObject
in interfaceDecoder
- Returns:
- The object decoder
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeString
Description copied from interface:Decoder
Decodes a string.- Specified by:
decodeString
in interfaceDecoder
- Returns:
- The string, never
null
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeStringNullable
Description copied from interface:Decoder
Equivalent todecodeNull() ? null : decodeString()
.- Specified by:
decodeStringNullable
in interfaceDecoder
- Returns:
- The value
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeBoolean
Description copied from interface:Decoder
Decodes a boolean.- Specified by:
decodeBoolean
in interfaceDecoder
- Returns:
- The boolean
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeBooleanNullable
Description copied from interface:Decoder
Equivalent todecodeNull() ? null : decodeBoolean()
.- Specified by:
decodeBooleanNullable
in interfaceDecoder
- Returns:
- The boolean
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeByte
Description copied from interface:Decoder
Decodes a byte.- Specified by:
decodeByte
in interfaceDecoder
- Returns:
- The byte
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeByteNullable
Description copied from interface:Decoder
Equivalent todecodeNull() ? null : decodeByte()
.- Specified by:
decodeByteNullable
in interfaceDecoder
- Returns:
- The value
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeShort
Description copied from interface:Decoder
Decodes a short.- Specified by:
decodeShort
in interfaceDecoder
- Returns:
- The short
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeShortNullable
Description copied from interface:Decoder
Equivalent todecodeNull() ? null : decodeShort()
.- Specified by:
decodeShortNullable
in interfaceDecoder
- Returns:
- The value
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeChar
Description copied from interface:Decoder
Decodes a char.- Specified by:
decodeChar
in interfaceDecoder
- Returns:
- The char
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeCharNullable
Description copied from interface:Decoder
Equivalent todecodeNull() ? null : decodeChar()
.- Specified by:
decodeCharNullable
in interfaceDecoder
- Returns:
- The value
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeInt
Description copied from interface:Decoder
Decodes a int.- Specified by:
decodeInt
in interfaceDecoder
- Returns:
- The int
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeIntNullable
Description copied from interface:Decoder
Equivalent todecodeNull() ? null : decodeInt()
.- Specified by:
decodeIntNullable
in interfaceDecoder
- Returns:
- The int
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeLong
Description copied from interface:Decoder
Decodes a long.- Specified by:
decodeLong
in interfaceDecoder
- Returns:
- The long
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeLongNullable
Description copied from interface:Decoder
Equivalent todecodeNull() ? null : decodeLong()
.- Specified by:
decodeLongNullable
in interfaceDecoder
- Returns:
- The value
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeFloat
Description copied from interface:Decoder
Decodes a float.- Specified by:
decodeFloat
in interfaceDecoder
- Returns:
- The float
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeFloatNullable
Description copied from interface:Decoder
Equivalent todecodeNull() ? null : decodeFloat()
.- Specified by:
decodeFloatNullable
in interfaceDecoder
- Returns:
- The value
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeDouble
Description copied from interface:Decoder
Decodes a double.- Specified by:
decodeDouble
in interfaceDecoder
- Returns:
- The double
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeDoubleNullable
Description copied from interface:Decoder
Equivalent todecodeNull() ? null : decodeDouble()
.- Specified by:
decodeDoubleNullable
in interfaceDecoder
- Returns:
- The value
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeBigInteger
Description copied from interface:Decoder
Decodes a BigInteger.- Specified by:
decodeBigInteger
in interfaceDecoder
- Returns:
- The BigInteger, never
null
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeBigIntegerNullable
Description copied from interface:Decoder
Equivalent todecodeNull() ? null : decodeBigInteger()
.- Specified by:
decodeBigIntegerNullable
in interfaceDecoder
- Returns:
- The value
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeBigDecimal
Description copied from interface:Decoder
Decodes a BigDecimal.- Specified by:
decodeBigDecimal
in interfaceDecoder
- Returns:
- The BigDecimal, never
null
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeBigDecimalNullable
Description copied from interface:Decoder
Equivalent todecodeNull() ? null : decodeBigDecimal()
.- Specified by:
decodeBigDecimalNullable
in interfaceDecoder
- Returns:
- The value
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeNumber
Description copied from interface:Decoder
Decodes a number.- Specified by:
decodeNumber
in interfaceDecoder
- Returns:
- The number
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeBinary
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.
- Specified by:
decodeBinary
in interfaceDecoder
- Returns:
- The decoded byte array
- Throws:
IOException
-
decodeNull
Description copied from interface:Decoder
Attempt to decode a null value. Returnsfalse
if this value is not null, and another method should be used for decoding. Returnstrue
if this value was null, and the cursor has been advanced to the next value.- Specified by:
decodeNull
in interfaceDecoder
- Returns:
- Returns
true
if the value wasnull
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeBuffer
Description copied from interface:Decoder
Buffer the whole subtree of this value and return it as a newDecoder
. The returnedDecoder
can be used independently to thisDecoder
. This means actual parsing of the subtree can be delayed.The returned
Decoder
should behave identically to thisDecoder
. This means that for exampledecoder.decodeDouble()
should be equivalent todecoder.decodeBuffer().decodeDouble()
.- Specified by:
decodeBuffer
in interfaceDecoder
- Returns:
- An independent decoder that visits this subtree.
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeNode
Description copied from interface:Decoder
Decodes the current state into aJsonNode
.- Specified by:
decodeNode
in interfaceDecoder
- Returns:
- The decoded node
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeArbitrary
Description copied from interface:Decoder
Decodes the current state into an arbitrary object.The following should be decoded by this method:
- Specified by:
decodeArbitrary
in interfaceDecoder
- Returns:
- The decoded object
- Throws:
IOException
- If an unrecoverable error occurs
-
skipValue
Description copied from interface:Decoder
Skips the current value.- Specified by:
skipValue
in interfaceDecoder
- Throws:
IOException
- If an unrecoverable error occurs
-