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:
Decoder,AutoCloseable
- Direct Known Subclasses:
BsonReaderDecoder
@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
LimitingStream.RemainingLimits -
Field Summary
Fields inherited from class io.micronaut.serde.LimitingStream
DEFAULT_LIMITS, DEFAULT_MAXIMUM_DEPTH -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractDecoderPerStructureStreamDecoder(@NonNull LimitingStream.RemainingLimits remainingLimits) Root constructor.protectedAbstractDecoderPerStructureStreamDecoder(@NonNull AbstractDecoderPerStructureStreamDecoder parent, @NonNull 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 StringDecodes a key, if there are no more keys to decode returnsnull.protected 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, getBigDecimalFromNumber, 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, decodeNumber, decodeNumberNullable, decodeObject, decodeShortNullable, decodeStringNullable, finishStructure
-
Constructor Details
-
AbstractDecoderPerStructureStreamDecoder
protected AbstractDecoderPerStructureStreamDecoder(@NonNull @NonNull AbstractDecoderPerStructureStreamDecoder parent, @NonNull @NonNull 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 LimitingStream.RemainingLimits remainingLimits) Root constructor.- Parameters:
remainingLimits- The limits for this decoder
-
-
Method Details
-
createChildDecoder
Create a new child decoder usingAbstractDecoderPerStructureStreamDecoder(AbstractDecoderPerStructureStreamDecoder,io.micronaut.serde.LimitingStream.RemainingLimits).- Returns:
- The new decoder
- Throws:
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 interfaceDecoder- Overrides:
finishStructurein classAbstractStreamDecoder- Parameters:
consumeLeftElements- True to consume left elements- Throws:
IOException- If an unrecoverable error occurs
-
hasNextArrayValue
public boolean hasNextArrayValue()- Specified by:
hasNextArrayValuein interfaceDecoder- Overrides:
hasNextArrayValuein classAbstractStreamDecoder- Returns:
- Returns
trueif another array value is available.
-
decodeKey
Description copied from interface:DecoderDecodes a key, if there are no more keys to decode returnsnull.- Specified by:
decodeKeyin interfaceDecoder- Overrides:
decodeKeyin classAbstractStreamDecoder- Returns:
- The key or
nullif there aren't any more keys - Throws:
IOException- If an unrecoverable error occurs
-
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
-