Package io.micronaut.serde.json.stream
Class JsonParserDecoder
java.lang.Object
io.micronaut.serde.LimitingStream
io.micronaut.serde.support.AbstractStreamDecoder
io.micronaut.serde.json.stream.JsonParserDecoder
- All Implemented Interfaces:
Decoder,AutoCloseable
Implementation of the
Decoder interface for JSON-P.-
Nested Class Summary
Nested classes/interfaces inherited from class io.micronaut.serde.support.AbstractStreamDecoder
AbstractStreamDecoder.TokenType, AbstractStreamDecoder.ValueDecoder<R>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 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringcoerceScalarToString(AbstractStreamDecoder.TokenType currentToken) Decode any non-null scalar value (number, string or boolean) to its string representation.createDeserializationException(String message, Object invalidValue) Creates an exception for the given message.protected AbstractStreamDecoder.TokenTypevoidfinishStructure(boolean consumeLeftElements) protected NumberDecode the currentAbstractStreamDecoder.TokenType.NUMBERvalue as aNumbervalue.protected BigDecimalDecode the currentAbstractStreamDecoder.TokenType.NUMBERvalue as aBigDecimalvalue.protected BigIntegerDecode the currentAbstractStreamDecoder.TokenType.NUMBERvalue as aBigIntegervalue.protected booleanDecode the currentAbstractStreamDecoder.TokenType.BOOLEANvalue.protected StringGet the current object field name.protected doubleDecode the currentAbstractStreamDecoder.TokenType.NUMBERvalue as a double value.protected longgetLong()Decode the currentAbstractStreamDecoder.TokenType.NUMBERvalue as a long value.protected StringDecode the currentAbstractStreamDecoder.TokenType.STRINGvalue.protected voidMove to the next token.protected voidIf we are at aAbstractStreamDecoder.TokenType.START_OBJECTorAbstractStreamDecoder.TokenType.START_ARRAY, skip to the matchingAbstractStreamDecoder.TokenType.END_OBJECTorAbstractStreamDecoder.TokenType.END_ARRAY.Methods inherited from class io.micronaut.serde.support.AbstractStreamDecoder
consumeLeftElements, decodeArbitrary, decodeArray, decodeArray0, decodeBigDecimal, decodeBigInteger, decodeBinary, decodeBoolean, decodeBuffer, decodeByte, decodeChar, decodeCustom, decodeCustom, decodeDouble, decodeFloat, decodeInt, decodeKey, decodeLong, decodeNode, decodeNull, decodeNumber, decodeObject, decodeObject0, decodeShort, decodeString, getBestNumberNode, getInteger, hasNextArrayValue, preDecodeValue, skipValue, unexpectedTokenMethods 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, decodeLongNullable, decodeObject, decodeShortNullable, decodeStringNullable, finishStructure
-
Constructor Details
-
JsonParserDecoder
public JsonParserDecoder(jakarta.json.stream.JsonParser jsonParser)
-
-
Method Details
-
finishStructure
- Specified by:
finishStructurein interfaceDecoder- Overrides:
finishStructurein classAbstractStreamDecoder- Parameters:
consumeLeftElements- True to consume left elements- Throws:
IOException- If an unrecoverable error occurs
-
currentToken
- Specified by:
currentTokenin classAbstractStreamDecoder- Returns:
- The current token.
-
nextToken
protected void nextToken()Description copied from class:AbstractStreamDecoderMove to the next token.- Specified by:
nextTokenin classAbstractStreamDecoder
-
getCurrentKey
Description copied from class:AbstractStreamDecoderGet the current object field name. Only called forAbstractStreamDecoder.TokenType.KEY.- Specified by:
getCurrentKeyin classAbstractStreamDecoder- Returns:
- The current field key
-
coerceScalarToString
Description copied from class:AbstractStreamDecoderDecode any non-null scalar value (number, string or boolean) to its string representation.- Specified by:
coerceScalarToStringin classAbstractStreamDecoder- Parameters:
currentToken- The current token- Returns:
- The current value, coerced to a string
-
getString
Description copied from class:AbstractStreamDecoderDecode the currentAbstractStreamDecoder.TokenType.STRINGvalue. Called for no other token type.- Specified by:
getStringin classAbstractStreamDecoder- Returns:
- The String value
-
getBoolean
protected boolean getBoolean()Description copied from class:AbstractStreamDecoderDecode the currentAbstractStreamDecoder.TokenType.BOOLEANvalue. Called for no other token type.- Specified by:
getBooleanin classAbstractStreamDecoder- Returns:
- The boolean value
-
getLong
protected long getLong()Description copied from class:AbstractStreamDecoderDecode the currentAbstractStreamDecoder.TokenType.NUMBERvalue as a long value. Called for no other token type.- Specified by:
getLongin classAbstractStreamDecoder- Returns:
- The number value
-
getDouble
protected double getDouble()Description copied from class:AbstractStreamDecoderDecode the currentAbstractStreamDecoder.TokenType.NUMBERvalue as a double value. Called for no other token type.- Specified by:
getDoublein classAbstractStreamDecoder- Returns:
- The number value
-
getBigInteger
Description copied from class:AbstractStreamDecoderDecode the currentAbstractStreamDecoder.TokenType.NUMBERvalue as aBigIntegervalue. Called for no other token type.- Specified by:
getBigIntegerin classAbstractStreamDecoder- Returns:
- The number value
-
getBigDecimal
Description copied from class:AbstractStreamDecoderDecode the currentAbstractStreamDecoder.TokenType.NUMBERvalue as aBigDecimalvalue. Called for no other token type.- Specified by:
getBigDecimalin classAbstractStreamDecoder- Returns:
- The number value
-
getBestNumber
Description copied from class:AbstractStreamDecoderDecode the currentAbstractStreamDecoder.TokenType.NUMBERvalue as aNumbervalue. Called for no other token type.- Specified by:
getBestNumberin classAbstractStreamDecoder- Returns:
- The number value
-
skipChildren
protected void skipChildren()Description copied from class:AbstractStreamDecoderIf we are at aAbstractStreamDecoder.TokenType.START_OBJECTorAbstractStreamDecoder.TokenType.START_ARRAY, skip to the matchingAbstractStreamDecoder.TokenType.END_OBJECTorAbstractStreamDecoder.TokenType.END_ARRAY. Else, do nothing.- Specified by:
skipChildrenin classAbstractStreamDecoder
-
createDeserializationException
Description copied from interface:DecoderCreates an exception for the given message.- Parameters:
message- The message, nevernullinvalidValue- The invalid value. Can benull.- Returns:
- The exception, never
null
-