Module org.apache.qpid.protonj2
Class MessageAnnotationsTypeDecoder
java.lang.Object
org.apache.qpid.protonj2.codec.decoders.AbstractDescribedTypeDecoder<MessageAnnotations>
org.apache.qpid.protonj2.codec.decoders.AbstractDescribedMapTypeDecoder<MessageAnnotations,Symbol>
org.apache.qpid.protonj2.codec.decoders.messaging.MessageAnnotationsTypeDecoder
- All Implemented Interfaces:
DescribedTypeDecoder<MessageAnnotations>,StreamDescribedTypeDecoder<MessageAnnotations>,StreamTypeDecoder<MessageAnnotations>,TypeDecoder<MessageAnnotations>
public final class MessageAnnotationsTypeDecoder
extends AbstractDescribedMapTypeDecoder<MessageAnnotations,Symbol>
Decoder of AMQP Message Annotations type values from a byte stream.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected MessageAnnotationscreateDescribed(Map<Symbol, Object> map) static ScanningContext<Symbol> createScanContext(Collection<Symbol> keys) Creates a new scanning context for the given collection ofSymbolvalues.static ScanningContext<Symbol> createScanContext(Symbol... keys) Creates a new scanning context for the given collection ofSymbolvalues.static StreamScanningContext<Symbol> Creates a new scanning context for the given collection ofSymbolvalues.static StreamScanningContext<Symbol> createStreamScanContext(Symbol... keys) Creates a new scanning context for the given collection ofSymbolvalues.Returns the AMQP descriptor code for the type this decoder reads.Returns the AMQP descriptor symbol for the type this decoder reads.Returns the Class that this decoder handles.protected SymbolreadKey(InputStream stream, StreamDecoder decoder, StreamDecoderState state) Called during decoding of the describedMapbody to allow the implementation to read the map key using the optimal decoder API for the type of key stored in the map.protected SymbolreadKey(ProtonBuffer buffer, Decoder decoder, DecoderState state) Called during decoding of the describedMapbody to allow the implementation to read the map key using the optimal decoder API for the type of key stored in the map.voidscanAnnotations(InputStream stream, StreamDecoderState state, StreamScanningContext<Symbol> context, BiConsumer<Symbol, Object> matchConsumer) Scans through the encodedMessageAnnotationsmap looking for keys that match with the providedScanningContext.voidscanAnnotations(ProtonBuffer buffer, DecoderState state, ScanningContext<Symbol> context, BiConsumer<Symbol, Object> matchConsumer) Scans through the encodedMessageAnnotationsmap looking for keys that match with the providedScanningContext.Methods inherited from class org.apache.qpid.protonj2.codec.decoders.AbstractDescribedMapTypeDecoder
readArrayElements, readArrayElements, readValue, readValue, scanMapEntries, scanMapEntries, skipValue, skipValue, validateAndGetCount, validateAndGetCountMethods inherited from class org.apache.qpid.protonj2.codec.decoders.AbstractDescribedTypeDecoder
checkIsExpectedType, checkIsExpectedType, checkIsExpectedTypeAndCast, checkIsExpectedTypeAndCast, isArrayType, isNull, isPrimitive, readSize, readSize, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.qpid.protonj2.codec.DescribedTypeDecoder
decoderRegistered
-
Field Details
-
INSTANCE
-
-
Constructor Details
-
MessageAnnotationsTypeDecoder
public MessageAnnotationsTypeDecoder()
-
-
Method Details
-
getTypeClass
Description copied from interface:TypeDecoderReturns the Class that this decoder handles.- Returns:
- the Class that this decoder handles
-
getDescriptorCode
Description copied from interface:DescribedTypeDecoderReturns the AMQP descriptor code for the type this decoder reads.- Returns:
- an unsigned long descriptor code value.
-
getDescriptorSymbol
Description copied from interface:DescribedTypeDecoderReturns the AMQP descriptor symbol for the type this decoder reads.- Returns:
- an symbol descriptor code value.
-
readKey
protected Symbol readKey(ProtonBuffer buffer, Decoder decoder, DecoderState state) throws DecodeException Description copied from class:AbstractDescribedMapTypeDecoderCalled during decoding of the describedMapbody to allow the implementation to read the map key using the optimal decoder API for the type of key stored in the map.- Specified by:
readKeyin classAbstractDescribedMapTypeDecoder<MessageAnnotations,Symbol> - Parameters:
buffer- The buffer where the encodedMapbody lives.decoder- TheDecoderto use for reading the key.state- TheDecoderStateto use while reading the key.- Returns:
- the newly read
Mapkey. - Throws:
DecodeException- if an error occurs while reading the map key.
-
readKey
protected Symbol readKey(InputStream stream, StreamDecoder decoder, StreamDecoderState state) throws DecodeException Description copied from class:AbstractDescribedMapTypeDecoderCalled during decoding of the describedMapbody to allow the implementation to read the map key using the optimal decoder API for the type of key stored in the map.- Specified by:
readKeyin classAbstractDescribedMapTypeDecoder<MessageAnnotations,Symbol> - Parameters:
stream- The bytes stream where the encodedMapbody lives.decoder- TheDecoderto use for reading the key.state- TheDecoderStateto use while reading the key.- Returns:
- the newly read
Mapkey. - Throws:
DecodeException- if an error occurs while reading the map key.
-
createDescribed
Description copied from class:AbstractDescribedMapTypeDecoderCalled from read method to wrap the decodedMapin the described type wrapper that thisMaptype manages.- Specified by:
createDescribedin classAbstractDescribedMapTypeDecoder<MessageAnnotations,Symbol> - Parameters:
map- The decoded map that this type handles.- Returns:
- the described type wrapper around the decoded
Map.
-
createScanContext
Creates a new scanning context for the given collection ofSymbolvalues.- Parameters:
keys- TheStringkeys that will be scanned for in the encodedMap- Returns:
- a
ScanningContextfor the collection of Symbol keys.
-
createScanContext
Creates a new scanning context for the given collection ofSymbolvalues.- Parameters:
keys- TheStringkeys that will be scanned for in the encodedMap- Returns:
- a
ScanningContextfor the collection of Symbol keys.
-
createStreamScanContext
Creates a new scanning context for the given collection ofSymbolvalues.- Parameters:
keys- TheStringkeys that will be scanned for in the encodedMap- Returns:
- a
StreamScanningContextfor the collection of Symbol keys.
-
createStreamScanContext
Creates a new scanning context for the given collection ofSymbolvalues.- Parameters:
keys- TheStringkeys that will be scanned for in the encodedMap- Returns:
- a
StreamScanningContextfor the collection of Symbol keys.
-
scanAnnotations
public void scanAnnotations(ProtonBuffer buffer, DecoderState state, ScanningContext<Symbol> context, BiConsumer<Symbol, Object> matchConsumer) throws DecodeExceptionScans through the encodedMessageAnnotationsmap looking for keys that match with the providedScanningContext. When a match is found the provided match consumer is called with the matched key and the decoded value mapped to that key. When the method returns the caller can assume that all bytes of the encoded MessageAnnotations have been read and that decoding of the next object can begin if the provided buffer remains readable.- Parameters:
buffer- The buffer to scan for specific key / value mappingsstate- The decoder state used during the scanningcontext- A matching context primed with the match data needed to match encoded keys.matchConsumer- ABiConsumerthat will be notified of each matching key / value pair.- Throws:
DecodeException- if an error is encountered while reading the next value.
-
scanAnnotations
public void scanAnnotations(InputStream stream, StreamDecoderState state, StreamScanningContext<Symbol> context, BiConsumer<Symbol, Object> matchConsumer) throws DecodeExceptionScans through the encodedMessageAnnotationsmap looking for keys that match with the providedScanningContext. When a match is found the provided match consumer is called with the matched key and the decoded value mapped to that key. When the method returns the caller can assume that all bytes of the encoded MessageAnnotations have been read and that decoding of the next object can begin if the provided stream remains readable.- Parameters:
stream- TheInputStreamto scan for specific key / value mappingsstate- The decoder state used during the scanningcontext- A matching context primed with the match data needed to match encoded keys.matchConsumer- ABiConsumerthat will be notified of each matching key / value pair.- Throws:
DecodeException- if an error is encountered while reading the next value.
-