Interface RollingChecksum

All Superinterfaces:
Cloneable, Serializable
All Known Implementing Classes:
Rsum

public interface RollingChecksum extends Cloneable, Serializable
A general interface for 32-bit checksums that have the "rolling" property.
Version:
$Revision: 1.8 $
Author:
Casey Marshall
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    check(byte[] buf, int offset, int length)
    Replaces the current internal state with entirely new data.
    Copies this checksum instance into a new instance.
    boolean
    Tests if a particular checksum is equal to this checksum.
    void
    first(byte[] buf, int offset, int length)
    Replaces the current internal state with entirely new data.
    int
    Returns the currently-computed 32-bit checksum.
    void
    Resets the internal state of the checksum, so it may be re-used later.
    void
    roll(byte b)
    Update the checksum with a single byte.
  • Method Details

    • getValue

      int getValue()
      Returns the currently-computed 32-bit checksum.
      Returns:
      The checksum.
    • reset

      void reset()
      Resets the internal state of the checksum, so it may be re-used later.
    • roll

      void roll(byte b)
      Update the checksum with a single byte. This is where the "rolling" method is used.
      Parameters:
      b - The next byte.
    • check

      void check(byte[] buf, int offset, int length)
      Replaces the current internal state with entirely new data.
      Parameters:
      buf - The bytes to checksum.
      offset - The offset into buf to start reading.
      length - The number of bytes to update.
    • first

      void first(byte[] buf, int offset, int length)
      Replaces the current internal state with entirely new data. This method is only used to initialize rolling checksum.
      Parameters:
      buf - The bytes to checksum.
      offset - The offset into buf to start reading.
      length - The number of bytes to update.
    • clone

      Object clone()
      Copies this checksum instance into a new instance. This method should be optional, and only implemented if the class implements the Cloneable interface.
      Returns:
      A clone of this instance.
    • equals

      boolean equals(Object o)
      Tests if a particular checksum is equal to this checksum. This means that the other object is an instance of this class, and its internal state equals this checksum's internal state.
      Overrides:
      equals in class Object
      Parameters:
      o - The object to test.
      Returns:
      true if this checksum equals the other checksum.