in proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathMessageAnnotationsType.java [93:154]
public MessageAnnotations readValue() {
DecoderImpl decoder = getDecoder();
ReadableBuffer buffer = decoder.getBuffer();
final int size;
final int count;
byte encodingCode = buffer.get();
switch (encodingCode) {
case EncodingCodes.MAP8:
size = buffer.get() & 0xFF;
count = buffer.get() & 0xFF;
break;
case EncodingCodes.MAP32:
size = buffer.getInt();
count = buffer.getInt();
break;
case EncodingCodes.NULL:
return new MessageAnnotations(null);
default:
throw new ProtonException("Expected Map type but found encoding: " + encodingCode);
}
if (count > buffer.remaining()) {
throw new IllegalArgumentException("Map element count "+count+" is specified to be greater than the amount of data available ("+
decoder.getByteBufferRemaining()+")");
}
TypeConstructor<?> valueConstructor = null;
Map<Symbol, Object> map = new LinkedHashMap<>(count);
for(int i = 0; i < count / 2; i++) {
Symbol key = decoder.readSymbol(null);
if (key == null) {
throw new DecodeException("String key in DeliveryAnnotations cannot be null");
}
boolean arrayType = false;
byte code = buffer.get(buffer.position());
switch (code)
{
case EncodingCodes.ARRAY8:
case EncodingCodes.ARRAY32:
arrayType = true;
}
valueConstructor = findNextDecoder(decoder, buffer, valueConstructor);
final Object value;
if (arrayType) {
value = ((ArrayType.ArrayEncoding) valueConstructor).readValueArray();
} else {
value = valueConstructor.readValue();
}
map.put(key, value);
}
return new MessageAnnotations(map);
}