org.metastatic.rsync
Interface RollingChecksum

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

public interface RollingChecksum
extends Cloneable, Serializable

A general interface for 32-bit checksums that have the "rolling" property.


Method Summary
 void check(byte[] buf, int offset, int length)
          Replaces the current internal state with entirely new data.
 Object clone()
          Copies this checksum instance into a new instance.
 boolean equals(Object o)
          Tests if a particular checksum is equal to this checksum.
 int getValue()
          Returns the currently-computed 32-bit checksum.
 void reset()
          Resets the internal state of the checksum, so it may be re-used later.
 void roll(byte bt)
          Update the checksum with a single byte.
 void trim()
          Update the checksum by simply "trimming" the least-recently-updated byte from the internal state.
 

Method Detail

getValue

public int getValue()
Returns the currently-computed 32-bit checksum.

Returns:
The checksum.

reset

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


roll

public void roll(byte bt)
Update the checksum with a single byte. This is where the "rolling" method is used.

Parameters:
bt - The next byte.

trim

public void trim()
Update the checksum by simply "trimming" the least-recently-updated byte from the internal state. Most, but not all, checksums can support this.


check

public 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.

clone

public 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

public 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.