Package org.apache.qpid.protonj2.codec
Interface DecoderState
- All Known Implementing Classes:
ProtonDecoderState
public interface DecoderState
Retains state of decode either between calls or across decode iterations
-
Method Summary
Modifier and TypeMethodDescriptiondecodeUTF8(ProtonBuffer buffer, int length) Given a set of UTF-8 encoded bytes decode and return the String that represents that UTF-8 value.default DecoderStateCalled once decoding of one level of a nested type completes to reduce to the previous level before proceeding to the next element on the current level if any.default intGets the configured maximum depth that nested types such as Lists, Maps and Arrays can have before aDecodeExceptionis thrown.default intGets the configured maximum number of elements that can be decoded from an array encoded with the zero width AMQP types (Null, UInt0.default DecoderStateDuring decode of AMQP types which can be comprised of a nesting of other AMQP types the such as Lists, Maps and Arrays, the depth is increased to track the amount of type nesting that comprises the type being decoded.reset()Resets any intermediate state back to default values.default DecoderStatesetDepthLimit(int limit) Sets the configured maximum depth that nested types such as Lists, Maps and Arrays can have before aDecodeExceptionis thrown to allow the decoder to error in cases where the depth of encoding exceeds what the environment is thought to be able to support.default DecoderStatesetMaxZeroWidthArrayElements(int maxElements) Sets the configured maximum number of elements that can be decoded from an array encoded with the zero width AMQP types (Null, UInt0.
-
Method Details
-
reset
DecoderState reset()Resets any intermediate state back to default values.- Returns:
- this
DecoderStateinstance.
-
getDecoder
Decoder getDecoder()- Returns:
- the decoder that created this state object
-
decodeUTF8
Given a set of UTF-8 encoded bytes decode and return the String that represents that UTF-8 value.- Parameters:
buffer- A buffer containing the UTF-8 encoded bytes to be decoded.length- The number of bytes in the passed buffer that comprise the UTF-8 encoding.- Returns:
- a String that represents the UTF-8 decoded bytes.
- Throws:
DecodeException- if an error occurs while decoding the string value.
-
setDepthLimit
Sets the configured maximum depth that nested types such as Lists, Maps and Arrays can have before aDecodeExceptionis thrown to allow the decoder to error in cases where the depth of encoding exceeds what the environment is thought to be able to support.- Parameters:
limit- The configured limit on decoding types with nested element structures.
-
getDepthLimit
default int getDepthLimit()Gets the configured maximum depth that nested types such as Lists, Maps and Arrays can have before aDecodeExceptionis thrown.- Returns:
- the configured maximum depth of nested types.
-
increaseDepth
During decode of AMQP types which can be comprised of a nesting of other AMQP types the such as Lists, Maps and Arrays, the depth is increased to track the amount of type nesting that comprises the type being decoded. Implementations can use this value to impose limits on the depth of nested objects within complex types and throw anDecodeExceptionif that depth value is reached.- Returns:
- this
DecoderStateinstance for chaining. - Throws:
DecodeException- if a set decoding depth limit is exceeded.
-
decreaseDepth
Called once decoding of one level of a nested type completes to reduce to the previous level before proceeding to the next element on the current level if any.- Returns:
- this
DecoderStateinstance for chaining.
-
getMaxZeroWidthArrayElements
default int getMaxZeroWidthArrayElements()Gets the configured maximum number of elements that can be decoded from an array encoded with the zero width AMQP types (Null, UInt0. ULong0, List0, Boolean_False and Boolean_True). A return value of zero indicates that the decoder should allow any zero sized arrays of zero width types and throw for all others (the new default).- Returns:
- the configured max number of zero width array encoding elements.
-
setMaxZeroWidthArrayElements
Sets the configured maximum number of elements that can be decoded from an array encoded with the zero width AMQP types (Null, UInt0. ULong0, List0, Boolean_False and Boolean_True). These are uncommon encodings and can lead to small encodings with large memory costs at decode which makes them discouraged for normal use.It is recommended that for implementations that implement this limit configuration the default be zero meaning zero width array encodings are disabled and will always throw a
DecodeException- Parameters:
maxElements- The configured max elements allowed in arrays encoded for zero width types.- Returns:
- this
DecoderStateinstance for chaining.
-