Interface Decoder

  • All Known Implementing Classes:
    ProtonDecoder

    public interface Decoder
    Decode AMQP types from a byte stream
    • Method Detail

      • newDecoderState

        DecoderState newDecoderState()
        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.
        Returns:
        a newly constructed EncoderState instance.
      • getCachedDecoderState

        DecoderState getCachedDecoderState()
        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.
        Returns:
        a cached DecoderState linked to this Decoder instance that has been reset.
      • readBoolean

        java.lang.Boolean readBoolean​(ProtonBuffer buffer,
                                      DecoderState state)
                               throws DecodeException
        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 mark the and reset the input to make a further read attempt.
        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

        boolean readBoolean​(ProtonBuffer buffer,
                            DecoderState state,
                            boolean defaultValue)
                     throws DecodeException
        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 mark the and reset the input to make a further read attempt.
        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

        java.lang.Byte readByte​(ProtonBuffer buffer,
                                DecoderState state)
                         throws DecodeException
        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 mark the and reset the input to make a further read attempt.
        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

        byte readByte​(ProtonBuffer buffer,
                      DecoderState state,
                      byte defaultValue)
               throws DecodeException
        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 mark the and reset the input to make a further read attempt.
        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

        UnsignedByte readUnsignedByte​(ProtonBuffer buffer,
                                      DecoderState state)
                               throws DecodeException
        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 mark the and reset the input to make a further read attempt.
        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

        byte readUnsignedByte​(ProtonBuffer buffer,
                              DecoderState state,
                              byte defaultValue)
                       throws DecodeException
        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 mark the and reset the input to make a further read attempt.
        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

        java.lang.Character readCharacter​(ProtonBuffer buffer,
                                          DecoderState state)
                                   throws DecodeException
        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 mark the and reset the input to make a further read attempt.
        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

        char readCharacter​(ProtonBuffer buffer,
                           DecoderState state,
                           char defaultValue)
                    throws DecodeException
        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 mark the and reset the input to make a further read attempt.
        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

        Decimal32 readDecimal32​(ProtonBuffer buffer,
                                DecoderState state)
                         throws DecodeException
        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 mark the and reset the input to make a further read attempt.
        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

        Decimal64 readDecimal64​(ProtonBuffer buffer,
                                DecoderState state)
                         throws DecodeException
        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 mark the and reset the input to make a further read attempt.
        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

        Decimal128 readDecimal128​(ProtonBuffer buffer,
                                  DecoderState state)
                           throws DecodeException
        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 mark the and reset the input to make a further read attempt.
        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

        java.lang.Short readShort​(ProtonBuffer buffer,
                                  DecoderState state)
                           throws DecodeException
        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 mark the and reset the input to make a further read attempt.
        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

        short readShort​(ProtonBuffer buffer,
                        DecoderState state,
                        short defaultValue)
                 throws DecodeException
        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 mark the and reset the input to make a further read attempt.
        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

        UnsignedShort readUnsignedShort​(ProtonBuffer buffer,
                                        DecoderState state)
                                 throws DecodeException
        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 mark the and reset the input to make a further read attempt.
        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

        short readUnsignedShort​(ProtonBuffer buffer,
                                DecoderState state,
                                short defaultValue)
                         throws DecodeException
        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 mark the and reset the input to make a further read attempt.
        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

        int readUnsignedShort​(ProtonBuffer buffer,
                              DecoderState state,
                              int defaultValue)
                       throws DecodeException
        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 mark the and reset the input to make a further read attempt.
        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

        java.lang.Integer readInteger​(ProtonBuffer buffer,
                                      DecoderState state)
                               throws DecodeException
        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 mark the and reset the input to make a further read attempt.
        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

        int readInteger​(ProtonBuffer buffer,
                        DecoderState state,
                        int defaultValue)
                 throws DecodeException
        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 mark the and reset the input to make a further read attempt.
        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

        UnsignedInteger readUnsignedInteger​(ProtonBuffer buffer,
                                            DecoderState state)
                                     throws DecodeException
        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 mark the and reset the input to make a further read attempt.
        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

        int readUnsignedInteger​(ProtonBuffer buffer,
                                DecoderState state,
                                int defaultValue)
                         throws DecodeException
        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 mark the and reset the input to make a further read attempt.
        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

        long readUnsignedInteger​(ProtonBuffer buffer,
                                 DecoderState state,
                                 long defaultValue)
                          throws DecodeException
        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 mark the and reset the input to make a further read attempt.
        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

        java.lang.Long readLong​(ProtonBuffer buffer,
                                DecoderState state)
                         throws DecodeException
        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 mark the and reset the input to make a further read attempt.
        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

        long readLong​(ProtonBuffer buffer,
                      DecoderState state,
                      long defaultValue)
               throws DecodeException
        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 mark the and reset the input to make a further read attempt.
        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

        UnsignedLong readUnsignedLong​(ProtonBuffer buffer,
                                      DecoderState state)
                               throws DecodeException
        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 mark the and reset the input to make a further read attempt.
        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

        long readUnsignedLong​(ProtonBuffer buffer,
                              DecoderState state,
                              long defaultValue)
                       throws DecodeException
        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 mark the and reset the input to make a further read attempt.
        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

        java.lang.Float readFloat​(ProtonBuffer buffer,
                                  DecoderState state)
                           throws DecodeException
        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 mark the and reset the input to make a further read attempt.
        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

        float readFloat​(ProtonBuffer buffer,
                        DecoderState state,
                        float defaultValue)
                 throws DecodeException
        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 mark the and reset the input to make a further read attempt.
        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

        java.lang.Double readDouble​(ProtonBuffer buffer,
                                    DecoderState state)
                             throws DecodeException
        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 mark the and reset the input to make a further read attempt.
        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

        double readDouble​(ProtonBuffer buffer,
                          DecoderState state,
                          double defaultValue)
                   throws DecodeException
        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 mark the and reset the input to make a further read attempt.
        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

        Binary readBinary​(ProtonBuffer buffer,
                          DecoderState state)
                   throws DecodeException
        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 mark the and reset the input to make a further read attempt.
        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

        ProtonBuffer readBinaryAsBuffer​(ProtonBuffer buffer,
                                        DecoderState state)
                                 throws DecodeException
        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 mark the and reset the input to make a further read attempt.
        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

        DeliveryTag readDeliveryTag​(ProtonBuffer buffer,
                                    DecoderState state)
                             throws DecodeException
        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.
        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

        java.lang.String readString​(ProtonBuffer buffer,
                                    DecoderState state)
                             throws DecodeException
        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 mark the and reset the input to make a further read attempt.
        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

        Symbol readSymbol​(ProtonBuffer buffer,
                          DecoderState state)
                   throws DecodeException
        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 mark the and reset the input to make a further read attempt.
        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

        java.lang.String readSymbol​(ProtonBuffer buffer,
                                    DecoderState state,
                                    java.lang.String defaultValue)
                             throws DecodeException
        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 mark the and reset the input to make a further read attempt.
        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

        java.lang.Long readTimestamp​(ProtonBuffer buffer,
                                     DecoderState state)
                              throws DecodeException
        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 mark the and reset the input to make a further read attempt.
        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

        long readTimestamp​(ProtonBuffer buffer,
                           DecoderState state,
                           long defaultValue)
                    throws DecodeException
        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 mark the and reset the input to make a further read attempt.
        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

        java.util.UUID readUUID​(ProtonBuffer buffer,
                                DecoderState state)
                         throws DecodeException
        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 mark the and reset the input to make a further read attempt.
        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,
      • readObject

        java.lang.Object readObject​(ProtonBuffer buffer,
                                    DecoderState state)
                             throws DecodeException
        Reads an encoded value from the given ProtonBuffer an return it as an Object which the caller must then interpret.
        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

        <T> T readObject​(ProtonBuffer buffer,
                         DecoderState state,
                         java.lang.Class<T> clazz)
                  throws DecodeException
        Reads an encoded value from the given ProtonBuffer an return it as an Object which the caller must then interpret.
        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

        <T> T[] readMultiple​(ProtonBuffer buffer,
                             DecoderState state,
                             java.lang.Class<T> clazz)
                      throws DecodeException
        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.
        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.
      • readMap

        <K,​V> java.util.Map<K,​V> readMap​(ProtonBuffer buffer,
                                                     DecoderState state)
                                              throws DecodeException
        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 mark the and reset the input to make a further read attempt.
        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

        <V> java.util.List<V> readList​(ProtonBuffer buffer,
                                       DecoderState state)
                                throws DecodeException
        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 mark the and reset the input to make a further read attempt.
        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,
      • readNextTypeDecoder

        TypeDecoder<?> readNextTypeDecoder​(ProtonBuffer buffer,
                                           DecoderState state)
                                    throws DecodeException
        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.
        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

        TypeDecoder<?> peekNextTypeDecoder​(ProtonBuffer buffer,
                                           DecoderState state)
                                    throws DecodeException
        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.
        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

        <V> Decoder registerDescribedTypeDecoder​(DescribedTypeDecoder<V> 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.
        Type Parameters:
        V - The type that the decoder reads.
        Parameters:
        decoder - A DescribedTypeDecoder instance to be registered with this Decoder
        Returns:
        this Decoder instance.