Interface ContentCodec


  • public interface ContentCodec
    API to support encode and decode of Buffers.

    Implementations must provide thread safety semantics, since instances could be shared across threads.

    • Method Detail

      • name

        java.lang.CharSequence name()
        A unique textual representation for the coding.
        Returns:
        a unique textual representation for the coding.
      • encode

        default Buffer encode​(Buffer src,
                              BufferAllocator allocator)
        Take a Buffer and encode its contents resulting in a Buffer with the encoded contents. This call increases the readerIndex of the src with the number of bytes available to read src.readableBytes().
        Parameters:
        src - the Buffer to encode
        allocator - the BufferAllocator to use for allocating auxiliary buffers or the returned buffer
        Returns:
        Buffer the result buffer with the content encoded
      • encode

        Buffer encode​(Buffer src,
                      int offset,
                      int length,
                      BufferAllocator allocator)
        Take a Buffer and encode its contents resulting in a Buffer with the encoded contents. This call increases the readerIndex of the src with the number of bytes read length.
        Parameters:
        src - the Buffer to encode
        offset - the offset after the current Buffer's readerInde to start reading from
        length - the total count of bytes to read
        allocator - the BufferAllocator to use for allocating auxiliary buffers or the returned buffer
        Returns:
        Buffer the result buffer with the content encoded
      • decode

        default Buffer decode​(Buffer src,
                              BufferAllocator allocator)
        Take a Buffer and decode its contents resulting in a Buffer with the decoded content. This call increases the readerIndex of the src with the number of bytes available to read src.readableBytes().
        Parameters:
        src - the Buffer to decode
        allocator - the BufferAllocator to use for allocating auxiliary buffers or the returned buffer
        Returns:
        Buffer the result buffer with the content decoded
      • decode

        Buffer decode​(Buffer src,
                      int offset,
                      int length,
                      BufferAllocator allocator)
        Take a Buffer and decode its contents resulting in a Buffer with the decoded content. This call increases the readerIndex of the src with the number of bytes read length.
        Parameters:
        src - the Buffer to decode
        offset - the offset after the current Buffer's readerIndex to start reading from
        length - the total count of bytes to read
        allocator - the BufferAllocator to use for allocating auxiliary buffers or the returned buffer
        Returns:
        Buffer the result buffer with the content decoded