Class AbstractSymbolTypeDecoder

java.lang.Object
org.apache.qpid.protonj2.codec.decoders.AbstractPrimitiveTypeDecoder<Symbol>
org.apache.qpid.protonj2.codec.decoders.primitives.AbstractSymbolTypeDecoder
All Implemented Interfaces:
SymbolTypeDecoder, PrimitiveTypeDecoder<Symbol>, StreamTypeDecoder<Symbol>, TypeDecoder<Symbol>
Direct Known Subclasses:
Symbol32TypeDecoder, Symbol8TypeDecoder

public abstract class AbstractSymbolTypeDecoder extends AbstractPrimitiveTypeDecoder<Symbol> implements SymbolTypeDecoder
Base class for the Symbol decoders used on AMQP Symbol types.
  • Constructor Details

    • AbstractSymbolTypeDecoder

      public AbstractSymbolTypeDecoder()
  • Method Details

    • readValue

      public Symbol readValue(ProtonBuffer buffer, DecoderState state) throws DecodeException
      Description copied from interface: TypeDecoder
      Reads the next type from the given buffer and returns it.
      Specified by:
      readValue in interface TypeDecoder<Symbol>
      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.
    • readString

      public String readString(ProtonBuffer buffer, DecoderState state) throws DecodeException
      Reads a String view of an encoded Symbol value from the given buffer.

      This method has the same result as calling the Symbol reading variant readValue(ProtonBuffer, DecoderState) and then invoking the toString method on the resulting Symbol.

      Parameters:
      buffer - The buffer to read the encoded symbol from.
      state - The encoder state that applied to this decode operation.
      Returns:
      a String view of the encoded Symbol value.
      Throws:
      DecodeException - if an error occurs decoding the Symbol from the given buffer.
    • readValue

      public Symbol readValue(InputStream stream, StreamDecoderState state) throws DecodeException
      Description copied from interface: StreamTypeDecoder
      Reads the next type from the given buffer and returns it.
      Specified by:
      readValue in interface StreamTypeDecoder<Symbol>
      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.
    • readString

      public String readString(InputStream stream, StreamDecoderState state) throws DecodeException
      Reads a String view of an encoded Symbol value from the given buffer.

      This method has the same result as calling the Symbol reading variant readValue(ProtonBuffer, DecoderState) and then invoking the toString method on the resulting Symbol.

      Parameters:
      stream - The InputStream to read the encoded symbol from.
      state - The encoder state that applied to this decode operation.
      Returns:
      a String view of the encoded Symbol value.
      Throws:
      DecodeException - if an error occurs decoding the Symbol from the given buffer.
    • skipValue

      public 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.

      Specified by:
      skipValue in interface TypeDecoder<Symbol>
      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 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.

      Specified by:
      skipValue in interface StreamTypeDecoder<Symbol>
      Parameters:
      stream - The stream that contains the encoded type.
      state - The decoder state.
      Throws:
      DecodeException - if an error occurs while skipping the value.
    • readSize

      protected abstract int readSize(ProtonBuffer buffer) throws DecodeException
      Subclasses must read the correct number of bytes from the buffer to determine the size of the encoded Symbol value.
      Parameters:
      buffer - The buffer to read the size from.
      Returns:
      the number of bytes that make up the encoded Symbol value.
      Throws:
      DecodeException - if an error occurs reading the size value.
    • readSize

      protected abstract int readSize(InputStream stream) throws DecodeException
      Subclasses must read the correct number of bytes from the buffer to determine the size of the encoded Symbol value.
      Parameters:
      stream - The InputStream to read the size from.
      Returns:
      the number of bytes that make up the encoded Symbol value.
      Throws:
      DecodeException - if an error occurs reading the size value.