in protonj2/src/main/java/org/apache/qpid/protonj2/codec/decoders/messaging/HeaderTypeDecoder.java [146:195]
private Header readHeader(InputStream stream, StreamDecoderState state, ListTypeDecoder listDecoder) throws DecodeException {
final Header header = new Header();
@SuppressWarnings("unused")
final int size = listDecoder.readSize(stream, state);
final int count = listDecoder.readCount(stream, state);
// Don't decode anything if things already look wrong.
if (count < MIN_HEADER_LIST_ENTRIES) {
throw new DecodeException("Not enough entries in Header list encoding: " + count);
}
if (count > MAX_HEADER_LIST_ENTRIES) {
throw new DecodeException("To many entries in Header 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);
if (ProtonStreamUtils.readByte(stream) == EncodingCodes.NULL) {
continue;
} else {
ProtonStreamUtils.reset(stream);
}
}
switch (index) {
case 0:
header.setDurable(state.getDecoder().readBoolean(stream, state, false));
break;
case 1:
header.setPriority(state.getDecoder().readUnsignedByte(stream, state, Header.DEFAULT_PRIORITY));
break;
case 2:
header.setTimeToLive(state.getDecoder().readUnsignedInteger(stream, state, 0l));
break;
case 3:
header.setFirstAcquirer(state.getDecoder().readBoolean(stream, state, false));
break;
case 4:
header.setDeliveryCount(state.getDecoder().readUnsignedInteger(stream, state, 0l));
break;
}
}
return header;
}