Class CrcCombineOnMarkChecksum

  • All Implemented Interfaces:
    Checksum, SdkChecksum

    @SdkInternalApi
    public class CrcCombineOnMarkChecksum
    extends Object
    implements SdkChecksum
    Class that provides functionality for combining CRC checksums with mark and reset capabilities.

    This class allows combining two CRC values, making it efficient to update and restore the checksum during mark and reset operations. It is particularly useful in scenarios where a checksum needs to be marked, potentially reset to a previous state, and combined with additional data.

    The class maintains an internal Checksum instance and uses a BiFunction to combine two CRC values when necessary. The combine function is applied to a pair of CRC values, along with the length of the data, to produce the resulting combined checksum.

    • Constructor Detail

    • Method Detail

      • getChecksumBytes

        public byte[] getChecksumBytes()
        Description copied from interface: SdkChecksum
        Returns the computed checksum in a byte array rather than the long provided by Checksum.getValue().
        Specified by:
        getChecksumBytes in interface SdkChecksum
        Returns:
        byte[] containing the checksum
      • mark

        public void mark​(int readLimit)
        Description copied from interface: SdkChecksum
        Allows marking a checksum for checksums that support the ability to mark and reset.
        Specified by:
        mark in interface SdkChecksum
        Parameters:
        readLimit - the maximum limit of bytes that can be read before the mark position becomes invalid.
      • update

        public void update​(int b)
        Specified by:
        update in interface Checksum
      • update

        public void update​(byte[] b,
                           int off,
                           int len)
        Specified by:
        update in interface Checksum
      • getValue

        public long getValue()
        Specified by:
        getValue in interface Checksum
      • reset

        public void reset()
        Specified by:
        reset in interface Checksum