Class AbstractDescribedMapTypeEncoder<K,V,M>
- java.lang.Object
-
- org.apache.qpid.protonj2.codec.encoders.AbstractDescribedTypeEncoder<M>
-
- org.apache.qpid.protonj2.codec.encoders.AbstractDescribedMapTypeEncoder<K,V,M>
-
- Type Parameters:
M- the map type that is being encoded.K- the key type used for the encoded map's keys.V- the value type used for the encoded map's values.
- All Implemented Interfaces:
DescribedTypeEncoder<M>,TypeEncoder<M>
- Direct Known Subclasses:
ApplicationPropertiesTypeEncoder,DeliveryAnnotationsTypeEncoder,FooterTypeEncoder,MessageAnnotationsTypeEncoder
public abstract class AbstractDescribedMapTypeEncoder<K,V,M> extends AbstractDescribedTypeEncoder<M>
Base class used for all Described Type objects that are represented as a List
-
-
Constructor Summary
Constructors Constructor Description AbstractDescribedMapTypeEncoder()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description bytegetMapEncoding(M value)Determine the map type the given value can be encoded to based on the number of bytes that would be needed to hold the encoded form of the resulting list entries.abstract intgetMapSize(M value)Gets the number of elements that will result when this type is encoded into an AMQP Map type.abstract booleanhasMap(M value)Returns false when the value to be encoded has no Map body and can be written as a Null body type instead of a Map type.voidwriteArray(ProtonBuffer buffer, EncoderState state, Object[] values)Write an array elements of the AMQP type to the given byte buffer.abstract voidwriteMapEntries(ProtonBuffer buffer, Encoder encoder, EncoderState state, M value)Performs the write of the Map entries to the given buffer, the caller takes care of writing the Map preamble and tracking the final size of the written elements of the Map.voidwriteRawArray(ProtonBuffer buffer, EncoderState state, Object[] values)Write an array elements of the AMQP type to the given byte buffer.voidwriteType(ProtonBuffer buffer, EncoderState state, M value)Write the full AMQP type data to the given byte buffer.-
Methods inherited from class org.apache.qpid.protonj2.codec.encoders.AbstractDescribedTypeEncoder
isArrayType
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.qpid.protonj2.codec.DescribedTypeEncoder
encoderRegistered, getDescriptorCode, getDescriptorSymbol
-
Methods inherited from interface org.apache.qpid.protonj2.codec.TypeEncoder
getTypeClass
-
-
-
-
Method Detail
-
getMapEncoding
public byte getMapEncoding(M value)
Determine the map type the given value can be encoded to based on the number of bytes that would be needed to hold the encoded form of the resulting list entries.Most encoders will return MAP32 but for cases where the type is known to be encoded to MAP8 the encoder can optimize the encode step and not compute sizes.
- Parameters:
value- The value that is to be encoded.- Returns:
- the encoding code of the map type encoding needed for this object.
-
hasMap
public abstract boolean hasMap(M value)
Returns false when the value to be encoded has no Map body and can be written as a Null body type instead of a Map type.- Parameters:
value- the value which be encoded as a map type.- Returns:
- true if the type to be encoded has a Map body, false otherwise.
-
getMapSize
public abstract int getMapSize(M value)
Gets the number of elements that will result when this type is encoded into an AMQP Map type.- Parameters:
value- the value which will be encoded as a map type.- Returns:
- the number of elements that should comprise the encoded list.
-
writeMapEntries
public abstract void writeMapEntries(ProtonBuffer buffer, Encoder encoder, EncoderState state, M value)
Performs the write of the Map entries to the given buffer, the caller takes care of writing the Map preamble and tracking the final size of the written elements of the Map.- Parameters:
buffer- the buffer where the type should be encoded to.encoder- the current encoder.state- the current encoder state.value- the value which will be encoded as a map type.
-
writeType
public void writeType(ProtonBuffer buffer, EncoderState state, M value)
Description copied from interface:TypeEncoderWrite the full AMQP type data to the given byte buffer.This can consist of writing both a type constructor value and the bytes that make up the value of the type being written.
- Parameters:
buffer- The buffer to write the AMQP type tostate- The current encoder statevalue- The value that is to be written.
-
writeArray
public void writeArray(ProtonBuffer buffer, EncoderState state, Object[] values)
Description copied from interface:TypeEncoderWrite an array elements of the AMQP type to the given byte buffer.This method writes the full Array type definition of an array of the type this encoder manages.
- Parameters:
buffer- The buffer to write the AMQP array elements tostate- The current encoder statevalues- The array of values that is to be written.
-
writeRawArray
public void writeRawArray(ProtonBuffer buffer, EncoderState state, Object[] values)
Description copied from interface:TypeEncoderWrite an array elements of the AMQP type to the given byte buffer.This method writes only the body portion of an AMQP array of this type, the array encoding, size and element count should be assumed to be managed by the caller.
- Parameters:
buffer- The buffer to write the AMQP array elements tostate- The current encoder statevalues- The array of values that is to be written.
-
-