Package io.micronaut.serde
Class DelegatingDecoder
java.lang.Object
io.micronaut.serde.DelegatingDecoder
- All Implemented Interfaces:
Decoder,AutoCloseable
Decoder that delegates to another decoder.
- Since:
- 2.3.0
- Author:
- Jonas Konrad
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Finalize the current structure.abstract @NonNull IOExceptioncreateDeserializationException(@NonNull String message, @Nullable Object invalidValue) This method remains abstract because it doesn't throw IOException and thus can't call decoder().@Nullable ObjectDecodes the current state into an arbitrary object.@NonNull DecoderStart decoding an array.@NonNull DecoderdecodeArray(io.micronaut.core.type.Argument<?> type) Start decoding an array.@NonNull BigDecimalDecodes a BigDecimal.@Nullable BigDecimalEquivalent todecodeNull() ? null : decodeBigDecimal().@NonNull BigIntegerDecodes a BigInteger.@Nullable BigIntegerEquivalent todecodeNull() ? null : decodeBigInteger().byte @NonNull []Decode binary data from this stream.byte @Nullable []Equivalent todecodeNull() ? null : decodeBinary().booleanDecodes a boolean.@Nullable BooleanEquivalent todecodeNull() ? null : decodeBoolean().Buffer the whole subtree of this value and return it as a newDecoder.byteDecodes a byte.@Nullable ByteEquivalent todecodeNull() ? null : decodeByte().charDecodes a char.@Nullable CharacterEquivalent todecodeNull() ? null : decodeChar().doubleDecodes a double.@Nullable DoubleEquivalent todecodeNull() ? null : decodeDouble().floatDecodes a float.@Nullable FloatEquivalent todecodeNull() ? null : decodeFloat().intDecodes a int.@Nullable IntegerEquivalent todecodeNull() ? null : decodeInt().@Nullable StringDecodes a key, if there are no more keys to decode returnsnull.longDecodes a long.@Nullable LongEquivalent todecodeNull() ? null : decodeLong().@NonNull io.micronaut.json.tree.JsonNodeDecodes the current state into aJsonNode.booleanAttempt to decode a null value.@NonNull DecoderDecodes an object.@NonNull DecoderdecodeObject(@NonNull io.micronaut.core.type.Argument<?> type) Decodes an object.shortDecodes a short.@Nullable ShortEquivalent todecodeNull() ? null : decodeShort().@NonNull StringDecodes a string.@Nullable StringEquivalent todecodeNull() ? null : decodeString().protected abstract Decoderdelegate()voidvoidfinishStructure(boolean consumeLeftElements) booleanvoidSkips the current value.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.micronaut.serde.Decoder
decodeNumber, decodeNumberNullable
-
Constructor Details
-
DelegatingDecoder
public DelegatingDecoder()
-
-
Method Details
-
delegate
- Throws:
IOException
-
delegateForDecodeValue
- Returns:
- The delegated decode value
- Throws:
IOException
-
decodeArray
@NonNull public @NonNull Decoder decodeArray(io.micronaut.core.type.Argument<?> type) throws IOException Description copied from interface:DecoderStart decoding an array.- Specified by:
decodeArrayin interfaceDecoder- Parameters:
type- The array type- Returns:
- The array decoder
- Throws:
IOException- If an unrecoverable error occurs
-
decodeArray
Description copied from interface:DecoderStart decoding an array.- Specified by:
decodeArrayin interfaceDecoder- Returns:
- The array decoder
- Throws:
IOException- If an unrecoverable error occurs
-
hasNextArrayValue
- Specified by:
hasNextArrayValuein interfaceDecoder- Returns:
- Returns
trueif another array value is available. - Throws:
IOException- If an unrecoverable error occurs
-
decodeObject
@NonNull public @NonNull Decoder decodeObject(@NonNull @NonNull io.micronaut.core.type.Argument<?> type) throws IOException Description copied from interface:DecoderDecodes an object.- Specified by:
decodeObjectin interfaceDecoder- Parameters:
type- The type, nevernull- Returns:
- The object decoder
- Throws:
IOException- If an unrecoverable error occurs
-
decodeObject
Description copied from interface:DecoderDecodes an object.- Specified by:
decodeObjectin interfaceDecoder- Returns:
- The object decoder
- Throws:
IOException- If an unrecoverable error occurs
-
decodeKey
Description copied from interface:DecoderDecodes a key, if there are no more keys to decode returnsnull.- Specified by:
decodeKeyin interfaceDecoder- Returns:
- The key or
nullif there aren't any more keys - Throws:
IOException- If an unrecoverable error occurs
-
decodeString
Description copied from interface:DecoderDecodes a string.- Specified by:
decodeStringin interfaceDecoder- Returns:
- The string, never
null - Throws:
IOException- If an unrecoverable error occurs
-
decodeStringNullable
Description copied from interface:DecoderEquivalent todecodeNull() ? null : decodeString().- Specified by:
decodeStringNullablein interfaceDecoder- Returns:
- The value
- Throws:
IOException- If an unrecoverable error occurs
-
decodeBoolean
Description copied from interface:DecoderDecodes a boolean.- Specified by:
decodeBooleanin interfaceDecoder- Returns:
- The boolean
- Throws:
IOException- If an unrecoverable error occurs
-
decodeBooleanNullable
Description copied from interface:DecoderEquivalent todecodeNull() ? null : decodeBoolean().- Specified by:
decodeBooleanNullablein interfaceDecoder- Returns:
- The boolean
- Throws:
IOException- If an unrecoverable error occurs
-
decodeByte
Description copied from interface:DecoderDecodes a byte.- Specified by:
decodeBytein interfaceDecoder- Returns:
- The byte
- Throws:
IOException- If an unrecoverable error occurs
-
decodeByteNullable
Description copied from interface:DecoderEquivalent todecodeNull() ? null : decodeByte().- Specified by:
decodeByteNullablein interfaceDecoder- Returns:
- The value
- Throws:
IOException- If an unrecoverable error occurs
-
decodeShort
Description copied from interface:DecoderDecodes a short.- Specified by:
decodeShortin interfaceDecoder- Returns:
- The short
- Throws:
IOException- If an unrecoverable error occurs
-
decodeShortNullable
Description copied from interface:DecoderEquivalent todecodeNull() ? null : decodeShort().- Specified by:
decodeShortNullablein interfaceDecoder- Returns:
- The value
- Throws:
IOException- If an unrecoverable error occurs
-
decodeChar
Description copied from interface:DecoderDecodes a char.- Specified by:
decodeCharin interfaceDecoder- Returns:
- The char
- Throws:
IOException- If an unrecoverable error occurs
-
decodeCharNullable
Description copied from interface:DecoderEquivalent todecodeNull() ? null : decodeChar().- Specified by:
decodeCharNullablein interfaceDecoder- Returns:
- The value
- Throws:
IOException- If an unrecoverable error occurs
-
decodeInt
Description copied from interface:DecoderDecodes a int.- Specified by:
decodeIntin interfaceDecoder- Returns:
- The int
- Throws:
IOException- If an unrecoverable error occurs
-
decodeIntNullable
Description copied from interface:DecoderEquivalent todecodeNull() ? null : decodeInt().- Specified by:
decodeIntNullablein interfaceDecoder- Returns:
- The int
- Throws:
IOException- If an unrecoverable error occurs
-
decodeLong
Description copied from interface:DecoderDecodes a long.- Specified by:
decodeLongin interfaceDecoder- Returns:
- The long
- Throws:
IOException- If an unrecoverable error occurs
-
decodeLongNullable
Description copied from interface:DecoderEquivalent todecodeNull() ? null : decodeLong().- Specified by:
decodeLongNullablein interfaceDecoder- Returns:
- The value
- Throws:
IOException- If an unrecoverable error occurs
-
decodeFloat
Description copied from interface:DecoderDecodes a float.- Specified by:
decodeFloatin interfaceDecoder- Returns:
- The float
- Throws:
IOException- If an unrecoverable error occurs
-
decodeFloatNullable
Description copied from interface:DecoderEquivalent todecodeNull() ? null : decodeFloat().- Specified by:
decodeFloatNullablein interfaceDecoder- Returns:
- The value
- Throws:
IOException- If an unrecoverable error occurs
-
decodeDouble
Description copied from interface:DecoderDecodes a double.- Specified by:
decodeDoublein interfaceDecoder- Returns:
- The double
- Throws:
IOException- If an unrecoverable error occurs
-
decodeDoubleNullable
Description copied from interface:DecoderEquivalent todecodeNull() ? null : decodeDouble().- Specified by:
decodeDoubleNullablein interfaceDecoder- Returns:
- The value
- Throws:
IOException- If an unrecoverable error occurs
-
decodeBigInteger
Description copied from interface:DecoderDecodes a BigInteger.- Specified by:
decodeBigIntegerin interfaceDecoder- Returns:
- The BigInteger, never
null - Throws:
IOException- If an unrecoverable error occurs
-
decodeBigIntegerNullable
Description copied from interface:DecoderEquivalent todecodeNull() ? null : decodeBigInteger().- Specified by:
decodeBigIntegerNullablein interfaceDecoder- Returns:
- The value
- Throws:
IOException- If an unrecoverable error occurs
-
decodeBigDecimal
Description copied from interface:DecoderDecodes a BigDecimal.- Specified by:
decodeBigDecimalin interfaceDecoder- Returns:
- The BigDecimal, never
null - Throws:
IOException- If an unrecoverable error occurs
-
decodeBigDecimalNullable
Description copied from interface:DecoderEquivalent todecodeNull() ? null : decodeBigDecimal().- Specified by:
decodeBigDecimalNullablein interfaceDecoder- Returns:
- The value
- Throws:
IOException- If an unrecoverable error occurs
-
decodeBinary
Description copied from interface:DecoderDecode 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:
decodeBinaryin interfaceDecoder- Returns:
- The decoded byte array
- Throws:
IOException
-
decodeBinaryNullable
Description copied from interface:DecoderEquivalent todecodeNull() ? null : decodeBinary().- Specified by:
decodeBinaryNullablein interfaceDecoder- Returns:
- The value
- Throws:
IOException- If an unrecoverable error occurs
-
decodeNull
Description copied from interface:DecoderAttempt 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.- Specified by:
decodeNullin interfaceDecoder- Returns:
- Returns
trueif the value wasnull - Throws:
IOException- If an unrecoverable error occurs
-
decodeArbitrary
Description copied from interface:DecoderDecodes the current state into an arbitrary object.The following should be decoded by this method:
- Specified by:
decodeArbitraryin interfaceDecoder- Returns:
- The decoded object
- Throws:
IOException- If an unrecoverable error occurs
-
decodeNode
Description copied from interface:DecoderDecodes the current state into aJsonNode.- Specified by:
decodeNodein interfaceDecoder- Returns:
- The decoded node
- Throws:
IOException- If an unrecoverable error occurs
-
decodeBuffer
Description copied from interface:DecoderBuffer 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().- Specified by:
decodeBufferin interfaceDecoder- Returns:
- An independent decoder that visits this subtree.
- Throws:
IOException- If an unrecoverable error occurs
-
skipValue
Description copied from interface:DecoderSkips the current value.- Specified by:
skipValuein interfaceDecoder- Throws:
IOException- If an unrecoverable error occurs
-
finishStructure
- Specified by:
finishStructurein interfaceDecoder- Throws:
IOException- If an unrecoverable error occurs
-
finishStructure
- Specified by:
finishStructurein interfaceDecoder- Parameters:
consumeLeftElements- True to consume left elements- Throws:
IOException- If an unrecoverable error occurs
-
close
Description copied from interface:DecoderFinalize the current structure. Equivalent to callingDecoder.finishStructure().- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceDecoder- Throws:
IOException- If an unrecoverable error occurs
-
createDeserializationException
@NonNull public abstract @NonNull IOException createDeserializationException(@NonNull @NonNull String message, @Nullable @Nullable Object invalidValue) This method remains abstract because it doesn't throw IOException and thus can't call decoder().
Creates an exception for the given message.- Specified by:
createDeserializationExceptionin interfaceDecoder- Parameters:
message- The message, nevernullinvalidValue- The invalid value. Can benull.- Returns:
- The exception, never
null
-