Class ProtonDecoder

java.lang.Object
org.apache.qpid.protonj2.codec.decoders.ProtonDecoder
All Implemented Interfaces:
Decoder

public final class ProtonDecoder extends Object implements Decoder
The default AMQP Decoder implementation.
  • Constructor Details

    • ProtonDecoder

      public ProtonDecoder()
  • Method Details

    • newDecoderState

      public ProtonDecoderState newDecoderState()
      Description copied from interface: Decoder
      Creates a new DecoderState instance that can be used when interacting with the Decoder. For decoding that occurs on more than one thread while sharing a single Decoder instance a different state object per thread is required as the DecoderState object can retain some state information during the decode process that could be corrupted if more than one thread were to share a single instance. For single threaded decoding work the Decoder offers a utility cached DecoderState API that will return the same instance on each call which can reduce allocation overhead and make using the Decoder simpler.
      Specified by:
      newDecoderState in interface Decoder
      Returns:
      a newly constructed EncoderState instance.
    • getCachedDecoderState

      public ProtonDecoderState getCachedDecoderState()
      Description copied from interface: Decoder
      Return a singleton DecoderState instance that is meant to be shared within single threaded decoder interactions. If more than one thread makes use of this cached DecoderState the results of any decoding done using this state object is not guaranteed to be correct. The returned instance will have its reset method called to ensure that any previously stored state data is cleared before the next use.
      Specified by:
      getCachedDecoderState in interface Decoder
      Returns:
      a cached DecoderState linked to this Decoder instance that has been reset.
    • readObject

      public Object readObject(ProtonBuffer buffer, DecoderState state) throws DecodeException
      Description copied from interface: Decoder
      Reads an encoded value from the given ProtonBuffer an return it as an Object which the caller must then interpret.
      Specified by:
      readObject in interface Decoder
      Parameters:
      buffer - The ProtonBuffer where the read operation takes place.
      state - The DecoderState that the decoder can use when decoding.
      Returns:
      the value read from the provided byte source.
      Throws:
      DecodeException - if the value fails to decode is not able to be decoded.
    • readObject

      public <T> T readObject(ProtonBuffer buffer, DecoderState state, Class<T> clazz) throws DecodeException
      Description copied from interface: Decoder
      Reads an encoded value from the given ProtonBuffer an return it as an Object which the caller must then interpret.
      Specified by:
      readObject in interface Decoder
      Type Parameters:
      T - the type that will be used when casting and returning the decoded value.
      Parameters:
      buffer - The ProtonBuffer where the read operation takes place.
      state - The DecoderState that the decoder can use when decoding.
      clazz - The Class type that should be used to cast the returned value.
      Returns:
      the value read from the provided byte source.
      Throws:
      DecodeException - if the value fails to decode is not able to be decoded.
    • readMultiple

      public <T> T[] readMultiple(ProtonBuffer buffer, DecoderState state, Class<T> clazz) throws DecodeException
      Description copied from interface: Decoder
      Reads one or more encoded values from the given ProtonBuffer an return it as an array of Object instances which the caller must then interpret.
      Specified by:
      readMultiple in interface Decoder
      Type Parameters:
      T - the type that will be used when casting and returning the decoded value.
      Parameters:
      buffer - The ProtonBuffer where the read operation takes place.
      state - The DecoderState that the decoder can use when decoding.
      clazz - The Class type that should be used to cast the returned array.
      Returns:
      the value read from the provided byte source.
      Throws:
      DecodeException - if the value fails to decode is not able to be decoded.
    • readNextTypeDecoder

      public TypeDecoder<?> readNextTypeDecoder(ProtonBuffer buffer, DecoderState state) throws DecodeException
      Description copied from interface: Decoder
      Reads from the given ProtonBuffer instance and returns a TypeDecoder that can read the next encoded AMQP type from the buffer's bytes. If an error occurs attempting to read and determine the next type decoder an DecodeException is thrown.
      Specified by:
      readNextTypeDecoder in interface Decoder
      Parameters:
      buffer - The buffer to read from to determine the next TypeDecoder needed.
      state - The DecoderState value that can be used for intermediate decoding tasks.
      Returns:
      a TypeDecoder instance that can read the next type in the buffer.
      Throws:
      DecodeException - if an error occurs while reading the next type decoder.
    • peekNextTypeDecoder

      public TypeDecoder<?> peekNextTypeDecoder(ProtonBuffer buffer, DecoderState state) throws DecodeException
      Description copied from interface: Decoder
      Peeks ahead in the given ProtonBuffer instance and returns a TypeDecoder that can read the next encoded AMQP type from the buffer's bytes. If an error occurs attempting to read and determine the next type decoder an DecodeException is thrown. The underlying buffer is not modified as a result of the peek operation and the returned TypeDecoder will fail to properly read the type until the encoding bytes are read.
      Specified by:
      peekNextTypeDecoder in interface Decoder
      Parameters:
      buffer - The buffer to read from to determine the next TypeDecoder needed.
      state - The DecoderState value that can be used for intermediate decoding tasks.
      Returns:
      a TypeDecoder instance that can provide insight into the next type in the buffer.
      Throws:
      DecodeException - if an error occurs while peeking ahead for the next type decoder.
    • registerDescribedTypeDecoder

      public <V> ProtonDecoder registerDescribedTypeDecoder(DescribedTypeDecoder<V> decoder)
      Description copied from interface: Decoder
      Allows custom DescribedTypeDecoder instances to be registered with this Decoder which will be used if the described type encoding is encountered during decode operations.
      Specified by:
      registerDescribedTypeDecoder in interface Decoder
      Type Parameters:
      V - The type that the decoder reads.
      Parameters:
      decoder - A DescribedTypeDecoder instance to be registered with this Decoder
      Returns:
      this Decoder instance.
    • readBoolean

      public Boolean readBoolean(ProtonBuffer buffer, DecoderState state) throws DecodeException
      Description copied from interface: Decoder
      Reads an encoded Boolean value from the given ProtonBuffer assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should make a note of the current read position and reset the input to make a further read attempt.
      Specified by:
      readBoolean in interface Decoder
      Parameters:
      buffer - The ProtonBuffer where the read operation takes place.
      state - The DecoderState that the decoder can use when decoding.
      Returns:
      the value read from the provided byte source.
      Throws:
      DecodeException - if the value fails to decode is not of the expected type,
    • readBoolean

      public boolean readBoolean(ProtonBuffer buffer, DecoderState state, boolean defaultValue) throws DecodeException
      Description copied from interface: Decoder
      Reads an encoded Byte value from the given ProtonBuffer assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should make a note of the current read position and reset the input to make a further read attempt.
      Specified by:
      readBoolean in interface Decoder
      Parameters:
      buffer - The ProtonBuffer where the read operation takes place.
      state - The DecoderState that the decoder can use when decoding.
      defaultValue - A default value to return if the next encoded value is a Null encoding.
      Returns:
      the value read from the provided byte source.
      Throws:
      DecodeException - if the value fails to decode is not of the expected type,
    • readByte

      public Byte readByte(ProtonBuffer buffer, DecoderState state) throws DecodeException
      Description copied from interface: Decoder
      Reads an encoded Byte value from the given ProtonBuffer assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should make a note of the current read position and reset the input to make a further read attempt.
      Specified by:
      readByte in interface Decoder
      Parameters:
      buffer - The ProtonBuffer where the read operation takes place.
      state - The DecoderState that the decoder can use when decoding.
      Returns:
      the value read from the provided byte source.
      Throws:
      DecodeException - if the value fails to decode is not of the expected type,
    • readByte

      public byte readByte(ProtonBuffer buffer, DecoderState state, byte defaultValue) throws DecodeException
      Description copied from interface: Decoder
      Reads an encoded Byte value from the given ProtonBuffer assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should make a note of the current read position and reset the input to make a further read attempt.
      Specified by:
      readByte in interface Decoder
      Parameters:
      buffer - The ProtonBuffer where the read operation takes place.
      state - The DecoderState that the decoder can use when decoding.
      defaultValue - A default value to return if the next encoded value is a Null encoding.
      Returns:
      the value read from the provided byte source.
      Throws:
      DecodeException - if the value fails to decode is not of the expected type,
    • readUnsignedByte

      public UnsignedByte readUnsignedByte(ProtonBuffer buffer, DecoderState state) throws DecodeException
      Description copied from interface: Decoder
      Reads an encoded UnsignedByte value from the given ProtonBuffer assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should make a note of the current read position and reset the input to make a further read attempt.
      Specified by:
      readUnsignedByte in interface Decoder
      Parameters:
      buffer - The ProtonBuffer where the read operation takes place.
      state - The DecoderState that the decoder can use when decoding.
      Returns:
      the value read from the provided byte source.
      Throws:
      DecodeException - if the value fails to decode is not of the expected type,
    • readUnsignedByte

      public byte readUnsignedByte(ProtonBuffer buffer, DecoderState state, byte defaultValue) throws DecodeException
      Description copied from interface: Decoder
      Reads an encoded UnsignedByte value from the given ProtonBuffer assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should make a note of the current read position and reset the input to make a further read attempt.
      Specified by:
      readUnsignedByte in interface Decoder
      Parameters:
      buffer - The ProtonBuffer where the read operation takes place.
      state - The DecoderState that the decoder can use when decoding.
      defaultValue - A default value to return if the next encoded value is a Null encoding.
      Returns:
      the value read from the provided byte source.
      Throws:
      DecodeException - if the value fails to decode is not of the expected type,
    • readCharacter

      public Character readCharacter(ProtonBuffer buffer, DecoderState state) throws DecodeException
      Description copied from interface: Decoder
      Reads an encoded Character value from the given ProtonBuffer assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should make a note of the current read position and reset the input to make a further read attempt.
      Specified by:
      readCharacter in interface Decoder
      Parameters:
      buffer - The ProtonBuffer where the read operation takes place.
      state - The DecoderState that the decoder can use when decoding.
      Returns:
      the value read from the provided byte source.
      Throws:
      DecodeException - if the value fails to decode is not of the expected type,
    • readCharacter

      public char readCharacter(ProtonBuffer buffer, DecoderState state, char defaultValue) throws DecodeException
      Description copied from interface: Decoder
      Reads an encoded Character value from the given ProtonBuffer assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should make a note of the current read position and reset the input to make a further read attempt.
      Specified by:
      readCharacter in interface Decoder
      Parameters:
      buffer - The ProtonBuffer where the read operation takes place.
      state - The DecoderState that the decoder can use when decoding.
      defaultValue - A default value to return if the next encoded value is a Null encoding.
      Returns:
      the value read from the provided byte source.
      Throws:
      DecodeException - if the value fails to decode is not of the expected type,
    • readDecimal32

      public Decimal32 readDecimal32(ProtonBuffer buffer, DecoderState state) throws DecodeException
      Description copied from interface: Decoder
      Reads an encoded Decimal32 value from the given ProtonBuffer assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should make a note of the current read position and reset the input to make a further read attempt.
      Specified by:
      readDecimal32 in interface Decoder
      Parameters:
      buffer - The ProtonBuffer where the read operation takes place.
      state - The DecoderState that the decoder can use when decoding.
      Returns:
      the value read from the provided byte source.
      Throws:
      DecodeException - if the value fails to decode is not of the expected type,
    • readDecimal64

      public Decimal64 readDecimal64(ProtonBuffer buffer, DecoderState state) throws DecodeException
      Description copied from interface: Decoder
      Reads an encoded Decimal64 value from the given ProtonBuffer assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should make a note of the current read position and reset the input to make a further read attempt.
      Specified by:
      readDecimal64 in interface Decoder
      Parameters:
      buffer - The ProtonBuffer where the read operation takes place.
      state - The DecoderState that the decoder can use when decoding.
      Returns:
      the value read from the provided byte source.
      Throws:
      DecodeException - if the value fails to decode is not of the expected type,
    • readDecimal128

      public Decimal128 readDecimal128(ProtonBuffer buffer, DecoderState state) throws DecodeException
      Description copied from interface: Decoder
      Reads an encoded Decimal128 value from the given ProtonBuffer assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should make a note of the current read position and reset the input to make a further read attempt.
      Specified by:
      readDecimal128 in interface Decoder
      Parameters:
      buffer - The ProtonBuffer where the read operation takes place.
      state - The DecoderState that the decoder can use when decoding.
      Returns:
      the value read from the provided byte source.
      Throws:
      DecodeException - if the value fails to decode is not of the expected type,
    • readShort

      public Short readShort(ProtonBuffer buffer, DecoderState state) throws DecodeException
      Description copied from interface: Decoder
      Reads an encoded Short value from the given ProtonBuffer assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should make a note of the current read position and reset the input to make a further read attempt.
      Specified by:
      readShort in interface Decoder
      Parameters:
      buffer - The ProtonBuffer where the read operation takes place.
      state - The DecoderState that the decoder can use when decoding.
      Returns:
      the value read from the provided byte source.
      Throws:
      DecodeException - if the value fails to decode is not of the expected type,
    • readShort

      public short readShort(ProtonBuffer buffer, DecoderState state, short defaultValue) throws DecodeException
      Description copied from interface: Decoder
      Reads an encoded Short value from the given ProtonBuffer assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should make a note of the current read position and reset the input to make a further read attempt.
      Specified by:
      readShort in interface Decoder
      Parameters:
      buffer - The ProtonBuffer where the read operation takes place.
      state - The DecoderState that the decoder can use when decoding.
      defaultValue - A default value to return if the next encoded value is a Null encoding.
      Returns:
      the value read from the provided byte source.
      Throws:
      DecodeException - if the value fails to decode is not of the expected type,
    • readUnsignedShort

      public UnsignedShort readUnsignedShort(ProtonBuffer buffer, DecoderState state) throws DecodeException
      Description copied from interface: Decoder
      Reads an encoded UnsignedShort value from the given ProtonBuffer assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should make a note of the current read position and reset the input to make a further read attempt.
      Specified by:
      readUnsignedShort in interface Decoder
      Parameters:
      buffer - The ProtonBuffer where the read operation takes place.
      state - The DecoderState that the decoder can use when decoding.
      Returns:
      the value read from the provided byte source.
      Throws:
      DecodeException - if the value fails to decode is not of the expected type,
    • readUnsignedShort

      public short readUnsignedShort(ProtonBuffer buffer, DecoderState state, short defaultValue) throws DecodeException
      Description copied from interface: Decoder
      Reads an encoded UnsignedShort value from the given ProtonBuffer assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should make a note of the current read position and reset the input to make a further read attempt.
      Specified by:
      readUnsignedShort in interface Decoder
      Parameters:
      buffer - The ProtonBuffer where the read operation takes place.
      state - The DecoderState that the decoder can use when decoding.
      defaultValue - A default value to return if the next encoded value is a Null encoding.
      Returns:
      the value read from the provided byte source.
      Throws:
      DecodeException - if the value fails to decode is not of the expected type,
    • readUnsignedShort

      public int readUnsignedShort(ProtonBuffer buffer, DecoderState state, int defaultValue) throws DecodeException
      Description copied from interface: Decoder
      Reads an encoded UnsignedShort value from the given ProtonBuffer assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should make a note of the current read position and reset the input to make a further read attempt.
      Specified by:
      readUnsignedShort in interface Decoder
      Parameters:
      buffer - The ProtonBuffer where the read operation takes place.
      state - The DecoderState that the decoder can use when decoding.
      defaultValue - A default value to return if the next encoded value is a Null encoding.
      Returns:
      the value read from the provided byte source.
      Throws:
      DecodeException - if the value fails to decode is not of the expected type,
    • readInteger

      public Integer readInteger(ProtonBuffer buffer, DecoderState state) throws DecodeException
      Description copied from interface: Decoder
      Reads an encoded Integer value from the given ProtonBuffer assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should make a note of the current read position and reset the input to make a further read attempt.
      Specified by:
      readInteger in interface Decoder
      Parameters:
      buffer - The ProtonBuffer where the read operation takes place.
      state - The DecoderState that the decoder can use when decoding.
      Returns:
      the value read from the provided byte source.
      Throws:
      DecodeException - if the value fails to decode is not of the expected type,
    • readInteger

      public int readInteger(ProtonBuffer buffer, DecoderState state, int defaultValue) throws DecodeException
      Description copied from interface: Decoder
      Reads an encoded Integer value from the given ProtonBuffer assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should make a note of the current read position and reset the input to make a further read attempt.
      Specified by:
      readInteger in interface Decoder
      Parameters:
      buffer - The ProtonBuffer where the read operation takes place.
      state - The DecoderState that the decoder can use when decoding.
      defaultValue - A default value to return if the next encoded value is a Null encoding.
      Returns:
      the value read from the provided byte source.
      Throws:
      DecodeException - if the value fails to decode is not of the expected type,
    • readUnsignedInteger

      public UnsignedInteger readUnsignedInteger(ProtonBuffer buffer, DecoderState state) throws DecodeException
      Description copied from interface: Decoder
      Reads an encoded UnsignedInteger value from the given ProtonBuffer assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should make a note of the current read position and reset the input to make a further read attempt.
      Specified by:
      readUnsignedInteger in interface Decoder
      Parameters:
      buffer - The ProtonBuffer where the read operation takes place.
      state - The DecoderState that the decoder can use when decoding.
      Returns:
      the value read from the provided byte source.
      Throws:
      DecodeException - if the value fails to decode is not of the expected type,
    • readUnsignedInteger

      public int readUnsignedInteger(ProtonBuffer buffer, DecoderState state, int defaultValue) throws DecodeException
      Description copied from interface: Decoder
      Reads an encoded UnsignedInteger value from the given ProtonBuffer assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should make a note of the current read position and reset the input to make a further read attempt.
      Specified by:
      readUnsignedInteger in interface Decoder
      Parameters:
      buffer - The ProtonBuffer where the read operation takes place.
      state - The DecoderState that the decoder can use when decoding.
      defaultValue - A default value to return if the next encoded value is a Null encoding.
      Returns:
      the value read from the provided byte source.
      Throws:
      DecodeException - if the value fails to decode is not of the expected type,
    • readUnsignedInteger

      public long readUnsignedInteger(ProtonBuffer buffer, DecoderState state, long defaultValue) throws DecodeException
      Description copied from interface: Decoder
      Reads an encoded UnsignedInteger value from the given ProtonBuffer assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should make a note of the current read position and reset the input to make a further read attempt.
      Specified by:
      readUnsignedInteger in interface Decoder
      Parameters:
      buffer - The ProtonBuffer where the read operation takes place.
      state - The DecoderState that the decoder can use when decoding.
      defaultValue - A default value to return if the next encoded value is a Null encoding.
      Returns:
      the value read from the provided byte source.
      Throws:
      DecodeException - if the value fails to decode is not of the expected type,
    • readLong

      public Long readLong(ProtonBuffer buffer, DecoderState state) throws DecodeException
      Description copied from interface: Decoder
      Reads an encoded Long value from the given ProtonBuffer assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should make a note of the current read position and reset the input to make a further read attempt.
      Specified by:
      readLong in interface Decoder
      Parameters:
      buffer - The ProtonBuffer where the read operation takes place.
      state - The DecoderState that the decoder can use when decoding.
      Returns:
      the value read from the provided byte source.
      Throws:
      DecodeException - if the value fails to decode is not of the expected type,
    • readLong

      public long readLong(ProtonBuffer buffer, DecoderState state, long defaultValue) throws DecodeException
      Description copied from interface: Decoder
      Reads an encoded Long value from the given ProtonBuffer assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should make a note of the current read position and reset the input to make a further read attempt.
      Specified by:
      readLong in interface Decoder
      Parameters:
      buffer - The ProtonBuffer where the read operation takes place.
      state - The DecoderState that the decoder can use when decoding.
      defaultValue - A default value to return if the next encoded value is a Null encoding.
      Returns:
      the value read from the provided byte source.
      Throws:
      DecodeException - if the value fails to decode is not of the expected type,
    • readUnsignedLong

      public UnsignedLong readUnsignedLong(ProtonBuffer buffer, DecoderState state) throws DecodeException
      Description copied from interface: Decoder
      Reads an encoded UnsignedLong value from the given ProtonBuffer assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should make a note of the current read position and reset the input to make a further read attempt.
      Specified by:
      readUnsignedLong in interface Decoder
      Parameters:
      buffer - The ProtonBuffer where the read operation takes place.
      state - The DecoderState that the decoder can use when decoding.
      Returns:
      the value read from the provided byte source.
      Throws:
      DecodeException - if the value fails to decode is not of the expected type,
    • readUnsignedLong

      public long readUnsignedLong(ProtonBuffer buffer, DecoderState state, long defaultValue) throws DecodeException
      Description copied from interface: Decoder
      Reads an encoded UnsignedLong value from the given ProtonBuffer assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should make a note of the current read position and reset the input to make a further read attempt.
      Specified by:
      readUnsignedLong in interface Decoder
      Parameters:
      buffer - The ProtonBuffer where the read operation takes place.
      state - The DecoderState that the decoder can use when decoding.
      defaultValue - A default value to return if the next encoded value is a Null encoding.
      Returns:
      the value read from the provided byte source.
      Throws:
      DecodeException - if the value fails to decode is not of the expected type,
    • readFloat

      public Float readFloat(ProtonBuffer buffer, DecoderState state) throws DecodeException
      Description copied from interface: Decoder
      Reads an encoded Float value from the given ProtonBuffer assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should make a note of the current read position and reset the input to make a further read attempt.
      Specified by:
      readFloat in interface Decoder
      Parameters:
      buffer - The ProtonBuffer where the read operation takes place.
      state - The DecoderState that the decoder can use when decoding.
      Returns:
      the value read from the provided byte source.
      Throws:
      DecodeException - if the value fails to decode is not of the expected type,
    • readFloat

      public float readFloat(ProtonBuffer buffer, DecoderState state, float defaultValue) throws DecodeException
      Description copied from interface: Decoder
      Reads an encoded Float value from the given ProtonBuffer assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should make a note of the current read position and reset the input to make a further read attempt.
      Specified by:
      readFloat in interface Decoder
      Parameters:
      buffer - The ProtonBuffer where the read operation takes place.
      state - The DecoderState that the decoder can use when decoding.
      defaultValue - A default value to return if the next encoded value is a Null encoding.
      Returns:
      the value read from the provided byte source.
      Throws:
      DecodeException - if the value fails to decode is not of the expected type,
    • readDouble

      public Double readDouble(ProtonBuffer buffer, DecoderState state) throws DecodeException
      Description copied from interface: Decoder
      Reads an encoded Double value from the given ProtonBuffer assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should make a note of the current read position and reset the input to make a further read attempt.
      Specified by:
      readDouble in interface Decoder
      Parameters:
      buffer - The ProtonBuffer where the read operation takes place.
      state - The DecoderState that the decoder can use when decoding.
      Returns:
      the value read from the provided byte source.
      Throws:
      DecodeException - if the value fails to decode is not of the expected type,
    • readDouble

      public double readDouble(ProtonBuffer buffer, DecoderState state, double defaultValue) throws DecodeException
      Description copied from interface: Decoder
      Reads an encoded Double value from the given ProtonBuffer assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should make a note of the current read position and reset the input to make a further read attempt.
      Specified by:
      readDouble in interface Decoder
      Parameters:
      buffer - The ProtonBuffer where the read operation takes place.
      state - The DecoderState that the decoder can use when decoding.
      defaultValue - A default value to return if the next encoded value is a Null encoding.
      Returns:
      the value read from the provided byte source.
      Throws:
      DecodeException - if the value fails to decode is not of the expected type,
    • readBinary

      public Binary readBinary(ProtonBuffer buffer, DecoderState state) throws DecodeException
      Description copied from interface: Decoder
      Reads an encoded Binary value from the given ProtonBuffer assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should make a note of the current read position the and reset the input to make a further read attempt.

      The resulting Binary instance will contain a read-only view of the decoded bytes and any calls to access the underlying buffer will return a read-only ProtonBuffer.

      Specified by:
      readBinary in interface Decoder
      Parameters:
      buffer - The ProtonBuffer where the read operation takes place.
      state - The DecoderState that the decoder can use when decoding.
      Returns:
      the value read from the provided byte source.
      Throws:
      DecodeException - if the value fails to decode is not of the expected type,
    • readBinaryAsBuffer

      public ProtonBuffer readBinaryAsBuffer(ProtonBuffer buffer, DecoderState state) throws DecodeException
      Description copied from interface: Decoder
      Reads an encoded Binary value from the given ProtonBuffer assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should make a note of the current read position and reset the input to make a further read attempt.

      The resulting ProtonBuffer will be a read-only view of the bytes read and to maximize performance the incoming buffer being decoded should also be read only otherwise the result is likely to be a deep copy of the source bytes.

      Specified by:
      readBinaryAsBuffer in interface Decoder
      Parameters:
      buffer - The ProtonBuffer where the read operation takes place.
      state - The DecoderState that the decoder can use when decoding.
      Returns:
      the value read from the provided byte source and returned in a ProtonBuffer.
      Throws:
      DecodeException - if the value fails to decode is not of the expected type,
    • readDeliveryTag

      public DeliveryTag readDeliveryTag(ProtonBuffer buffer, DecoderState state) throws DecodeException
      Description copied from interface: Decoder
      This method expects to read a Binary encoded type from the provided buffer and constructs a DeliveryTag type that wraps the bytes encoded. If the encoding is a NULL AMQP type then this method returns null.
      Specified by:
      readDeliveryTag in interface Decoder
      Parameters:
      buffer - The buffer to read a Binary encoded value from
      state - The current encoding state.
      Returns:
      a new DeliveryTag instance or null if an AMQP NULL encoding is found.
      Throws:
      DecodeException - if an error occurs while decoding the DeliveryTag instance.
    • readString

      public String readString(ProtonBuffer buffer, DecoderState state) throws DecodeException
      Description copied from interface: Decoder
      Reads an encoded String value from the given ProtonBuffer assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should make a note of the current read position and reset the input to make a further read attempt.
      Specified by:
      readString in interface Decoder
      Parameters:
      buffer - The ProtonBuffer where the read operation takes place.
      state - The DecoderState that the decoder can use when decoding.
      Returns:
      the value read from the provided byte source.
      Throws:
      DecodeException - if the value fails to decode is not of the expected type,
    • readSymbol

      public Symbol readSymbol(ProtonBuffer buffer, DecoderState state) throws DecodeException
      Description copied from interface: Decoder
      Reads an encoded Symbol value from the given ProtonBuffer assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should make a note of the current read position and reset the input to make a further read attempt.
      Specified by:
      readSymbol in interface Decoder
      Parameters:
      buffer - The ProtonBuffer where the read operation takes place.
      state - The DecoderState that the decoder can use when decoding.
      Returns:
      the value read from the provided byte source.
      Throws:
      DecodeException - if the value fails to decode is not of the expected type,
    • readSymbol

      public String readSymbol(ProtonBuffer buffer, DecoderState state, String defaultValue) throws DecodeException
      Description copied from interface: Decoder
      Reads an encoded String value from the given ProtonBuffer assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should make a note of the current read position and reset the input to make a further read attempt.
      Specified by:
      readSymbol in interface Decoder
      Parameters:
      buffer - The ProtonBuffer where the read operation takes place.
      state - The DecoderState that the decoder can use when decoding.
      defaultValue - A default value to return if the next encoded value is a Null encoding.
      Returns:
      the value read from the provided byte source.
      Throws:
      DecodeException - if the value fails to decode is not of the expected type,
    • readTimestamp

      public Long readTimestamp(ProtonBuffer buffer, DecoderState state) throws DecodeException
      Description copied from interface: Decoder
      Reads an encoded AMQP time stamp value from the given ProtonBuffer assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should make a note of the current read position and reset the input to make a further read attempt.
      Specified by:
      readTimestamp in interface Decoder
      Parameters:
      buffer - The ProtonBuffer where the read operation takes place.
      state - The DecoderState that the decoder can use when decoding.
      Returns:
      the value read from the provided byte source and return a Long with the time value.
      Throws:
      DecodeException - if the value fails to decode is not of the expected type,
    • readTimestamp

      public long readTimestamp(ProtonBuffer buffer, DecoderState state, long defaultValue) throws DecodeException
      Description copied from interface: Decoder
      Reads an encoded AMQP time stamp value from the given ProtonBuffer assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should make a note of the current read position and reset the input to make a further read attempt.
      Specified by:
      readTimestamp in interface Decoder
      Parameters:
      buffer - The ProtonBuffer where the read operation takes place.
      state - The DecoderState that the decoder can use when decoding.
      defaultValue - A default value to return if the next encoded value is a Null encoding.
      Returns:
      the value read from the provided byte source.
      Throws:
      DecodeException - if the value fails to decode is not of the expected type,
    • readUUID

      public UUID readUUID(ProtonBuffer buffer, DecoderState state) throws DecodeException
      Description copied from interface: Decoder
      Reads an encoded UUID value from the given ProtonBuffer assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should make a note of the current read position and reset the input to make a further read attempt.
      Specified by:
      readUUID in interface Decoder
      Parameters:
      buffer - The ProtonBuffer where the read operation takes place.
      state - The DecoderState that the decoder can use when decoding.
      Returns:
      the value read from the provided byte source.
      Throws:
      DecodeException - if the value fails to decode is not of the expected type,
    • readMap

      public <K, V> Map<K,V> readMap(ProtonBuffer buffer, DecoderState state) throws DecodeException
      Description copied from interface: Decoder
      Reads an encoded Map value from the given ProtonBuffer assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should make a note of the current read position and reset the input to make a further read attempt.
      Specified by:
      readMap in interface Decoder
      Type Parameters:
      K - The key type for the map that is being read.
      V - The value type for the map that is being read.
      Parameters:
      buffer - The ProtonBuffer where the read operation takes place.
      state - The DecoderState that the decoder can use when decoding.
      Returns:
      the value read from the provided byte source.
      Throws:
      DecodeException - if the value fails to decode is not of the expected type,
    • readList

      public <V> List<V> readList(ProtonBuffer buffer, DecoderState state) throws DecodeException
      Description copied from interface: Decoder
      Reads an encoded List value from the given ProtonBuffer assuming that the next value in the byte stream is that type. The operation fails if the next encoded type is not what was expected. If the caller wishes to recover from failed decode attempt they should make a note of the current read position and reset the input to make a further read attempt.
      Specified by:
      readList in interface Decoder
      Type Parameters:
      V - The value type for the list being read.
      Parameters:
      buffer - The ProtonBuffer where the read operation takes place.
      state - The DecoderState that the decoder can use when decoding.
      Returns:
      the value read from the provided byte source.
      Throws:
      DecodeException - if the value fails to decode is not of the expected type,