Search in sources :

Example 1 with NullTypeDecoder

use of org.apache.qpid.protonj2.codec.decoders.primitives.NullTypeDecoder in project qpid-protonj2 by apache.

the class ApplicationPropertiesTypeDecoder method readArrayElements.

@Override
public ApplicationProperties[] readArrayElements(InputStream stream, StreamDecoderState state, int count) throws DecodeException {
    final StreamTypeDecoder<?> decoder = state.getDecoder().readNextTypeDecoder(stream, state);
    final ApplicationProperties[] result = new ApplicationProperties[count];
    if (decoder instanceof NullTypeDecoder) {
        for (int i = 0; i < count; ++i) {
            result[i] = new ApplicationProperties(null);
        }
        return result;
    }
    for (int i = 0; i < count; ++i) {
        result[i] = new ApplicationProperties(readMap(stream, state, checkIsExpectedTypeAndCast(MapTypeDecoder.class, decoder)));
    }
    return result;
}
Also used : NullTypeDecoder(org.apache.qpid.protonj2.codec.decoders.primitives.NullTypeDecoder) ApplicationProperties(org.apache.qpid.protonj2.types.messaging.ApplicationProperties) MapTypeDecoder(org.apache.qpid.protonj2.codec.decoders.primitives.MapTypeDecoder)

Example 2 with NullTypeDecoder

use of org.apache.qpid.protonj2.codec.decoders.primitives.NullTypeDecoder in project qpid-protonj2 by apache.

the class DeliveryAnnotationsTypeDecoder method readArrayElements.

@Override
public DeliveryAnnotations[] readArrayElements(ProtonBuffer buffer, DecoderState state, int count) throws DecodeException {
    final TypeDecoder<?> decoder = state.getDecoder().readNextTypeDecoder(buffer, state);
    final DeliveryAnnotations[] result = new DeliveryAnnotations[count];
    if (decoder instanceof NullTypeDecoder) {
        for (int i = 0; i < count; ++i) {
            decoder.readValue(buffer, state);
            result[i] = new DeliveryAnnotations(null);
        }
        return result;
    }
    for (int i = 0; i < count; ++i) {
        result[i] = new DeliveryAnnotations(readMap(buffer, state, checkIsExpectedTypeAndCast(MapTypeDecoder.class, decoder)));
    }
    return result;
}
Also used : NullTypeDecoder(org.apache.qpid.protonj2.codec.decoders.primitives.NullTypeDecoder) DeliveryAnnotations(org.apache.qpid.protonj2.types.messaging.DeliveryAnnotations) MapTypeDecoder(org.apache.qpid.protonj2.codec.decoders.primitives.MapTypeDecoder)

Example 3 with NullTypeDecoder

use of org.apache.qpid.protonj2.codec.decoders.primitives.NullTypeDecoder in project qpid-protonj2 by apache.

the class DeliveryAnnotationsTypeDecoder method readArrayElements.

@Override
public DeliveryAnnotations[] readArrayElements(InputStream stream, StreamDecoderState state, int count) throws DecodeException {
    final StreamTypeDecoder<?> decoder = state.getDecoder().readNextTypeDecoder(stream, state);
    final DeliveryAnnotations[] result = new DeliveryAnnotations[count];
    if (decoder instanceof NullTypeDecoder) {
        for (int i = 0; i < count; ++i) {
            decoder.readValue(stream, state);
            result[i] = new DeliveryAnnotations(null);
        }
        return result;
    }
    for (int i = 0; i < count; ++i) {
        result[i] = new DeliveryAnnotations(readMap(stream, state, checkIsExpectedTypeAndCast(MapTypeDecoder.class, decoder)));
    }
    return result;
}
Also used : NullTypeDecoder(org.apache.qpid.protonj2.codec.decoders.primitives.NullTypeDecoder) DeliveryAnnotations(org.apache.qpid.protonj2.types.messaging.DeliveryAnnotations) MapTypeDecoder(org.apache.qpid.protonj2.codec.decoders.primitives.MapTypeDecoder)

Example 4 with NullTypeDecoder

use of org.apache.qpid.protonj2.codec.decoders.primitives.NullTypeDecoder in project qpid-protonj2 by apache.

the class FooterTypeDecoder method readArrayElements.

@SuppressWarnings("unchecked")
@Override
public Footer[] readArrayElements(InputStream stream, StreamDecoderState state, int count) throws DecodeException {
    final StreamTypeDecoder<?> decoder = state.getDecoder().readNextTypeDecoder(stream, state);
    final Footer[] result = new Footer[count];
    if (decoder instanceof NullTypeDecoder) {
        for (int i = 0; i < count; ++i) {
            decoder.readValue(stream, state);
            result[i] = new Footer(null);
        }
        return result;
    }
    final MapTypeDecoder mapDecoder = checkIsExpectedTypeAndCast(MapTypeDecoder.class, decoder);
    for (int i = 0; i < count; ++i) {
        result[i] = new Footer(mapDecoder.readValue(stream, state));
    }
    return result;
}
Also used : NullTypeDecoder(org.apache.qpid.protonj2.codec.decoders.primitives.NullTypeDecoder) Footer(org.apache.qpid.protonj2.types.messaging.Footer) MapTypeDecoder(org.apache.qpid.protonj2.codec.decoders.primitives.MapTypeDecoder)

Example 5 with NullTypeDecoder

use of org.apache.qpid.protonj2.codec.decoders.primitives.NullTypeDecoder in project qpid-protonj2 by apache.

the class ApplicationPropertiesTypeDecoder method readArrayElements.

@Override
public ApplicationProperties[] readArrayElements(ProtonBuffer buffer, DecoderState state, int count) throws DecodeException {
    final TypeDecoder<?> decoder = state.getDecoder().readNextTypeDecoder(buffer, state);
    final ApplicationProperties[] result = new ApplicationProperties[count];
    if (decoder instanceof NullTypeDecoder) {
        for (int i = 0; i < count; ++i) {
            result[i] = new ApplicationProperties(null);
        }
        return result;
    }
    for (int i = 0; i < count; ++i) {
        result[i] = new ApplicationProperties(readMap(buffer, state, checkIsExpectedTypeAndCast(MapTypeDecoder.class, decoder)));
    }
    return result;
}
Also used : NullTypeDecoder(org.apache.qpid.protonj2.codec.decoders.primitives.NullTypeDecoder) ApplicationProperties(org.apache.qpid.protonj2.types.messaging.ApplicationProperties) MapTypeDecoder(org.apache.qpid.protonj2.codec.decoders.primitives.MapTypeDecoder)

Aggregations

MapTypeDecoder (org.apache.qpid.protonj2.codec.decoders.primitives.MapTypeDecoder)10 NullTypeDecoder (org.apache.qpid.protonj2.codec.decoders.primitives.NullTypeDecoder)10 Footer (org.apache.qpid.protonj2.types.messaging.Footer)4 ApplicationProperties (org.apache.qpid.protonj2.types.messaging.ApplicationProperties)2 DeliveryAnnotations (org.apache.qpid.protonj2.types.messaging.DeliveryAnnotations)2 MessageAnnotations (org.apache.qpid.protonj2.types.messaging.MessageAnnotations)2