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
    Modifier and Type
    Field
    Description
    static final int
     
  • Method Summary

    Modifier and Type
    Method
    Description
    decodeUTF8(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 decreased
     
    default int
    Gets the configured maximum depth that nested types such as Lists, Maps and Arrays can have before a DecodeException is thrown to allow the decoder to errors in cases where the depth of encoding exceeds that the environment can support.
    default int
    Gets the configured maximum size of an encoded array this decoder will allow before it throws an DecodeException to indicate that a rule violation has occurred.
    default int
    Gets the configured maximum length of an encoded Binary this decoder will allow before it throws an DecodeException to indicate that a rule violation has occurred.
    default int
    Gets the configured maximum indicated encoded size of a List this decoder will allow before it throws an DecodeException to indicate that a rule violation has occurred.
    default int
    Gets the configured maximum indicated encoded size of a List this decoder will allow before it throws an DecodeException to indicate that a rule violation has occurred.
    default int
    Gets the configured maximum size of an encoded string this decoder will allow before it throws an DecodeException to indicate that a rule violation has occurred.
    default int
    Gets the configured maximum size of an encoded Symbol this decoder will allow before it throws an DecodeException to indicate that a rule violation has occurred.
    default int
    Gets 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.
    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 a DecodeException is thrown to allow the decoder to errors in cases where the depth of encoding exceeds that the environment can support.
    setMaxArraySize(int maximumSize)
    Sets the configured maximum size of an encoded array this decoder will allow before it throws an DecodeException to indicate that a rule violation has occurred.
    setMaxBinarySize(int maximumSize)
    Gets the configured maximum size of an encoded Binary this decoder will allow before it throws an DecodeException to indicate that a rule violation has occurred.
    setMaxListSize(int maximumSize)
    Sets the configured maximum indicated encoded size of a List this decoder will allow before it throws an DecodeException to indicate that a rule violation has occurred.
    setMaxMapSize(int maximumSize)
    Sets the configured maximum indicated encoded size of a Map this decoder will allow before it throws an DecodeException to indicate that a rule violation has occurred.
    setMaxStringSize(int maximumSize)
    Sets the configured maximum size of an encoded string this decoder will allow before it throws an DecodeException to indicate that a rule violation has occurred.
    setMaxSymbolSize(int maximumSize)
    Gets the configured maximum length of an encoded Symbol this decoder will allow before it throws an DecodeException to indicate that a rule violation has occurred.
    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

      Resets any intermediate state back to default values.
      Returns:
      this StreamDecoderState instance.
    • getDecoder

      StreamDecoder getDecoder()
      Returns:
      the StreamDecoder that created this state object
    • decodeUTF8

      String decodeUTF8(InputStream stream, int length) throws DecodeException
      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 passed InputStream 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

      default StreamDecoderState setDepthLimit(int limit)
      Sets the configured maximum depth that nested types such as Lists, Maps and Arrays can have before a DecodeException is 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 StreamDecoderState instance 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 a DecodeException is 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

      default StreamDecoderState increaseDepth() throws DecodeException
      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 an DecodeException if that depth value is exceeded.
      Returns:
      this StreamDecoderState instance for chaining.
      Throws:
      DecodeException - if a set decoding depth limit is exceeded.
    • decreaseDepth

      default StreamDecoderState decreaseDepth()
      During decode as on level of complex type decode completes the level value is decreased
      Returns:
      this StreamDecoderState instance 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

      default StreamDecoderState 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. 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 StreamDecoderState instance for chaining.
    • getMaxStringSize

      default int getMaxStringSize()
      Gets the configured maximum size of an encoded string this decoder will allow before it throws an DecodeException to indicate that a rule violation has occurred.
      Returns:
      the configured max encoded string size supported.
    • setMaxStringSize

      default StreamDecoderState setMaxStringSize(int maximumSize)
      Sets the configured maximum size of an encoded string this decoder will allow before it throws an DecodeException to 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 StreamDecoderState instance for chaining.
    • getMaxArraySize

      default int getMaxArraySize()
      Gets the configured maximum size of an encoded array this decoder will allow before it throws an DecodeException to indicate that a rule violation has occurred.
      Returns:
      the configured max encoded array size supported.
    • setMaxArraySize

      default StreamDecoderState setMaxArraySize(int maximumSize)
      Sets the configured maximum size of an encoded array this decoder will allow before it throws an DecodeException to 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 StreamDecoderState instance for chaining.
    • getMaxListSize

      default int getMaxListSize()
      Gets the configured maximum indicated encoded size of a List this decoder will allow before it throws an DecodeException to indicate that a rule violation has occurred.
      Returns:
      the configured max encoded list elements supported.
    • setMaxListSize

      default StreamDecoderState setMaxListSize(int maximumSize)
      Sets the configured maximum indicated encoded size of a List this decoder will allow before it throws an DecodeException to 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 StreamDecoderState instance for chaining.
    • getMaxMapSize

      default int getMaxMapSize()
      Gets the configured maximum indicated encoded size of a List this decoder will allow before it throws an DecodeException to indicate that a rule violation has occurred.
      Returns:
      the configured max encoded list size supported.
    • setMaxMapSize

      default StreamDecoderState setMaxMapSize(int maximumSize)
      Sets the configured maximum indicated encoded size of a Map this decoder will allow before it throws an DecodeException to 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 StreamDecoderState instance for chaining.
    • getMaxBinarySize

      default int getMaxBinarySize()
      Gets the configured maximum length of an encoded Binary this decoder will allow before it throws an DecodeException to indicate that a rule violation has occurred.
      Returns:
      the configured max encoded binary length supported.
    • setMaxBinarySize

      default StreamDecoderState setMaxBinarySize(int maximumSize)
      Gets the configured maximum size of an encoded Binary this decoder will allow before it throws an DecodeException to 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 StreamDecoderState instance for chaining.
    • getMaxSymbolSize

      default int getMaxSymbolSize()
      Gets the configured maximum size of an encoded Symbol this decoder will allow before it throws an DecodeException to indicate that a rule violation has occurred.
      Returns:
      the configured max encoded Symbol length supported.
    • setMaxSymbolSize

      default StreamDecoderState setMaxSymbolSize(int maximumSize)
      Gets the configured maximum length of an encoded Symbol this decoder will allow before it throws an DecodeException to 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 StreamDecoderState instance for chaining.