Package io.activej.csp.process.frames
Class FrameFormats
java.lang.Object
io.activej.csp.process.frames.FrameFormats
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic FrameFormatcompound(FrameFormat mainFormat, FrameFormat... otherFormats) A combination of different frame formats.static FrameFormatidentity()A frame format that does not change incoming data in any way.static FrameFormatA frame format that encodes data preceding it with its size.static FrameFormatwithMagicNumber(FrameFormat frameFormat, byte[] magicNumber) A frame format that adds specified magic number to the start of the stream.
-
Constructor Details
-
FrameFormats
public FrameFormats()
-
-
Method Details
-
compound
A combination of different frame formats. ThisFrameFormatencodes data using frame format passed as a first argument. Stream is decoded by the first decoder that can determine that data corresponds to decoder's format.- Parameters:
mainFormat- a format that will be used for encoding data (will also be used as a candidate for decoding)otherFormats- formats that are candidates for decoding data- Returns:
- a compound frame format that consists of several other frame formats
-
identity
A frame format that does not change incoming data in any way.Should be used in
compound(FrameFormat, FrameFormat...)method only as the last frame format as it determines any data to have a correct formatYou can wrap this frame format using
withMagicNumber(FrameFormat, byte[])by specifying custom magic number to be used -
sizePrefixed
A frame format that encodes data preceding it with its size.Should not be used in
compound(FrameFormat, FrameFormat...)method, as it does not determine its format (unless stream does not start with proper VarInt bytes)You can wrap this frame format using
withMagicNumber(FrameFormat, byte[])by specifying custom magic number to be used -
withMagicNumber
A frame format that adds specified magic number to the start of the stream.
-