in proton-j/src/main/java/org/apache/qpid/proton/codec/ListType.java [308:378]
public List readValue()
{
DecoderImpl decoder = getDecoder();
ReadableBuffer buffer = decoder.getBuffer();
int size = ((int)decoder.readRawByte()) & 0xff;
// todo - limit the decoder with size
int count = ((int)decoder.readRawByte()) & 0xff;
TypeConstructor<?> typeConstructor = null;
List<Object> list = new ArrayList<>(count);
for (int i = 0; i < count; i++)
{
boolean arrayType = false;
byte encodingCode = buffer.get(buffer.position());
switch (encodingCode)
{
case EncodingCodes.ARRAY8:
case EncodingCodes.ARRAY32:
arrayType = true;
}
// Whenever we can just reuse the previously used TypeDecoder instead
// of spending time looking up the same one again.
if (typeConstructor == null)
{
typeConstructor = getDecoder().readConstructor();
}
else
{
if (encodingCode == EncodingCodes.DESCRIBED_TYPE_INDICATOR || !(typeConstructor instanceof PrimitiveTypeEncoding<?>))
{
typeConstructor = getDecoder().readConstructor();
}
else
{
PrimitiveTypeEncoding<?> primitiveConstructor = (PrimitiveTypeEncoding<?>) typeConstructor;
if (encodingCode != primitiveConstructor.getEncodingCode())
{
typeConstructor = getDecoder().readConstructor();
}
else
{
// consume the encoding code byte for real
encodingCode = buffer.get();
}
}
}
if (typeConstructor == null)
{
throw new DecodeException("Unknown constructor");
}
final Object value;
if (arrayType)
{
value = ((ArrayType.ArrayEncoding) typeConstructor).readValueArray();
}
else
{
value = typeConstructor.readValue();
}
list.add(value);
}
return list;
}