Package io.micronaut.serde.support.util
Class JsonNodeDecoder
java.lang.Object
io.micronaut.serde.LimitingStream
io.micronaut.serde.support.util.JsonNodeDecoder
- All Implemented Interfaces:
Decoder,AutoCloseable
Implementation of the
Decoder interface that
uses the JsonNode abstraction.-
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 JsonNodeDecodercreate(io.micronaut.json.tree.JsonNode node, LimitingStream.RemainingLimits remainingLimits) createDeserializationException(String message, Object invalidValue) Creates an exception for the given message.Decodes the current state into an arbitrary object.decodeArray(io.micronaut.core.type.Argument<?> type) Start decoding an array.Decodes a BigDecimal.Decodes a BigInteger.byte @NonNull []Decode binary data from this stream.booleanDecodes a boolean.Buffer the whole subtree of this value and return it as a newDecoder.byteDecodes a byte.charDecodes a char.doubleDecodes a double.floatDecodes a float.intDecodes a int.longDecodes a long.@NonNull io.micronaut.json.tree.JsonNodeDecodes the current state into aJsonNode.booleanAttempt to decode a null value.decodeObject(io.micronaut.core.type.Argument<?> type) Decodes an object.shortDecodes a short.Decodes a string.protected abstract io.micronaut.json.tree.JsonNodeMethods inherited from class io.micronaut.serde.LimitingStream
childLimits, decreaseDepth, increaseDepth, limitsFromConfiguration, ourLimitsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.micronaut.serde.Decoder
close, decodeArray, decodeBigDecimalNullable, decodeBigIntegerNullable, decodeBinaryNullable, decodeBooleanNullable, decodeByteNullable, decodeCharNullable, decodeDoubleNullable, decodeFloatNullable, decodeIntNullable, decodeKey, decodeLongNullable, decodeNumber, decodeNumberNullable, decodeObject, decodeShortNullable, decodeStringNullable, finishStructure, finishStructure, hasNextArrayValue, skipValue
-
Method Details
-
create
public static JsonNodeDecoder create(io.micronaut.json.tree.JsonNode node, LimitingStream.RemainingLimits remainingLimits) -
peekValue
- Throws:
IOException
-
decodeArray
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
-
decodeObject
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
-
decodeString
Description copied from interface:DecoderDecodes a string.- Specified by:
decodeStringin interfaceDecoder- Returns:
- The string, never
null - 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
-
decodeByte
Description copied from interface:DecoderDecodes a byte.- Specified by:
decodeBytein interfaceDecoder- Returns:
- The byte
- 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
-
decodeChar
Description copied from interface:DecoderDecodes a char.- Specified by:
decodeCharin interfaceDecoder- Returns:
- The char
- 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
-
decodeLong
Description copied from interface:DecoderDecodes a long.- Specified by:
decodeLongin interfaceDecoder- Returns:
- The long
- 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
-
decodeDouble
Description copied from interface:DecoderDecodes a double.- Specified by:
decodeDoublein interfaceDecoder- Returns:
- The double
- 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
-
decodeBigDecimal
Description copied from interface:DecoderDecodes a BigDecimal.- Specified by:
decodeBigDecimalin interfaceDecoder- Returns:
- The BigDecimal, never
null - 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
-
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
-
createDeserializationException
Description copied from interface:DecoderCreates 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
-