in protonj2/src/main/java/org/apache/qpid/protonj2/codec/decoders/transport/OpenTypeDecoder.java [163:231]
private Open readOpen(InputStream stream, StreamDecoder decoder, StreamDecoderState state, ListTypeDecoder listDecoder) throws DecodeException {
final Open open = new Open();
@SuppressWarnings("unused")
final int size = listDecoder.readSize(stream, state);
final int count = listDecoder.readCount(stream, state);
if (count < MIN_OPEN_LIST_ENTRIES) {
throw new DecodeException("The container-id field cannot be omitted from the Open");
}
if (count > MAX_OPEN_LIST_ENTRIES) {
throw new DecodeException("To many entries in Open list encoding: " + count);
}
for (int index = 0; index < count; ++index) {
// If the stream allows we 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 (stream.markSupported()) {
stream.mark(1);
final boolean nullValue = ProtonStreamUtils.readByte(stream) == EncodingCodes.NULL;
if (nullValue) {
if (index == 0) {
throw new DecodeException("The container-id field cannot be omitted from the Open");
}
continue;
} else {
ProtonStreamUtils.reset(stream);
}
}
switch (index) {
case 0:
open.setContainerId(decoder.readString(stream, state));
break;
case 1:
open.setHostname(decoder.readString(stream, state));
break;
case 2:
open.setMaxFrameSize(decoder.readUnsignedInteger(stream, state, 0l));
break;
case 3:
open.setChannelMax(decoder.readUnsignedShort(stream, state, 0));
break;
case 4:
open.setIdleTimeout(decoder.readUnsignedInteger(stream, state, 0l));
break;
case 5:
open.setOutgoingLocales(decoder.readMultiple(stream, state, Symbol.class));
break;
case 6:
open.setIncomingLocales(decoder.readMultiple(stream, state, Symbol.class));
break;
case 7:
open.setOfferedCapabilities(decoder.readMultiple(stream, state, Symbol.class));
break;
case 8:
open.setDesiredCapabilities(decoder.readMultiple(stream, state, Symbol.class));
break;
case 9:
open.setProperties(decoder.readMap(stream, state));
break;
}
}
return open;
}