Class AbstractDescribedListTypeDecoder<V>

java.lang.Object
org.apache.qpid.protonj2.codec.decoders.AbstractDescribedTypeDecoder<V>
org.apache.qpid.protonj2.codec.decoders.AbstractDescribedListTypeDecoder<V>
Type Parameters:
V - The type that this decoder handles.
All Implemented Interfaces:
DescribedTypeDecoder<V>, StreamDescribedTypeDecoder<V>, StreamTypeDecoder<V>, TypeDecoder<V>
Direct Known Subclasses:
AcceptedTypeDecoder, AttachTypeDecoder, BeginTypeDecoder, CloseTypeDecoder, CoordinatorTypeDecoder, DeclaredTypeDecoder, DeclareTypeDecoder, DeleteOnCloseTypeDecoder, DeleteOnNoLinksOrMessagesTypeDecoder, DeleteOnNoLinksTypeDecoder, DeleteOnNoMessagesTypeDecoder, DetachTypeDecoder, DischargeTypeDecoder, DispositionTypeDecoder, EndTypeDecoder, ErrorConditionTypeDecoder, FlowTypeDecoder, HeaderTypeDecoder, ModifiedTypeDecoder, OpenTypeDecoder, PropertiesTypeDecoder, ReceivedTypeDecoder, RejectedTypeDecoder, ReleasedTypeDecoder, SaslChallengeTypeDecoder, SaslInitTypeDecoder, SaslMechanismsTypeDecoder, SaslOutcomeTypeDecoder, SaslResponseTypeDecoder, SourceTypeDecoder, TargetTypeDecoder, TransactionStateTypeDecoder, TransferTypeDecoder

public abstract class AbstractDescribedListTypeDecoder<V> extends AbstractDescribedTypeDecoder<V>
Abstract base for all List based Described Type decoders which implements the generic methods common to all the implementations.
  • Constructor Details

    • AbstractDescribedListTypeDecoder

      public AbstractDescribedListTypeDecoder()
  • Method Details

    • readValue

      public final V readValue(ProtonBuffer buffer, DecoderState state) throws DecodeException
      Description copied from interface: TypeDecoder
      Reads the next type from the given buffer and returns it.
      Parameters:
      buffer - the source of encoded data.
      state - the current state of the decoder.
      Returns:
      the next instance in the stream that this decoder handles.
      Throws:
      DecodeException - if an error is encountered while reading the next value.
    • readValue

      public final V readValue(InputStream stream, StreamDecoderState state) throws DecodeException
      Description copied from interface: StreamTypeDecoder
      Reads the next type from the given buffer and returns it.
      Parameters:
      stream - the source of encoded data.
      state - the current state of the decoder.
      Returns:
      the next instance in the stream that this decoder handles.
      Throws:
      DecodeException - if an error is encountered while reading the next value.
    • skipValue

      public final void skipValue(ProtonBuffer buffer, DecoderState state) throws DecodeException
      Description copied from interface: TypeDecoder
      Skips over the bytes that compose the type this descriptor decodes.

      Skipping values can be used when the type is not used or processed by the application doing the decoding. An example might be an AMQP message decoder that only needs to decode certain parts of the message and not others.

      Parameters:
      buffer - The buffer that contains the encoded type.
      state - The decoder state.
      Throws:
      DecodeException - if an error occurs while skipping the value.
    • skipValue

      public final void skipValue(InputStream stream, StreamDecoderState state) throws DecodeException
      Description copied from interface: StreamTypeDecoder
      Skips over the bytes that compose the type this descriptor decodes.

      Skipping values can be used when the type is not used or processed by the application doing the decoding. An example might be an AMQP message decoder that only needs to decode certain parts of the message and not others.

      Parameters:
      stream - The stream that contains the encoded type.
      state - The decoder state.
      Throws:
      DecodeException - if an error occurs while skipping the value.
    • readArrayElements

      public final V[] readArrayElements(ProtonBuffer buffer, DecoderState state, int count) throws DecodeException
      Description copied from interface: TypeDecoder
      Reads a series of this type that have been encoded into the body of an Array type.

      When encoded into an array the values are encoded in series following the identifier for the type, this method is given a count of the number of instances that are encoded and should read each in succession and returning them in a new array.

      Parameters:
      buffer - the source of encoded data.
      state - the current state of the decoder.
      count - the number of array elements encoded in the buffer.
      Returns:
      the next instance in the stream that this decoder handles.
      Throws:
      DecodeException - if an error is encountered while reading the next value.
    • readArrayElements

      public final V[] readArrayElements(InputStream stream, StreamDecoderState state, int count) throws DecodeException
      Description copied from interface: StreamTypeDecoder
      Reads a series of this type that have been encoded into the body of an Array type.

      When encoded into an array the values are encoded in series following the identifier for the type, this method is given a count of the number of instances that are encoded and should read each in succession and returning them in a new array.

      Parameters:
      stream - the source of encoded data.
      state - the current state of the decoder.
      count - the number of array elements encoded in the buffer.
      Returns:
      the next instance in the stream that this decoder handles.
      Throws:
      DecodeException - if an error is encountered while reading the next value.
    • getMinListElements

      protected abstract int getMinListElements()
      (@return the minimum number of elements that must appear in this list type}
    • getMaxListElements

      protected abstract int getMaxListElements()
      Returns the maximum number of elements that may appear in this list type.
      Returns:
      the maximum number of elements that may appear in this list type
    • readSingle

      protected V readSingle(ProtonBuffer buffer, DecoderState state, ListTypeDecoder listDecoder) throws DecodeException
      Reads a single instance of the described list type using the provided decoder. The default implementation performs a series of validation checks on the incoming encoded data and then calls the abstract readListType method which can assume the basic contracts of the encoding are correct and simply read the elements into the final described type object.
      Parameters:
      buffer - The source of the encoded bytes to read the value from.
      state - The decoder state that was passed at the start of decoding.
      listDecoder - The list decoder that indicates the structure of the encoded lists of elements.
      Returns:
      a single value that is the described type this decoder reads using the given list decoder.
      Throws:
      DecodeException - if an error occurs while performing the decode.
    • readSingle

      protected V readSingle(InputStream stream, StreamDecoderState state, ListTypeDecoder listDecoder) throws DecodeException
      Reads a single instance of the described list type using the provided decoder. The default implementation performs a series of validation checks on the incoming encoded data and then calls the abstract readListType method which can assume the basic contracts of the encoding are correct and simply read the elements into the final described type object.
      Parameters:
      stream - The source of the encoded bytes to read the value from.
      state - The decoder state that was passed at the start of decoding.
      listDecoder - The list decoder that indicates the structure of the encoded lists of elements.
      Returns:
      a single value that is the described type this decoder reads using the given list decoder.
      Throws:
      DecodeException - if an error occurs while performing the decode.
    • readType

      protected abstract V readType(int count, ProtonBuffer buffer, Decoder decoder, DecoderState state) throws DecodeException
      Reads the actual type from the byte stream with the given number of encoded list elements populated
      Parameters:
      count - The number of entries encoded into the list body.
      buffer - The source of the encoded bytes to read the value from.
      decoder - The list decoder that indicates the structure of the encoded lists of elements.
      state - The decoder state that was passed at the start of decoding.
      Returns:
      a single value that is the described type this decoder reads using the given list decoder.
      Throws:
      DecodeException - if an error occurs while performing the decode.
    • readType

      protected abstract V readType(int count, InputStream stream, StreamDecoder decoder, StreamDecoderState state) throws DecodeException
      Reads the actual type from the byte stream with the given number of encoded list elements populated
      Parameters:
      count - The number of entries encoded into the list body.
      stream - The source of the encoded bytes to read the value from.
      decoder - The list decoder that indicates the structure of the encoded lists of elements.
      state - The decoder state that was passed at the start of decoding.
      Returns:
      a single value that is the described type this decoder reads using the given list decoder.
      Throws:
      DecodeException - if an error occurs while performing the decode.