Package io.micronaut.serde
Class LimitingStream
java.lang.Object
io.micronaut.serde.LimitingStream
- Direct Known Subclasses:
- AbstractStreamDecoder,- BsonWriterEncoder,- JacksonDecoder,- JacksonEncoder,- JsonNodeDecoder,- JsonNodeEncoder,- OracleJdbcJsonGeneratorEncoder
Utility class to check data limits in encoders and decoders. Currently, the only limit that is
 checked is the nesting depth.
 
 This class can be used in both implementation "patterns" for Encoder (and
 Decoder): For the same-object pattern, where Encoder.encodeObject(Argument)
 returns the same instance, the encoder should call increaseDepth(), with a
 corresponding decreaseDepth() call in Encoder.finishStructure(). Conversely, if
 the encoder is implemented using the child-object pattern, where
 Encoder.encodeObject(Argument) returns a child encoder responsible for the subtree, that
 child encoder should be instantiated using the new limits returned by childLimits().
 
 If there is a limit violation, childLimits() or increaseDepth() will throw an
 exception.
- Since:
- 2.0.0
- Author:
- Jonas Konrad
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic final classThis data structure contains the limits for this stream.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final LimitingStream.RemainingLimitsDefault limits, only use this when noSerdeConfigurationis available.static final intDefault nesting depth limit.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected final @NonNull LimitingStream.RemainingLimitsGet the limits of a new child encoder.protected final voidDecrease the current depth, always needs a correspondingincreaseDepth()call.protected final voidIncrease the current depth.limitsFromConfiguration(SerdeConfiguration configuration) Get the configured limits.protected final @NonNull LimitingStream.RemainingLimitsGet a snapshot of our current limits to be passed to the constructor.
- 
Field Details- 
DEFAULT_MAXIMUM_DEPTHpublic static final int DEFAULT_MAXIMUM_DEPTHDefault nesting depth limit.- See Also:
 
- 
DEFAULT_LIMITSDefault limits, only use this when noSerdeConfigurationis available.
 
- 
- 
Constructor Details- 
LimitingStream
 
- 
- 
Method Details- 
ourLimitsGet a snapshot of our current limits to be passed to the constructor. This can be used for buffering decoders, when a new decoder takes over but no change in depth takes place.- Returns:
- The current limits
 
- 
childLimits@NonNull protected final @NonNull LimitingStream.RemainingLimits childLimits() throws SerdeExceptionGet the limits of a new child encoder.- Returns:
- The new limits
- Throws:
- SerdeException- If there is a nesting depth limit violation
 
- 
increaseDepthIncrease the current depth.- Throws:
- SerdeException- If there is a nesting depth limit violation
 
- 
decreaseDepthprotected final void decreaseDepth()Decrease the current depth, always needs a correspondingincreaseDepth()call.
- 
limitsFromConfigurationpublic static LimitingStream.RemainingLimits limitsFromConfiguration(SerdeConfiguration configuration) Get the configured limits.- Parameters:
- configuration- The serde configuration
- Returns:
- The configured limits
 
 
-