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 voidclose()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 DecoderStart decoding an array.decodeArray(io.micronaut.core.type.Argument<?> type) Start decoding an array.Decodes a BigDecimal.default BigDecimalEquivalent todecodeNull() ? null : decodeBigDecimal().Decodes a BigInteger.default BigIntegerEquivalent todecodeNull() ? null : decodeBigInteger().booleanDecodes a boolean.default BooleanEquivalent todecodeNull() ? null : decodeBoolean().Buffer the whole subtree of this value and return it as a newDecoder.byteDecodes a byte.default ByteEquivalent todecodeNull() ? null : decodeByte().charDecodes a char.default CharacterEquivalent todecodeNull() ? null : decodeChar().doubleDecodes a double.default DoubleEquivalent todecodeNull() ? null : decodeDouble().floatDecodes a float.default FloatEquivalent todecodeNull() ? null : decodeFloat().intDecodes a int.default IntegerEquivalent todecodeNull() ? null : decodeInt().Decodes a key, if there are no more keys to decode returnsnull.longDecodes a long.default LongEquivalent todecodeNull() ? null : decodeLong().io.micronaut.json.tree.JsonNodeDecodes the current state into aJsonNode.booleanAttempt to decode a null value.default DecoderDecodes an object.decodeObject(io.micronaut.core.type.Argument<?> type) Decodes an object.shortDecodes a short.default ShortEquivalent todecodeNull() ? null : decodeShort().Decodes a string.default StringEquivalent todecodeNull() ? null : decodeString().default voidvoidfinishStructure(boolean consumeLeftElements) booleanvoidSkips 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
trueif 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
nullif 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. Returnsfalseif this value is not null, and another method should be used for decoding. Returnstrueif this value was null, and the cursor has been advanced to the next value.- Returns:
- Returns
trueif 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 returnedDecodercan be used independently to thisDecoder. This means actual parsing of the subtree can be delayed.The returned
Decodershould 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:
closein 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, nevernullinvalidValue- The invalid value. Can benull.- Returns:
- The exception, never
null
-