Class AbstractDescribedMapTypeDecoder<D,K>

java.lang.Object
org.apache.qpid.protonj2.codec.decoders.AbstractDescribedTypeDecoder<D>
org.apache.qpid.protonj2.codec.decoders.AbstractDescribedMapTypeDecoder<D,K>
Type Parameters:
D - The described type that this map type implements
K - The key type for the elements in the described type map
All Implemented Interfaces:
DescribedTypeDecoder<D>, StreamDescribedTypeDecoder<D>, StreamTypeDecoder<D>, TypeDecoder<D>
Direct Known Subclasses:
ApplicationPropertiesTypeDecoder, DeliveryAnnotationsTypeDecoder, FooterTypeDecoder, MessageAnnotationsTypeDecoder

public abstract class AbstractDescribedMapTypeDecoder<D,K> extends AbstractDescribedTypeDecoder<D>
Abstract base for all List based Described Type decoders which implements the generic methods common to all the implementations.
  • Constructor Details

    • AbstractDescribedMapTypeDecoder

      public AbstractDescribedMapTypeDecoder()
  • Method Details

    • readValue

      public final D readValue(ProtonBuffer buffer, DecoderState state) throws DecodeException
      Description copied from interface: TypeDecoder
      Reads the next type from the given buffer and returns it.
      Parameters:
      buffer - the source of encoded data.
      state - the current state of the decoder.
      Returns:
      the next instance in the stream that this decoder handles.
      Throws:
      DecodeException - if an error is encountered while reading the next value.
    • readValue

      public final D readValue(InputStream stream, StreamDecoderState state) throws DecodeException
      Description copied from interface: StreamTypeDecoder
      Reads the next type from the given buffer and returns it.
      Parameters:
      stream - the source of encoded data.
      state - the current state of the decoder.
      Returns:
      the next instance in the stream that this decoder handles.
      Throws:
      DecodeException - if an error is encountered while reading the next value.
    • skipValue

      public final void skipValue(ProtonBuffer buffer, DecoderState state) throws DecodeException
      Description copied from interface: TypeDecoder
      Skips over the bytes that compose the type this descriptor decodes.

      Skipping values can be used when the type is not used or processed by the application doing the decoding. An example might be an AMQP message decoder that only needs to decode certain parts of the message and not others.

      Parameters:
      buffer - The buffer that contains the encoded type.
      state - The decoder state.
      Throws:
      DecodeException - if an error occurs while skipping the value.
    • skipValue

      public final void skipValue(InputStream stream, StreamDecoderState state) throws DecodeException
      Description copied from interface: StreamTypeDecoder
      Skips over the bytes that compose the type this descriptor decodes.

      Skipping values can be used when the type is not used or processed by the application doing the decoding. An example might be an AMQP message decoder that only needs to decode certain parts of the message and not others.

      Parameters:
      stream - The stream that contains the encoded type.
      state - The decoder state.
      Throws:
      DecodeException - if an error occurs while skipping the value.
    • readArrayElements

      public final D[] readArrayElements(ProtonBuffer buffer, DecoderState state, int count) throws DecodeException
      Description copied from interface: TypeDecoder
      Reads a series of this type that have been encoded into the body of an Array type.

      When encoded into an array the values are encoded in series following the identifier for the type, this method is given a count of the number of instances that are encoded and should read each in succession and returning them in a new array.

      Parameters:
      buffer - the source of encoded data.
      state - the current state of the decoder.
      count - the number of array elements encoded in the buffer.
      Returns:
      the next instance in the stream that this decoder handles.
      Throws:
      DecodeException - if an error is encountered while reading the next value.
    • readArrayElements

      public final D[] readArrayElements(InputStream stream, StreamDecoderState state, int count) throws DecodeException
      Description copied from interface: StreamTypeDecoder
      Reads a series of this type that have been encoded into the body of an Array type.

      When encoded into an array the values are encoded in series following the identifier for the type, this method is given a count of the number of instances that are encoded and should read each in succession and returning them in a new array.

      Parameters:
      stream - the source of encoded data.
      state - the current state of the decoder.
      count - the number of array elements encoded in the buffer.
      Returns:
      the next instance in the stream that this decoder handles.
      Throws:
      DecodeException - if an error is encountered while reading the next value.
    • createDescribed

      protected abstract D createDescribed(Map<K,Object> map)
      Called from read method to wrap the decoded Map in the described type wrapper that this Map type manages.
      Parameters:
      map - The decoded map that this type handles.
      Returns:
      the described type wrapper around the decoded Map.
    • readKey

      protected abstract K readKey(ProtonBuffer buffer, Decoder decoder, DecoderState state) throws DecodeException
      Called during decoding of the described Map body to allow the implementation to read the map key using the optimal decoder API for the type of key stored in the map.
      Parameters:
      buffer - The buffer where the encoded Map body lives.
      decoder - The Decoder to use for reading the key.
      state - The DecoderState to use while reading the key.
      Returns:
      the newly read Map key.
      Throws:
      DecodeException - if an error occurs while reading the map key.
    • readKey

      protected abstract K readKey(InputStream stream, StreamDecoder decoder, StreamDecoderState state) throws DecodeException
      Called during decoding of the described Map body to allow the implementation to read the map key using the optimal decoder API for the type of key stored in the map.
      Parameters:
      stream - The bytes stream where the encoded Map body lives.
      decoder - The Decoder to use for reading the key.
      state - The DecoderState to use while reading the key.
      Returns:
      the newly read Map key.
      Throws:
      DecodeException - if an error occurs while reading the map key.
    • scanMapEntries

      protected void scanMapEntries(ProtonBuffer buffer, DecoderState state, ScanningContext<K> context, BiConsumer<K,Object> matchConsumer) throws DecodeException
      Throws:
      DecodeException
    • scanMapEntries

      protected void scanMapEntries(InputStream stream, StreamDecoderState state, StreamScanningContext<K> context, BiConsumer<K,Object> matchConsumer) throws DecodeException
      Throws:
      DecodeException
    • validateAndGetCount

      protected static final int validateAndGetCount(int size, ProtonBuffer buffer, DecoderState state, MapTypeDecoder decoder) throws DecodeException
      Throws:
      DecodeException
    • validateAndGetCount

      protected static final int validateAndGetCount(int size, InputStream stream, StreamDecoderState state, MapTypeDecoder decoder) throws DecodeException
      Throws:
      DecodeException