Search in sources :

Example 6 with DeliveryAnnotationsSection

use of org.apache.qpid.server.protocol.v1_0.type.messaging.DeliveryAnnotationsSection in project qpid-broker-j by apache.

the class MessageDecoder method parse.

public void parse() throws AmqpErrorException {
    if (!_parsed) {
        List<EncodingRetainingSection<?>> sections;
        try (QpidByteBuffer combined = QpidByteBuffer.concatenate(_fragments)) {
            sections = _sectionDecoder.parseAll(combined);
        }
        _fragments.forEach(QpidByteBuffer::dispose);
        Iterator<EncodingRetainingSection<?>> iter = sections.iterator();
        EncodingRetainingSection<?> s = iter.hasNext() ? iter.next() : null;
        if (s instanceof HeaderSection) {
            _headerSection = (HeaderSection) s;
            s = iter.hasNext() ? iter.next() : null;
        }
        if (s instanceof DeliveryAnnotationsSection) {
            _deliveryAnnotationsSection = (DeliveryAnnotationsSection) s;
            s = iter.hasNext() ? iter.next() : null;
        }
        if (s instanceof MessageAnnotationsSection) {
            _messageAnnotationsSection = (MessageAnnotationsSection) s;
            s = iter.hasNext() ? iter.next() : null;
        }
        if (s instanceof PropertiesSection) {
            _propertiesSection = (PropertiesSection) s;
            s = iter.hasNext() ? iter.next() : null;
        }
        if (s instanceof ApplicationPropertiesSection) {
            _applicationPropertiesSection = (ApplicationPropertiesSection) s;
            s = iter.hasNext() ? iter.next() : null;
        }
        if (s instanceof AmqpValueSection) {
            _contentSize = s.getEncodedSize();
            _dataSections.add(s);
            s = iter.hasNext() ? iter.next() : null;
        } else if (s instanceof DataSection) {
            do {
                _contentSize += s.getEncodedSize();
                _dataSections.add(s);
                s = iter.hasNext() ? iter.next() : null;
            } while (s instanceof DataSection);
        } else if (s instanceof AmqpSequenceSection) {
            do {
                _contentSize += s.getEncodedSize();
                _dataSections.add(s);
                s = iter.hasNext() ? iter.next() : null;
            } while (s instanceof AmqpSequenceSection);
        }
        if (s instanceof FooterSection) {
            _footerSection = (FooterSection) s;
            s = iter.hasNext() ? iter.next() : null;
        }
        if (s != null) {
            throw new IllegalStateException(String.format("Encountered unexpected section '%s'", s.getClass().getSimpleName()));
        }
        _parsed = true;
    }
}
Also used : PropertiesSection(org.apache.qpid.server.protocol.v1_0.type.messaging.PropertiesSection) ApplicationPropertiesSection(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationPropertiesSection) DeliveryAnnotationsSection(org.apache.qpid.server.protocol.v1_0.type.messaging.DeliveryAnnotationsSection) EncodingRetainingSection(org.apache.qpid.server.protocol.v1_0.type.messaging.EncodingRetainingSection) MessageAnnotationsSection(org.apache.qpid.server.protocol.v1_0.type.messaging.MessageAnnotationsSection) ApplicationPropertiesSection(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationPropertiesSection) AmqpSequenceSection(org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpSequenceSection) HeaderSection(org.apache.qpid.server.protocol.v1_0.type.messaging.HeaderSection) FooterSection(org.apache.qpid.server.protocol.v1_0.type.messaging.FooterSection) DataSection(org.apache.qpid.server.protocol.v1_0.type.messaging.DataSection) QpidByteBuffer(org.apache.qpid.server.bytebuffer.QpidByteBuffer) AmqpValueSection(org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpValueSection)

Aggregations

DeliveryAnnotationsSection (org.apache.qpid.server.protocol.v1_0.type.messaging.DeliveryAnnotationsSection)6 HeaderSection (org.apache.qpid.server.protocol.v1_0.type.messaging.HeaderSection)5 QpidByteBuffer (org.apache.qpid.server.bytebuffer.QpidByteBuffer)4 ApplicationPropertiesSection (org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationPropertiesSection)4 DeliveryAnnotations (org.apache.qpid.server.protocol.v1_0.type.messaging.DeliveryAnnotations)4 FooterSection (org.apache.qpid.server.protocol.v1_0.type.messaging.FooterSection)4 MessageAnnotationsSection (org.apache.qpid.server.protocol.v1_0.type.messaging.MessageAnnotationsSection)4 AmqpValueSection (org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpValueSection)3 PropertiesSection (org.apache.qpid.server.protocol.v1_0.type.messaging.PropertiesSection)3 ArrayList (java.util.ArrayList)2 StringWriter (org.apache.qpid.server.protocol.v1_0.codec.StringWriter)2 AmqpSequenceSection (org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpSequenceSection)2 ApplicationProperties (org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties)2 DataSection (org.apache.qpid.server.protocol.v1_0.type.messaging.DataSection)2 EncodingRetainingSection (org.apache.qpid.server.protocol.v1_0.type.messaging.EncodingRetainingSection)2 Footer (org.apache.qpid.server.protocol.v1_0.type.messaging.Footer)2 Header (org.apache.qpid.server.protocol.v1_0.type.messaging.Header)2 MessageAnnotations (org.apache.qpid.server.protocol.v1_0.type.messaging.MessageAnnotations)2 Symbol (org.apache.qpid.server.protocol.v1_0.type.Symbol)1 AmqpValue (org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpValue)1