All Implemented Interfaces:
DescribedTypeEncoder<Accepted>, TypeEncoder<Accepted>

public final class AcceptedTypeEncoder extends AbstractDescribedListTypeEncoder<Accepted>
Encoder of AMQP Accepted type values to a byte stream
  • Field Details

  • Constructor Details

    • AcceptedTypeEncoder

      public AcceptedTypeEncoder()
  • Method Details

    • getTypeClass

      public Class<Accepted> getTypeClass()
      Returns:
      the Class type that this encoder handles.
    • getDescriptorCode

      public UnsignedLong getDescriptorCode()
      Returns:
      the UnsignedLong value to use as the Descriptor for this type.
    • getDescriptorSymbol

      public Symbol getDescriptorSymbol()
      Returns:
      the Symbol value to use as the Descriptor for this type.
    • getListEncoding

      public byte getListEncoding(Accepted value)
      Description copied from class: AbstractDescribedListTypeEncoder
      Determine the list type the given value can be encoded to based on the number of bytes that would be needed to hold the encoded form of the resulting list entries.

      Most encoders will return LIST32 but for cases where the type is known to be encoded to LIST8 or always encodes an empty list (LIST0) the encoder can optimize the encode step and not compute sizes.

      Overrides:
      getListEncoding in class AbstractDescribedListTypeEncoder<Accepted>
      Parameters:
      value - The value that is to be encoded.
      Returns:
      the encoding code of the list type encoding needed for this object.
    • getMaxElementCount

      public int getMaxElementCount()
      Description copied from class: AbstractDescribedListTypeEncoder
      Returns the maximum number of elements the list body of the described type can carry and is used as a sanity check during encode.
      Specified by:
      getMaxElementCount in class AbstractDescribedListTypeEncoder<Accepted>
      Returns:
      the maximum number of elements the described type can carry.
    • getElementCount

      public int getElementCount(Accepted value)
      Description copied from class: AbstractDescribedListTypeEncoder
      Gets the number of elements that will result when this type is encoded into an AMQP List type.
      Specified by:
      getElementCount in class AbstractDescribedListTypeEncoder<Accepted>
      Parameters:
      value - the value which will be encoded as a list type.
      Returns:
      the number of elements that should comprise the encoded list.
    • writeType

      public void writeType(ProtonBuffer buffer, EncoderState state, Accepted value)
      Description copied from interface: TypeEncoder
      Write the full AMQP type data to the given byte buffer.

      This can consist of writing both a type constructor value and the bytes that make up the value of the type being written.

      Specified by:
      writeType in interface TypeEncoder<Accepted>
      Overrides:
      writeType in class AbstractDescribedListTypeEncoder<Accepted>
      Parameters:
      buffer - The buffer to write the AMQP type to
      state - The current encoder state
      value - The value that is to be written.
    • writeElements

      public void writeElements(Accepted source, int count, ProtonBuffer buffer, Encoder encoder, EncoderState state)
      Description copied from class: AbstractDescribedListTypeEncoder
      Instructs the encoder to write the elements identified with the given count which should match what it reports as the required number needed for this encoding.
      Specified by:
      writeElements in class AbstractDescribedListTypeEncoder<Accepted>
      Parameters:
      source - the source of the list elements to write
      count - the number of elements that are to be encoded for this type
      buffer - the buffer to write the element to
      encoder - the current Encoder value to use.
      state - the current EncoderState value to use.