Class FrameFormats

java.lang.Object
io.activej.csp.process.frames.FrameFormats

public class FrameFormats extends Object
  • Constructor Details

    • FrameFormats

      public FrameFormats()
  • Method Details

    • compound

      public static FrameFormat compound(FrameFormat mainFormat, FrameFormat... otherFormats)
      A combination of different frame formats. This FrameFormat encodes 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

      public static FrameFormat 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 format

      You can wrap this frame format using withMagicNumber(FrameFormat, byte[]) by specifying custom magic number to be used

    • sizePrefixed

      public static FrameFormat 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

      public static FrameFormat withMagicNumber(FrameFormat frameFormat, byte[] magicNumber)
      A frame format that adds specified magic number to the start of the stream.