in protonj2/src/main/java/org/apache/qpid/protonj2/codec/decoders/transport/AttachTypeDecoder.java [84:160]
private Attach readAttach(ProtonBuffer buffer, Decoder decoder, DecoderState state, ListTypeDecoder listDecoder) throws DecodeException {
final Attach attach = new Attach();
@SuppressWarnings("unused")
final int size = listDecoder.readSize(buffer, state);
final int count = listDecoder.readCount(buffer, state);
if (count < MIN_ATTACH_LIST_ENTRIES) {
throw new DecodeException(errorForMissingRequiredFields(count));
}
if (count > MAX_ATTACH_LIST_ENTRIES) {
throw new DecodeException("To many entries in Attach list encoding: " + count);
}
for (int index = 0; index < count; ++index) {
// Peek ahead and see if there is a null in the next slot, if so we don't call
// the setter for that entry to ensure the returned type reflects the encoded
// state in the modification entry.
if (buffer.peekByte() == EncodingCodes.NULL) {
// Ensure mandatory fields are set
if (index < MIN_ATTACH_LIST_ENTRIES) {
throw new DecodeException(errorForMissingRequiredFields(index));
}
buffer.advanceReadOffset(1);
continue;
}
switch (index) {
case 0:
attach.setName(decoder.readString(buffer, state));
break;
case 1:
attach.setHandle(decoder.readUnsignedInteger(buffer, state, 0l));
break;
case 2:
attach.setRole(decoder.readBoolean(buffer, state, false) ? Role.RECEIVER : Role.SENDER);
break;
case 3:
attach.setSenderSettleMode(SenderSettleMode.valueOf(decoder.readUnsignedByte(buffer, state, (byte) 2)));
break;
case 4:
attach.setReceiverSettleMode(ReceiverSettleMode.valueOf(decoder.readUnsignedByte(buffer, state, (byte) 0)));
break;
case 5:
attach.setSource(decoder.readObject(buffer, state, Source.class));
break;
case 6:
attach.setTarget(decoder.readObject(buffer, state, Terminus.class));
break;
case 7:
attach.setUnsettled(decoder.readMap(buffer, state));
break;
case 8:
attach.setIncompleteUnsettled(decoder.readBoolean(buffer, state, true));
break;
case 9:
attach.setInitialDeliveryCount(decoder.readUnsignedInteger(buffer, state, 0l));
break;
case 10:
attach.setMaxMessageSize(decoder.readUnsignedLong(buffer, state));
break;
case 11:
attach.setOfferedCapabilities(decoder.readMultiple(buffer, state, Symbol.class));
break;
case 12:
attach.setDesiredCapabilities(decoder.readMultiple(buffer, state, Symbol.class));
break;
case 13:
attach.setProperties(decoder.readMap(buffer, state));
break;
}
}
return attach;
}