Package org.apache.qpid.protonj2.codec
Interface StreamDecoderState
- All Known Implementing Classes:
ProtonStreamDecoderState
public interface StreamDecoderState
Retains state of the
InputStream based decode either between calls or across decode iterations-
Field Summary
Fields -
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.default StreamDecoderStateDuring decode as on level of complex type decode completes the level value is decreaseddefault intGets 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.default intGets the configured maximum size of an encoded array this decoder will allow before it throws anDecodeExceptionto indicate that a rule violation has occurred.default intGets the configured maximum length of an encoded Binary this decoder will allow before it throws anDecodeExceptionto indicate that a rule violation has occurred.default 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.default 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.default intGets the configured maximum size of an encoded string this decoder will allow before it throws anDecodeExceptionto indicate that a rule violation has occurred.default intGets the configured maximum size of an encoded Symbol this decoder will allow before it throws anDecodeExceptionto indicate that a rule violation has occurred.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 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.reset()Resets any intermediate state back to default values.default StreamDecoderStatesetDepthLimit(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.default StreamDecoderStatesetMaxArraySize(int maximumSize) Sets the configured maximum size of an encoded array this decoder will allow before it throws anDecodeExceptionto indicate that a rule violation has occurred.default StreamDecoderStatesetMaxBinarySize(int maximumSize) Gets the configured maximum size of an encoded Binary this decoder will allow before it throws anDecodeExceptionto indicate that a rule violation has occurred.default StreamDecoderStatesetMaxListSize(int maximumSize) 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.default StreamDecoderStatesetMaxMapSize(int maximumSize) 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.default StreamDecoderStatesetMaxStringSize(int maximumSize) Sets the configured maximum size of an encoded string this decoder will allow before it throws anDecodeExceptionto indicate that a rule violation has occurred.default StreamDecoderStatesetMaxSymbolSize(int maximumSize) Gets the configured maximum length of an encoded Symbol this decoder will allow before it throws anDecodeExceptionto indicate that a rule violation has occurred.default StreamDecoderStatesetMaxZeroWidthArrayElements(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.
-
Field Details
-
DEFAULT_MAX_ALLOCATION_LIMIT
static final int DEFAULT_MAX_ALLOCATION_LIMIT- See Also:
-
-
Method Details
-
reset
StreamDecoderState reset()Resets any intermediate state back to default values.- Returns:
- this
StreamDecoderStateinstance.
-
getDecoder
StreamDecoder getDecoder()- Returns:
- the
StreamDecoderthat created this state object
-
decodeUTF8
Given a stream that will provide UTF-8 encoded bytes, decode and return the String that represents that UTF-8 value.- 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.
-
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 errors in cases where the depth of encoding exceeds that the environment can support.- Parameters:
limit- The configured limit on decoding types with nested element structures.- Returns:
- this
StreamDecoderStateinstance for chaining. - Throws:
DecodeException- if a set decoding depth limit is exceeded.
-
getDepthLimit
default int getDepthLimit()Gets 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.- 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 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.- Returns:
- this
StreamDecoderStateinstance for chaining. - Throws:
DecodeException- if a set decoding depth limit is exceeded.
-
decreaseDepth
During decode as on level of complex type decode completes the level value is decreased- Returns:
- this
StreamDecoderStateinstance 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
StreamDecoderStateinstance for chaining.
-
getMaxStringSize
default int getMaxStringSize()Gets the configured maximum size of an encoded string this decoder will allow before it throws anDecodeExceptionto indicate that a rule violation has occurred.- Returns:
- the configured max encoded string size supported.
-
setMaxStringSize
Sets the configured maximum size of an encoded string this decoder will allow before it throws anDecodeExceptionto indicate that a rule violation has occurred.- Parameters:
maximumSize- The maximum allowed encoded size value to allow before an decoding exception is thrown.- Returns:
- this
StreamDecoderStateinstance for chaining.
-
getMaxArraySize
default int getMaxArraySize()Gets the configured maximum size of an encoded array this decoder will allow before it throws anDecodeExceptionto indicate that a rule violation has occurred.- Returns:
- the configured max encoded array size supported.
-
setMaxArraySize
Sets the configured maximum size of an encoded array this decoder will allow before it throws anDecodeExceptionto indicate that a rule violation has occurred.- Parameters:
maximumSize- The maximum allowed encoded size value to allow before an decoding exception is thrown.- Returns:
- this
StreamDecoderStateinstance for chaining.
-
getMaxListSize
default int getMaxListSize()Gets the configured maximum indicated encoded size of a List this decoder will allow before it throws anDecodeExceptionto indicate that a rule violation has occurred.- Returns:
- the configured max encoded list elements supported.
-
setMaxListSize
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.- Parameters:
maximumSize- The maximum allowed encoded size value to allow before an decoding exception is thrown.- Returns:
- this
StreamDecoderStateinstance for chaining.
-
getMaxMapSize
default int getMaxMapSize()Gets the configured maximum indicated encoded size of a List this decoder will allow before it throws anDecodeExceptionto indicate that a rule violation has occurred.- Returns:
- the configured max encoded list size supported.
-
setMaxMapSize
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.- Parameters:
maximumSize- The maximum allowed encoded size value to allow before an decoding exception is thrown.- Returns:
- this
StreamDecoderStateinstance for chaining.
-
getMaxBinarySize
default int getMaxBinarySize()Gets the configured maximum length of an encoded Binary this decoder will allow before it throws anDecodeExceptionto indicate that a rule violation has occurred.- Returns:
- the configured max encoded binary length supported.
-
setMaxBinarySize
Gets the configured maximum size of an encoded Binary this decoder will allow before it throws anDecodeExceptionto indicate that a rule violation has occurred.- Parameters:
maximumSize- The maximum allowed encoded size value to allow before an decoding exception is thrown.- Returns:
- this
StreamDecoderStateinstance for chaining.
-
getMaxSymbolSize
default int getMaxSymbolSize()Gets the configured maximum size of an encoded Symbol this decoder will allow before it throws anDecodeExceptionto indicate that a rule violation has occurred.- Returns:
- the configured max encoded Symbol length supported.
-
setMaxSymbolSize
Gets the configured maximum length of an encoded Symbol this decoder will allow before it throws anDecodeExceptionto indicate that a rule violation has occurred.- Parameters:
maximumSize- The maximum allowed encoded size value to allow before an decoding exception is thrown.- Returns:
- this
StreamDecoderStateinstance for chaining.
-