Interface MapTypeDecoder

All Superinterfaces:
PrimitiveTypeDecoder<Map>, StreamTypeDecoder<Map>, TypeDecoder<Map>
All Known Implementing Classes:
AbstractMapTypeDecoder, Map32TypeDecoder, Map8TypeDecoder

public interface MapTypeDecoder extends PrimitiveTypeDecoder<Map>
Base interface for all AMQP Map type value decoders.
  • Method Details

    • getTypeClass

      default Class<Map> getTypeClass()
      Specified by:
      getTypeClass in interface StreamTypeDecoder<Map>
      Specified by:
      getTypeClass in interface TypeDecoder<Map>
      Returns:
      the Class that this decoder handles.
    • readCount

      int readCount(ProtonBuffer buffer, DecoderState state) throws DecodeException
      Reads the count of entries in the encoded Map.

      This value is the total count of all key values pairs, and should always be an even number as Map types cannot be unbalanced.

      Parameters:
      buffer - The buffer containing the encoded Map type.
      state - The DecoderState used during this decode.
      Returns:
      the number of elements that we encoded from the original Map.
      Throws:
      DecodeException - if an error occurs reading the value
    • readCount

      int readCount(InputStream stream, StreamDecoderState state) throws DecodeException
      Reads the count of entries in the encoded Map.

      This value is the total count of all key values pairs, and should always be an even number as Map types cannot be unbalanced.

      Parameters:
      stream - The InputStream containing the encoded Map type.
      state - The StreamDecoderState used during this decode.
      Returns:
      the number of elements that we encoded from the original Map.
      Throws:
      DecodeException - if an error occurs reading the value
    • scanKeys

      <KeyType> void scanKeys(ProtonBuffer buffer, DecoderState state, ScanningContext<KeyType> context, BiConsumer<KeyType,Object> matchConsumer) throws DecodeException
      Scan the encoded Map keys matching on predetermined key value encodings to quickly find mappings that are of interest and then only decoding the value portion of the matched key / value pair. This allows for quick checks of incoming Map types without the performance penalty of a full decode. After the method returns the contexts of the encoded Map in the provided buffer will have been consumed and the next type can be decoded.

      Each matching key / value mapping triggers a call to the provided BiConsumer with the key that triggered the match (generally a cached non-decoded value) and the decoded value mapped to that key. The caller should use the consumer to trigger actions based on the matches found in the mappings which avoid full decodings of large maps when only a limited set of values is desired.

      Type Parameters:
      KeyType - The key type is used when calling the match consumer
      Parameters:
      buffer - The buffer containing the encoded Map type.
      state - The DecoderState used during this decode.
      context - The previously created and configured ScanningContext
      matchConsumer - The consumer that will be notified when a matching key is found.
      Throws:
      DecodeException - if an error occurs reading the value
    • scanKeys

      <KeyType> void scanKeys(InputStream stream, StreamDecoderState state, StreamScanningContext<KeyType> context, BiConsumer<KeyType,Object> matchConsumer) throws DecodeException
      Scan the encoded Map keys matching on predetermined key value encodings to quickly find mappings that are of interest and then only decoding the value portion of the matched key / value pair. This allows for quick checks of incoming Map types without the performance penalty of a full decode. After the method returns the contexts of the encoded Map in the provided stream will have been consumed and the next type can be decoded.

      Each matching key / value mapping triggers a call to the provided BiConsumer with the key that triggered the match (generally a cached non-decoded value) and the decoded value mapped to that key. The caller should use the consumer to trigger actions based on the matches found in the mappings which avoid full decodings of large maps when only a limited set of values is desired.

      Type Parameters:
      KeyType - The key type is used when calling the match consumer
      Parameters:
      stream - The InputStream containing the encoded Map type.
      state - The StreamDecoderState used during this decode.
      context - The previously created and configured ScanningContext
      matchConsumer - The consumer that will be notified when a matching key is found.
      Throws:
      DecodeException - if an error occurs reading the value