Package io.activej.csp.process.frames
Interface BlockDecoder
public interface BlockDecoder
Defines methods to decode data encoded using as blocks
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final io.activej.bytebuf.ByteBufA 'sentinel' value that indicates end of stream. -
Method Summary
Modifier and TypeMethodDescription@Nullable io.activej.bytebuf.ByteBufdecode(io.activej.bytebuf.ByteBufs bufs) Attempts to decode data blocks contained in aByteBufs.booleanWhether this decoder allows stream to end without End-Of-Stream Block.voidreset()Attempts to reset some internal state of decoder.
-
Field Details
-
END_OF_STREAM
static final io.activej.bytebuf.ByteBuf END_OF_STREAMA 'sentinel' value that indicates end of stream. It should never be used for anything other than indicating end of stream indecode(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 aByteBufs.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
ByteBufthat contains successfully decoded data ornullwhich indicates that there are not enough data in bufs for a block to be decoded.If this method returns
END_OF_STREAMit 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 formatio.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 (ifChannelFrameDecoderis 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
-