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
-
Method Summary
Modifier and TypeMethodDescriptionprotected String
coerceScalarToString
(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.TokenType
void
finishStructure
(boolean consumeLeftElements) protected Number
Decode the currentAbstractStreamDecoder.TokenType.NUMBER
value as aNumber
value.protected BigDecimal
Decode the currentAbstractStreamDecoder.TokenType.NUMBER
value as aBigDecimal
value.protected BigInteger
Decode the currentAbstractStreamDecoder.TokenType.NUMBER
value as aBigInteger
value.protected boolean
Decode the currentAbstractStreamDecoder.TokenType.BOOLEAN
value.protected String
Get the current object field name.protected double
Decode the currentAbstractStreamDecoder.TokenType.NUMBER
value as a double value.protected long
getLong()
Decode the currentAbstractStreamDecoder.TokenType.NUMBER
value as a long value.protected String
Decode the currentAbstractStreamDecoder.TokenType.STRING
value.protected void
Move to the next token.protected void
If we are at aAbstractStreamDecoder.TokenType.START_OBJECT
orAbstractStreamDecoder.TokenType.START_ARRAY
, skip to the matchingAbstractStreamDecoder.TokenType.END_OBJECT
orAbstractStreamDecoder.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, getBigDecimalFromNumber, getInteger, hasNextArrayValue, preDecodeValue, skipValue, unexpectedToken
Methods inherited from class io.micronaut.serde.LimitingStream
childLimits, decreaseDepth, increaseDepth, limitsFromConfiguration, ourLimits
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.micronaut.serde.Decoder
close, decodeArray, decodeBigDecimalNullable, decodeBigIntegerNullable, decodeBinaryNullable, decodeBooleanNullable, decodeByteNullable, decodeCharNullable, decodeDoubleNullable, decodeFloatNullable, decodeIntNullable, decodeLongNullable, decodeNumber, decodeNumberNullable, decodeObject, decodeShortNullable, decodeStringNullable, finishStructure
-
Constructor Details
-
JsonParserDecoder
public JsonParserDecoder(jakarta.json.stream.JsonParser jsonParser)
-
-
Method Details
-
finishStructure
- Specified by:
finishStructure
in interfaceDecoder
- Overrides:
finishStructure
in classAbstractStreamDecoder
- Parameters:
consumeLeftElements
- True to consume left elements- Throws:
IOException
- If an unrecoverable error occurs
-
currentToken
- Specified by:
currentToken
in classAbstractStreamDecoder
- Returns:
- The current token.
-
nextToken
protected void nextToken()Description copied from class:AbstractStreamDecoder
Move to the next token.- Specified by:
nextToken
in classAbstractStreamDecoder
-
getCurrentKey
Description copied from class:AbstractStreamDecoder
Get the current object field name. Only called forAbstractStreamDecoder.TokenType.KEY
.- Specified by:
getCurrentKey
in classAbstractStreamDecoder
- Returns:
- The current field key
-
coerceScalarToString
Description copied from class:AbstractStreamDecoder
Decode any non-null scalar value (number, string or boolean) to its string representation.- Specified by:
coerceScalarToString
in classAbstractStreamDecoder
- Parameters:
currentToken
- The current token- Returns:
- The current value, coerced to a string
-
getString
Description copied from class:AbstractStreamDecoder
Decode the currentAbstractStreamDecoder.TokenType.STRING
value. Called for no other token type.- Specified by:
getString
in classAbstractStreamDecoder
- Returns:
- The String value
-
getBoolean
protected boolean getBoolean()Description copied from class:AbstractStreamDecoder
Decode the currentAbstractStreamDecoder.TokenType.BOOLEAN
value. Called for no other token type.- Specified by:
getBoolean
in classAbstractStreamDecoder
- Returns:
- The boolean value
-
getLong
protected long getLong()Description copied from class:AbstractStreamDecoder
Decode the currentAbstractStreamDecoder.TokenType.NUMBER
value as a long value. Called for no other token type.- Specified by:
getLong
in classAbstractStreamDecoder
- Returns:
- The number value
-
getDouble
protected double getDouble()Description copied from class:AbstractStreamDecoder
Decode the currentAbstractStreamDecoder.TokenType.NUMBER
value as a double value. Called for no other token type.- Specified by:
getDouble
in classAbstractStreamDecoder
- Returns:
- The number value
-
getBigInteger
Description copied from class:AbstractStreamDecoder
Decode the currentAbstractStreamDecoder.TokenType.NUMBER
value as aBigInteger
value. Called for no other token type.- Specified by:
getBigInteger
in classAbstractStreamDecoder
- Returns:
- The number value
-
getBigDecimal
Description copied from class:AbstractStreamDecoder
Decode the currentAbstractStreamDecoder.TokenType.NUMBER
value as aBigDecimal
value. Called for no other token type.- Specified by:
getBigDecimal
in classAbstractStreamDecoder
- Returns:
- The number value
-
getBestNumber
Description copied from class:AbstractStreamDecoder
Decode the currentAbstractStreamDecoder.TokenType.NUMBER
value as aNumber
value. Called for no other token type.- Specified by:
getBestNumber
in classAbstractStreamDecoder
- Returns:
- The number value
-
skipChildren
protected void skipChildren()Description copied from class:AbstractStreamDecoder
If we are at aAbstractStreamDecoder.TokenType.START_OBJECT
orAbstractStreamDecoder.TokenType.START_ARRAY
, skip to the matchingAbstractStreamDecoder.TokenType.END_OBJECT
orAbstractStreamDecoder.TokenType.END_ARRAY
. Else, do nothing.- Specified by:
skipChildren
in classAbstractStreamDecoder
-
createDeserializationException
Description copied from interface:Decoder
Creates an exception for the given message.- Parameters:
message
- The message, nevernull
invalidValue
- The invalid value. Can benull
.- Returns:
- The exception, never
null
-