Class CheckSum

  • Direct Known Subclasses:
    AdHash, Adler32CheckSum, CRC32CheckSum, MD5CheckSum

    public abstract class CheckSum
    extends java.lang.Object
    Parent class for various running checksum implementations. CheckSum has 2 modes -- write mode and read mode. Updating check sum is only available in the write mode. When getCheckSum() is called, the object will flip to the read mode and Checksum value will be finalized. reset() can flip the object back to the write mode and checksum value will be re-initialized.
    • Constructor Detail

      • CheckSum

        public CheckSum()
    • Method Detail

      • update

        public void update​(byte[] input,
                           int startIndex,
                           int length)
        Update the checksum buffer to include input with startIndex and length. Following calls to multiple 'update's you need to call 'getCheckSum' which will reset the buffer as well.
      • updateChecksum

        protected abstract void updateChecksum​(byte[] input,
                                               int startIndex,
                                               int length)
      • getCheckSum

        public byte[] getCheckSum()
        Get the checkSum of the buffer till now. When it called, the object will flip from write mode to read mode
      • getFinalCheckSum

        protected abstract byte[] getFinalCheckSum()
      • reset

        public void reset()
        Reset the checksum generator
      • resetInternal

        public abstract void resetInternal()
      • getEncodedState

        public byte[] getEncodedState()
      • update

        public void update​(int number)
        Update the underlying buffer using the integer
        Parameters:
        number - number to be stored in checksum buffer
      • update

        public void update​(short number)
        Update the underlying buffer using the short
        Parameters:
        number - number to be stored in checksum buffer
      • update

        public void update​(byte[] input)
        Update the checksum buffer to include input
        Parameters:
        input - bytes added to the buffer
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object