Class CRC32C

  • All Implemented Interfaces:
    Checksum

    public final class CRC32C
    extends Object
    implements Checksum
    This class was refactored from the original Java 9 implementation to be compatible with Java 8.
    • Constructor Detail

      • CRC32C

        public CRC32C()
        Creates a new CRC32C object.
    • Method Detail

      • update

        public void update​(int b)
        Updates the CRC-32C checksum with the specified byte (the low eight bits of the argument b).
        Specified by:
        update in interface Checksum
      • update

        public void update​(byte[] b,
                           int off,
                           int len)
        Updates the CRC-32C checksum with the specified array of bytes.
        Specified by:
        update in interface Checksum
        Throws:
        ArrayIndexOutOfBoundsException - if off is negative, or len is negative, or off+len is negative or greater than the length of the array b.
      • update

        public void update​(ByteBuffer buffer)
        Updates the CRC-32C checksum with the bytes from the specified buffer.

        The checksum is updated with the remaining bytes in the buffer, starting at the buffer's position. Upon return, the buffer's position will be updated to its limit; its limit will not have been changed.

        Specified by:
        update in interface Checksum
      • reset

        public void reset()
        Resets CRC-32C to initial value.
        Specified by:
        reset in interface Checksum
      • getValue

        public long getValue()
        Returns CRC-32C value.
        Specified by:
        getValue in interface Checksum