private Properties readProperties()

in protonj2/src/main/java/org/apache/qpid/protonj2/codec/decoders/messaging/PropertiesTypeDecoder.java [169:242]


    private Properties readProperties(InputStream stream, StreamDecoderState state, ListTypeDecoder listDecoder) throws DecodeException {
        final Properties properties = new Properties();

        @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_PROPERTIES_LIST_ENTRIES) {
            throw new DecodeException("Not enough entries in Properties list encoding: " + count);
        }

        if (count > MAX_PROPERTIES_LIST_ENTRIES) {
            throw new DecodeException("To many entries in Properties 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:
                    properties.setMessageId(state.getDecoder().readObject(stream, state));
                    break;
                case 1:
                    properties.setUserId(state.getDecoder().readBinary(stream, state));
                    break;
                case 2:
                    properties.setTo(state.getDecoder().readString(stream, state));
                    break;
                case 3:
                    properties.setSubject(state.getDecoder().readString(stream, state));
                    break;
                case 4:
                    properties.setReplyTo(state.getDecoder().readString(stream, state));
                    break;
                case 5:
                    properties.setCorrelationId(state.getDecoder().readObject(stream, state));
                    break;
                case 6:
                    properties.setContentType(state.getDecoder().readSymbol(stream, state, null));
                    break;
                case 7:
                    properties.setContentEncoding(state.getDecoder().readSymbol(stream, state, null));
                    break;
                case 8:
                    properties.setAbsoluteExpiryTime(state.getDecoder().readTimestamp(stream, state, 0l));
                    break;
                case 9:
                    properties.setCreationTime(state.getDecoder().readTimestamp(stream, state, 0l));
                    break;
                case 10:
                    properties.setGroupId(state.getDecoder().readString(stream, state));
                    break;
                case 11:
                    properties.setGroupSequence(state.getDecoder().readUnsignedInteger(stream, state, 0l));
                    break;
                case 12:
                    properties.setReplyToGroupId(state.getDecoder().readString(stream, state));
                    break;
            }
        }

        return properties;
    }