Interface MapTypeDecoder
- All Superinterfaces:
PrimitiveTypeDecoder<Map>
,StreamTypeDecoder<Map>
,TypeDecoder<Map>
- All Known Implementing Classes:
AbstractMapTypeDecoder
,Map32TypeDecoder
,Map8TypeDecoder
-
Method Summary
Modifier and TypeMethodDescriptionint
readCount
(InputStream stream, StreamDecoderState state) Reads the count of entries in the encoded Map.int
readCount
(ProtonBuffer buffer, DecoderState state) Reads the count of entries in the encoded Map.<KeyType> void
scanKeys
(InputStream stream, StreamDecoderState state, StreamScanningContext<KeyType> context, BiConsumer<KeyType, Object> matchConsumer) Scan the encodedMap
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.<KeyType> void
scanKeys
(ProtonBuffer buffer, DecoderState state, ScanningContext<KeyType> context, BiConsumer<KeyType, Object> matchConsumer) Scan the encodedMap
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.Methods inherited from interface org.apache.qpid.protonj2.codec.decoders.PrimitiveTypeDecoder
getTypeCode, isJavaPrimitive, isPrimitive
Methods inherited from interface org.apache.qpid.protonj2.codec.StreamTypeDecoder
isArrayType, isNull, readArrayElements, readSize, readValue, skipValue
Methods inherited from interface org.apache.qpid.protonj2.codec.TypeDecoder
isArrayType, isNull, readArrayElements, readSize, readValue, skipValue
-
Method Details
-
getTypeClass
- Specified by:
getTypeClass
in interfaceStreamTypeDecoder<Map>
- Specified by:
getTypeClass
in interfaceTypeDecoder<Map>
- Returns:
- the Class that this decoder handles.
-
readCount
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
- TheDecoderState
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
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
- TheStreamDecoderState
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 DecodeExceptionScan the encodedMap
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 incomingMap
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
- TheDecoderState
used during this decode.context
- The previously created and configuredScanningContext
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 DecodeExceptionScan the encodedMap
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 incomingMap
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
- TheStreamDecoderState
used during this decode.context
- The previously created and configuredScanningContext
matchConsumer
- The consumer that will be notified when a matching key is found.- Throws:
DecodeException
- if an error occurs reading the value
-