Class ProtonStreamDecoderState
java.lang.Object
org.apache.qpid.protonj2.codec.decoders.ProtonStreamDecoderState
- All Implemented Interfaces:
StreamDecoderState
State object used by the Built in Decoder implementation.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe default maximum depth the decoder will allow before triggering anDecodeExceptionwhen the state depth value is increased during a decode process of complex types that can next objects.static final intThe default maximum number of zero width array elements that controls the size of an zero width array type that can be decoded without throwing an DecodeException.Fields inherited from interface org.apache.qpid.protonj2.codec.StreamDecoderState
DEFAULT_MAX_ALLOCATION_LIMIT -
Constructor Summary
ConstructorsConstructorDescriptionCreate a newStreamDecoderStateinstance that is joined forever to the givenDecoder. -
Method Summary
Modifier and TypeMethodDescriptiondecodeUTF8(InputStream stream, int length) Given a stream that will provide UTF-8 encoded bytes, decode and return the String that represents that UTF-8 value.During decode as on level of complex type decode completes the level value is decreasedintGets the configured maximum depth that nested types such as Lists, Maps and Arrays can have before aDecodeExceptionis thrown to allow the decoder to errors in cases where the depth of encoding exceeds that the environment can support.intGets the configured maximum size of an encoded array this decoder will allow before it throws anDecodeExceptionto indicate that a rule violation has occurred.intGets the configured maximum length of an encoded Binary this decoder will allow before it throws anDecodeExceptionto indicate that a rule violation has occurred.intGets the configured maximum indicated encoded size of a List this decoder will allow before it throws anDecodeExceptionto indicate that a rule violation has occurred.intGets the configured maximum indicated encoded size of a List this decoder will allow before it throws anDecodeExceptionto indicate that a rule violation has occurred.intGets the configured maximum size of an encoded string this decoder will allow before it throws anDecodeExceptionto indicate that a rule violation has occurred.intGets the configured maximum size of an encoded Symbol this decoder will allow before it throws anDecodeExceptionto indicate that a rule violation has occurred.intGets the configured maximum number of elements that can be decoded from an array encoded with the zero width AMQP types (Null, UInt0.During decode of AMQP types which can be comprised of a nesting of other AMQP types 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.setDepthLimit(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 errors in cases where the depth of encoding exceeds that the environment can support.setMaxArraySize(int maxArrayLength) Sets the configured maximum size of an encoded array this decoder will allow before it throws anDecodeExceptionto indicate that a rule violation has occurred.setMaxBinarySize(int maxBinaryLength) Gets the configured maximum size of an encoded Binary this decoder will allow before it throws anDecodeExceptionto indicate that a rule violation has occurred.setMaxListSize(int maxListSize) Sets the configured maximum indicated encoded size of a List this decoder will allow before it throws anDecodeExceptionto indicate that a rule violation has occurred.setMaxMapSize(int maxMapSize) Sets the configured maximum indicated encoded size of a Map this decoder will allow before it throws anDecodeExceptionto indicate that a rule violation has occurred.setMaxStringSize(int maxStringLength) Sets the configured maximum size of an encoded string this decoder will allow before it throws anDecodeExceptionto indicate that a rule violation has occurred.setMaxSymbolSize(int maxSymbolLength) Gets the configured maximum length of an encoded Symbol this decoder will allow before it throws anDecodeExceptionto indicate that a rule violation has occurred.setMaxZeroWidthArrayElements(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.voidsetStringDecoder(UTF8StreamDecoder stringDecoder) Sets a custom UTF-8Stringdecoder that will be used for allStringdecoding done from the encoder associated with thisStreamDecoderStateinstance.
-
Field Details
-
DEFAULT_MAX_DECODE_DEPTH
public static final int DEFAULT_MAX_DECODE_DEPTHThe default maximum depth the decoder will allow before triggering anDecodeExceptionwhen the state depth value is increased during a decode process of complex types that can next objects.- See Also:
-
DEFAULT_MAX_ZERO_WIDTH_ARRAY_ELEMENTS
public static final int DEFAULT_MAX_ZERO_WIDTH_ARRAY_ELEMENTSThe default maximum number of zero width array elements that controls the size of an zero width array type that can be decoded without throwing an DecodeException.- See Also:
-
-
Constructor Details
-
ProtonStreamDecoderState
Create a newStreamDecoderStateinstance that is joined forever to the givenDecoder.- Parameters:
decoder- TheStreamDecoderthat this state instance is assigned to.
-
-
Method Details
-
getDecoder
- Specified by:
getDecoderin interfaceStreamDecoderState- Returns:
- the
StreamDecoderthat created this state object
-
reset
Description copied from interface:StreamDecoderStateResets any intermediate state back to default values.- Specified by:
resetin interfaceStreamDecoderState- Returns:
- this
StreamDecoderStateinstance.
-
getStringDecoder
- Returns:
- the currently set custom UTF-8
Stringdecoder or null if non set.
-
setStringDecoder
Sets a custom UTF-8Stringdecoder that will be used for allStringdecoding done from the encoder associated with thisStreamDecoderStateinstance. If no decoder is registered then the implementation uses its own decoding algorithm.- Parameters:
stringDecoder- a customUTF8Decoderthat will be used for allStringdecoding.
-
getMaxZeroWidthArrayElements
public int getMaxZeroWidthArrayElements()Description copied from interface:StreamDecoderStateGets 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).- Specified by:
getMaxZeroWidthArrayElementsin interfaceStreamDecoderState- Returns:
- the configured max number of zero width array encoding elements.
-
setMaxZeroWidthArrayElements
Description copied from interface:StreamDecoderStateSets 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- Specified by:
setMaxZeroWidthArrayElementsin interfaceStreamDecoderState- Parameters:
maxElements- The configured max elements allowed in arrays encoded for zero width types.- Returns:
- this
StreamDecoderStateinstance for chaining.
-
getMaxStringSize
public int getMaxStringSize()Description copied from interface:StreamDecoderStateGets the configured maximum size of an encoded string this decoder will allow before it throws anDecodeExceptionto indicate that a rule violation has occurred.- Specified by:
getMaxStringSizein interfaceStreamDecoderState- Returns:
- the configured max encoded string size supported.
-
setMaxStringSize
Description copied from interface:StreamDecoderStateSets the configured maximum size of an encoded string this decoder will allow before it throws anDecodeExceptionto indicate that a rule violation has occurred.- Specified by:
setMaxStringSizein interfaceStreamDecoderState- Parameters:
maxStringLength- The maximum allowed encoded size value to allow before an decoding exception is thrown.- Returns:
- this
StreamDecoderStateinstance for chaining.
-
getMaxArraySize
public int getMaxArraySize()Description copied from interface:StreamDecoderStateGets the configured maximum size of an encoded array this decoder will allow before it throws anDecodeExceptionto indicate that a rule violation has occurred.- Specified by:
getMaxArraySizein interfaceStreamDecoderState- Returns:
- the configured max encoded array size supported.
-
setMaxArraySize
Description copied from interface:StreamDecoderStateSets the configured maximum size of an encoded array this decoder will allow before it throws anDecodeExceptionto indicate that a rule violation has occurred.- Specified by:
setMaxArraySizein interfaceStreamDecoderState- Parameters:
maxArrayLength- The maximum allowed encoded size value to allow before an decoding exception is thrown.- Returns:
- this
StreamDecoderStateinstance for chaining.
-
getMaxListSize
public int getMaxListSize()Description copied from interface:StreamDecoderStateGets the configured maximum indicated encoded size of a List this decoder will allow before it throws anDecodeExceptionto indicate that a rule violation has occurred.- Specified by:
getMaxListSizein interfaceStreamDecoderState- Returns:
- the configured max encoded list elements supported.
-
setMaxListSize
Description copied from interface:StreamDecoderStateSets the configured maximum indicated encoded size of a List this decoder will allow before it throws anDecodeExceptionto indicate that a rule violation has occurred.- Specified by:
setMaxListSizein interfaceStreamDecoderState- Parameters:
maxListSize- The maximum allowed encoded size value to allow before an decoding exception is thrown.- Returns:
- this
StreamDecoderStateinstance for chaining.
-
getMaxMapSize
public int getMaxMapSize()Description copied from interface:StreamDecoderStateGets the configured maximum indicated encoded size of a List this decoder will allow before it throws anDecodeExceptionto indicate that a rule violation has occurred.- Specified by:
getMaxMapSizein interfaceStreamDecoderState- Returns:
- the configured max encoded list size supported.
-
setMaxMapSize
Description copied from interface:StreamDecoderStateSets the configured maximum indicated encoded size of a Map this decoder will allow before it throws anDecodeExceptionto indicate that a rule violation has occurred.- Specified by:
setMaxMapSizein interfaceStreamDecoderState- Parameters:
maxMapSize- The maximum allowed encoded size value to allow before an decoding exception is thrown.- Returns:
- this
StreamDecoderStateinstance for chaining.
-
getMaxBinarySize
public int getMaxBinarySize()Description copied from interface:StreamDecoderStateGets the configured maximum length of an encoded Binary this decoder will allow before it throws anDecodeExceptionto indicate that a rule violation has occurred.- Specified by:
getMaxBinarySizein interfaceStreamDecoderState- Returns:
- the configured max encoded binary length supported.
-
setMaxBinarySize
Description copied from interface:StreamDecoderStateGets the configured maximum size of an encoded Binary this decoder will allow before it throws anDecodeExceptionto indicate that a rule violation has occurred.- Specified by:
setMaxBinarySizein interfaceStreamDecoderState- Parameters:
maxBinaryLength- The maximum allowed encoded size value to allow before an decoding exception is thrown.- Returns:
- this
StreamDecoderStateinstance for chaining.
-
getMaxSymbolSize
public int getMaxSymbolSize()Description copied from interface:StreamDecoderStateGets the configured maximum size of an encoded Symbol this decoder will allow before it throws anDecodeExceptionto indicate that a rule violation has occurred.- Specified by:
getMaxSymbolSizein interfaceStreamDecoderState- Returns:
- the configured max encoded Symbol length supported.
-
setMaxSymbolSize
Description copied from interface:StreamDecoderStateGets the configured maximum length of an encoded Symbol this decoder will allow before it throws anDecodeExceptionto indicate that a rule violation has occurred.- Specified by:
setMaxSymbolSizein interfaceStreamDecoderState- Parameters:
maxSymbolLength- The maximum allowed encoded size value to allow before an decoding exception is thrown.- Returns:
- this
StreamDecoderStateinstance for chaining.
-
setDepthLimit
Description copied from interface:StreamDecoderStateSets the configured maximum depth that nested types such as Lists, Maps and Arrays can have before aDecodeExceptionis thrown to allow the decoder to errors in cases where the depth of encoding exceeds that the environment can support.- Specified by:
setDepthLimitin interfaceStreamDecoderState- Parameters:
limit- The configured limit on decoding types with nested element structures.- Returns:
- this
StreamDecoderStateinstance for chaining.
-
getDepthLimit
public int getDepthLimit()Description copied from interface:StreamDecoderStateGets the configured maximum depth that nested types such as Lists, Maps and Arrays can have before aDecodeExceptionis thrown to allow the decoder to errors in cases where the depth of encoding exceeds that the environment can support.- Specified by:
getDepthLimitin interfaceStreamDecoderState- Returns:
- the configured maximum depth of nested types.
-
increaseDepth
Description copied from interface:StreamDecoderStateDuring decode of AMQP types which can be comprised of a nesting of other AMQP types 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 exceeded.- Specified by:
increaseDepthin interfaceStreamDecoderState- Returns:
- this
StreamDecoderStateinstance for chaining. - Throws:
DecodeException- if a set decoding depth limit is exceeded.
-
decreaseDepth
Description copied from interface:StreamDecoderStateDuring decode as on level of complex type decode completes the level value is decreased- Specified by:
decreaseDepthin interfaceStreamDecoderState- Returns:
- this
StreamDecoderStateinstance for chaining.
-
decodeUTF8
Description copied from interface:StreamDecoderStateGiven a stream that will provide UTF-8 encoded bytes, decode and return the String that represents that UTF-8 value.- Specified by:
decodeUTF8in interfaceStreamDecoderState- Parameters:
stream- A stream from which the UTF-8 encoded bytes are to be decoded.length- The number of bytes in the passedInputStreamthat 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.
-