Package io.milton.zsync
Interface RollingChecksum
- All Superinterfaces:
Cloneable,Serializable
- All Known Implementing Classes:
Rsum
A general interface for 32-bit checksums that have the "rolling"
property.
- Version:
- $Revision: 1.8 $
- Author:
- Casey Marshall
-
Method Summary
Modifier and TypeMethodDescriptionvoidcheck(byte[] buf, int offset, int length) Replaces the current internal state with entirely new data.clone()Copies this checksum instance into a new instance.booleanTests if a particular checksum is equal to this checksum.voidfirst(byte[] buf, int offset, int length) Replaces the current internal state with entirely new data.intgetValue()Returns the currently-computed 32-bit checksum.voidreset()Resets the internal state of the checksum, so it may be re-used later.voidroll(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 intobufto 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 intobufto 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 theCloneableinterface.- Returns:
- A clone of this instance.
-
equals
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.
-