Package io.micronaut.serde
Interface Decoder
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
AbstractDecoderPerStructureStreamDecoder
,AbstractStreamDecoder
,BsonReaderDecoder
,JacksonDecoder
,JsonNodeDecoder
,JsonParserDecoder
,OracleJdbcJsonParserDecoder
Core interface for decoding values from a serialized format such as JSON.
- Since:
- 1.0.0
-
Method Summary
Modifier and TypeMethodDescriptiondefault void
close()
Finalize the current structure.createDeserializationException
(String message, Object invalidValue) Creates an exception for the given message.Decodes the current state into an arbitrary object.default Decoder
Start decoding an array.decodeArray
(io.micronaut.core.type.Argument<?> type) Start decoding an array.Decodes a BigDecimal.default BigDecimal
Equivalent todecodeNull() ? null : decodeBigDecimal()
.Decodes a BigInteger.default BigInteger
Equivalent todecodeNull() ? null : decodeBigInteger()
.boolean
Decodes a boolean.default Boolean
Equivalent todecodeNull() ? null : decodeBoolean()
.Buffer the whole subtree of this value and return it as a newDecoder
.byte
Decodes a byte.default Byte
Equivalent todecodeNull() ? null : decodeByte()
.char
Decodes a char.default Character
Equivalent todecodeNull() ? null : decodeChar()
.double
Decodes a double.default Double
Equivalent todecodeNull() ? null : decodeDouble()
.float
Decodes a float.default Float
Equivalent todecodeNull() ? null : decodeFloat()
.int
Decodes a int.default Integer
Equivalent todecodeNull() ? null : decodeInt()
.Decodes a key, if there are no more keys to decode returnsnull
.long
Decodes a long.default Long
Equivalent todecodeNull() ? null : decodeLong()
.io.micronaut.json.tree.JsonNode
Decodes the current state into aJsonNode
.boolean
Attempt to decode a null value.default Decoder
Decodes an object.decodeObject
(io.micronaut.core.type.Argument<?> type) Decodes an object.short
Decodes a short.default Short
Equivalent todecodeNull() ? null : decodeShort()
.Decodes a string.default String
Equivalent todecodeNull() ? null : decodeString()
.default void
void
finishStructure
(boolean consumeLeftElements) boolean
void
Skips the current value.
-
Method Details
-
decodeArray
Start decoding an array.- Parameters:
type
- The array type- Returns:
- The array decoder
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeArray
Start decoding an array.- Returns:
- The array decoder
- Throws:
IOException
- If an unrecoverable error occurs
-
hasNextArrayValue
- Returns:
- Returns
true
if another array value is available. - Throws:
IOException
- If an unrecoverable error occurs
-
decodeObject
Decodes an object.- Parameters:
type
- The type, nevernull
- Returns:
- The object decoder
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeObject
Decodes an object.- Returns:
- The object decoder
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeKey
Decodes a key, if there are no more keys to decode returnsnull
.- Returns:
- The key or
null
if there aren't any more keys - Throws:
IOException
- If an unrecoverable error occurs
-
decodeString
Decodes a string.- Returns:
- The string, never
null
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeStringNullable
Equivalent todecodeNull() ? null : decodeString()
.- Returns:
- The value
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeBoolean
Decodes a boolean.- Returns:
- The boolean
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeBooleanNullable
Equivalent todecodeNull() ? null : decodeBoolean()
.- Returns:
- The boolean
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeByte
Decodes a byte.- Returns:
- The byte
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeByteNullable
Equivalent todecodeNull() ? null : decodeByte()
.- Returns:
- The value
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeShort
Decodes a short.- Returns:
- The short
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeShortNullable
Equivalent todecodeNull() ? null : decodeShort()
.- Returns:
- The value
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeChar
Decodes a char.- Returns:
- The char
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeCharNullable
Equivalent todecodeNull() ? null : decodeChar()
.- Returns:
- The value
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeInt
Decodes a int.- Returns:
- The int
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeIntNullable
Equivalent todecodeNull() ? null : decodeInt()
.- Returns:
- The int
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeLong
Decodes a long.- Returns:
- The long
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeLongNullable
Equivalent todecodeNull() ? null : decodeLong()
.- Returns:
- The value
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeFloat
Decodes a float.- Returns:
- The float
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeFloatNullable
Equivalent todecodeNull() ? null : decodeFloat()
.- Returns:
- The value
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeDouble
Decodes a double.- Returns:
- The double
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeDoubleNullable
Equivalent todecodeNull() ? null : decodeDouble()
.- Returns:
- The value
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeBigInteger
Decodes a BigInteger.- Returns:
- The BigInteger, never
null
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeBigIntegerNullable
Equivalent todecodeNull() ? null : decodeBigInteger()
.- Returns:
- The value
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeBigDecimal
Decodes a BigDecimal.- Returns:
- The BigDecimal, never
null
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeBigDecimalNullable
Equivalent todecodeNull() ? null : decodeBigDecimal()
.- Returns:
- The value
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeNull
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.- Returns:
- Returns
true
if the value wasnull
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeArbitrary
Decodes the current state into an arbitrary object.The following should be decoded by this method:
- Returns:
- The decoded object
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeNode
Decodes the current state into aJsonNode
.- Returns:
- The decoded node
- Throws:
IOException
- If an unrecoverable error occurs
-
decodeBuffer
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()
.- Returns:
- An independent decoder that visits this subtree.
- Throws:
IOException
- If an unrecoverable error occurs
-
skipValue
Skips the current value.- Throws:
IOException
- If an unrecoverable error occurs
-
finishStructure
- Throws:
IllegalStateException
- If there are still elements left to consumeIOException
- If an unrecoverable error occurs
-
finishStructure
- Parameters:
consumeLeftElements
- True to consume left elements- Throws:
IllegalStateException
- If there are still elements left to consume and consumeLeftElements is falseIOException
- If an unrecoverable error occurs
-
close
Finalize the current structure. Equivalent to callingfinishStructure()
.- Specified by:
close
in interfaceAutoCloseable
- Throws:
IOException
- If an unrecoverable error occurs
-
createDeserializationException
@NonNull IOException createDeserializationException(@NonNull String message, @Nullable Object invalidValue) Creates an exception for the given message.- Parameters:
message
- The message, nevernull
invalidValue
- The invalid value. Can benull
.- Returns:
- The exception, never
null
-