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 Type
    Method
    Description
    decodeUTF8(ProtonBuffer buffer, int length)
    Given a set of UTF-8 encoded bytes decode and return the String that represents that UTF-8 value.
    default DecoderState
    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.
     
    default int
    Gets the configured maximum depth that nested types such as Lists, Maps and Arrays can have before a DecodeException is thrown.
    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.
    default DecoderState
    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.
    Resets any intermediate state back to default values.
    default DecoderState
    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 error in cases where the depth of encoding exceeds what the environment is thought to be able to support.
    default DecoderState
    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 DecoderState instance.
    • getDecoder

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

      String decodeUTF8(ProtonBuffer buffer, int length) throws DecodeException
      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

      default DecoderState 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 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 a DecodeException is thrown.
      Returns:
      the configured maximum depth of nested types.
    • increaseDepth

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

      default DecoderState 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 DecoderState 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 DecoderState 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 DecoderState instance for chaining.