in broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/transport/EncoderUtils.java [263:339]
private static int getTypeLength(Type t, Object value)
{
switch (t)
{
case VOID:
return 0;
case BIN8:
case UINT8:
case INT8:
case CHAR:
case BOOLEAN:
return 1;
case BIN16:
case UINT16:
case INT16:
return 2;
case BIN32:
case UINT32:
case CHAR_UTF32:
case INT32:
case FLOAT:
return 4;
case BIN64:
case UINT64:
case INT64:
case DATETIME:
case DOUBLE:
return 8;
case UUID:
return 16;
case STR8:
return getStr8Length((String) value);
case STR16:
return getStr16Length((String) value);
case STR8_LATIN:
case STR8_UTF16:
case STR16_LATIN:
case STR16_UTF16:
String str = (String) value;
return t.getWidth() + (str == null ? 0 : str.getBytes(StandardCharsets.UTF_8).length);
case MAP:
return getMapLength((Map<String, Object>) value);
case LIST:
return getListLength((List<Object>) value);
case ARRAY:
return getArrayLength((List<Object>) value);
case STRUCT32:
return getStruct32Length((Struct) value);
case BIN40:
case DEC32:
case BIN72:
case DEC64:
return t.getWidth() + (value == null ? 0 : ((byte[])value).length);
default:
if (!(value instanceof byte[]))
{
throw new IllegalArgumentException("Expecting byte array was " + (value == null
? "null"
: value.getClass()));
}
return t.getWidth() + (value == null ? 0 : ((byte[])value).length);
}
}