Package io.micronaut.serde.support
Class AbstractDecoderPerStructureStreamDecoder
java.lang.Object
io.micronaut.serde.LimitingStream
io.micronaut.serde.support.AbstractStreamDecoder
io.micronaut.serde.support.AbstractDecoderPerStructureStreamDecoder
- All Implemented Interfaces:
io.micronaut.serde.Decoder,AutoCloseable
@Internal
public abstract class AbstractDecoderPerStructureStreamDecoder
extends AbstractStreamDecoder
Abstract variation of
AbstractStreamDecoder that uses separate decoders for structures like an array or an object.-
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
io.micronaut.serde.LimitingStream.RemainingLimits -
Field Summary
Fields inherited from class io.micronaut.serde.LimitingStream
DEFAULT_LIMITS, DEFAULT_MAXIMUM_DEPTH -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractDecoderPerStructureStreamDecoder(@NonNull io.micronaut.serde.LimitingStream.RemainingLimits remainingLimits) Root constructor.protectedAbstractDecoderPerStructureStreamDecoder(@NonNull AbstractDecoderPerStructureStreamDecoder parent, @NonNull io.micronaut.serde.LimitingStream.RemainingLimits remainingLimits) Child constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidCalled when the old child has finished processing and returns control of the stream to the parent.protected abstract AbstractStreamDecoderCreate a new child decoder usingAbstractDecoderPerStructureStreamDecoder(AbstractDecoderPerStructureStreamDecoder,io.micronaut.serde.LimitingStream.RemainingLimits).protected AbstractStreamDecoderdecodeArray0(AbstractStreamDecoder.TokenType currentToken) Decodes the array.final Stringprotected AbstractStreamDecoderdecodeObject0(AbstractStreamDecoder.TokenType currentToken) Decodes the object.voidfinishStructure(boolean consumeLeftElements) booleanprotected voidpreDecodeValue(AbstractStreamDecoder.TokenType currentToken) Should be called before attempting to decode a value.Methods inherited from class io.micronaut.serde.support.AbstractStreamDecoder
coerceScalarToString, consumeLeftElements, currentToken, decodeArbitrary, decodeArray, decodeBigDecimal, decodeBigInteger, decodeBinary, decodeBoolean, decodeBuffer, decodeByte, decodeChar, decodeCustom, decodeCustom, decodeDouble, decodeFloat, decodeInt, decodeLong, decodeNode, decodeNull, decodeNumber, decodeObject, decodeShort, decodeString, getBestNumber, getBestNumberNode, getBigDecimal, getBigInteger, getBoolean, getCurrentKey, getDouble, getInteger, getLong, getString, nextToken, skipChildren, 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, createDeserializationException, decodeArray, decodeBigDecimalNullable, decodeBigIntegerNullable, decodeBinaryNullable, decodeBooleanNullable, decodeByteNullable, decodeCharNullable, decodeDoubleNullable, decodeFloatNullable, decodeIntNullable, decodeLongNullable, decodeObject, decodeShortNullable, decodeStringNullable, finishStructure
-
Constructor Details
-
AbstractDecoderPerStructureStreamDecoder
protected AbstractDecoderPerStructureStreamDecoder(@NonNull @NonNull AbstractDecoderPerStructureStreamDecoder parent, @NonNull @NonNull io.micronaut.serde.LimitingStream.RemainingLimits remainingLimits) Child constructor. Should inherit the parser from the parent.- Parameters:
parent- The parent decoder.remainingLimits- The limits for this decoder
-
AbstractDecoderPerStructureStreamDecoder
protected AbstractDecoderPerStructureStreamDecoder(@NonNull @NonNull io.micronaut.serde.LimitingStream.RemainingLimits remainingLimits) Root constructor.- Parameters:
remainingLimits- The limits for this decoder
-
-
Method Details
-
createChildDecoder
protected abstract AbstractStreamDecoder createChildDecoder() throws io.micronaut.serde.exceptions.SerdeExceptionCreate a new child decoder usingAbstractDecoderPerStructureStreamDecoder(AbstractDecoderPerStructureStreamDecoder,io.micronaut.serde.LimitingStream.RemainingLimits).- Returns:
- The new decoder
- Throws:
io.micronaut.serde.exceptions.SerdeException
-
preDecodeValue
Description copied from class:AbstractStreamDecoderShould be called before attempting to decode a value. Has basic sanity checks, such as confirming we're not currently in aAbstractStreamDecoder.TokenType.KEYand that there's no child decoder currently running.- Overrides:
preDecodeValuein classAbstractStreamDecoder- Parameters:
currentToken- The current token
-
finishStructure
- Specified by:
finishStructurein interfaceio.micronaut.serde.Decoder- Overrides:
finishStructurein classAbstractStreamDecoder- Throws:
IOException
-
hasNextArrayValue
public boolean hasNextArrayValue()- Specified by:
hasNextArrayValuein interfaceio.micronaut.serde.Decoder- Overrides:
hasNextArrayValuein classAbstractStreamDecoder
-
decodeKey
- Specified by:
decodeKeyin interfaceio.micronaut.serde.Decoder- Overrides:
decodeKeyin classAbstractStreamDecoder- Throws:
IOException
-
decodeArray0
protected AbstractStreamDecoder decodeArray0(AbstractStreamDecoder.TokenType currentToken) throws IOException Description copied from class:AbstractStreamDecoderDecodes the array.- Overrides:
decodeArray0in classAbstractStreamDecoder- Parameters:
currentToken- The current token- Returns:
- The decoder
- Throws:
IOException- The exception
-
decodeObject0
protected AbstractStreamDecoder decodeObject0(AbstractStreamDecoder.TokenType currentToken) throws IOException Description copied from class:AbstractStreamDecoderDecodes the object.- Overrides:
decodeObject0in classAbstractStreamDecoder- Parameters:
currentToken- The current token- Returns:
- The decoder
- Throws:
IOException- The exception
-
backFromChild
Called when the old child has finished processing and returns control of the stream to the parent. Current token is assumed to beAbstractStreamDecoder.TokenType.END_ARRAYorAbstractStreamDecoder.TokenType.END_OBJECT. However weAbstractStreamDecoder.currentToken()may hold an outdated value untilAbstractStreamDecoder.nextToken()is called, which this method does.- Parameters:
child- The now-invalid child decoder.- Throws:
IOException- if an unrecoverable error occurs
-