Interface BlockDecoder


public interface BlockDecoder
Defines methods to decode data encoded using as blocks
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final io.activej.bytebuf.ByteBuf
    A 'sentinel' value that indicates end of stream.
  • Method Summary

    Modifier and Type
    Method
    Description
    @Nullable io.activej.bytebuf.ByteBuf
    decode(io.activej.bytebuf.ByteBufs bufs)
    Attempts to decode data blocks contained in a ByteBufs.
    boolean
    Whether this decoder allows stream to end without End-Of-Stream Block.
    void
    Attempts to reset some internal state of decoder.
  • Field Details

    • END_OF_STREAM

      static final io.activej.bytebuf.ByteBuf END_OF_STREAM
      A 'sentinel' value that indicates end of stream. It should never be used for anything other than indicating end of stream in decode(ByteBufs) method
  • Method Details

    • decode

      @Nullable @Nullable io.activej.bytebuf.ByteBuf decode(io.activej.bytebuf.ByteBufs bufs) throws io.activej.common.exception.MalformedDataException
      Attempts to decode data blocks contained in a ByteBufs.

      Decoder is forbidden to consume any bytes from bufs if it has not yet determined that encoded data corresponds to decoder's format

      Parameters:
      bufs - queue that contains encoded data
      Returns:
      a ByteBuf that contains successfully decoded data or null which indicates that there are not enough data in bufs for a block to be decoded.

      If this method returns END_OF_STREAM it indicates that end of stream has been reached and no more data is expected.

      Throws:
      io.activej.common.exception.UnknownFormatException - if data is encoded using unknown format
      io.activej.common.exception.MalformedDataException - if data is malformed
    • reset

      void reset()
      Attempts to reset some internal state of decoder. This method is called after each successfully decoded block (if ChannelFrameDecoder is configured to do so).
    • ignoreMissingEndOfStreamBlock

      boolean ignoreMissingEndOfStreamBlock()
      Whether this decoder allows stream to end without End-Of-Stream Block.

      Stream still has to end with a valid complete Data Block (or be empty) and should not have any trailing data after the last block

      Returns:
      whether decoder supports missing End-Of-Stream Blocks