Package io.milton.zsync
Class ChecksumPair
java.lang.Object
io.milton.zsync.ChecksumPair
- All Implemented Interfaces:
Serializable,Cloneable
A pair of weak and strong checksums for use with the Rsync algorithm.
The weak "rolling" checksum is typically a 32-bit sum derived from
the Adler32 algorithm; the strong checksum is usually a 128-bit MD4
checksum.
- Version:
- $Revision: 1.9 $
- Author:
- Casey Marshall
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionChecksumPair(int weak) Create a new checksum pair with only weak checksumChecksumPair(int weak, byte[] strong) Create a new checksum pair with no associated offset.ChecksumPair(int weak, byte[] strong, int seq) Create a new checksum pair with no associated offset.ChecksumPair(int weak, byte[] strong, long offset) Create a new checksum pair with no length or sequence fields.ChecksumPair(int weak, byte[] strong, long offset, int length, int seq) Create a new checksum pair. -
Method Summary
Modifier and TypeMethodDescriptionbooleanWe define equality for this object as equality between two weak sums and equality between two strong sums.intReturn the length of the data for which this checksum pair was generated.longReturn the offset from where this checksum pair was generated.intReturn the sequence number of this checksum pair, if any.byte[]Get the strong checksum.Get the strong checksum in hexadecimal format.intgetWeak()Get the weak checksum.Get the weak checksum in hexadecimal format.inthashCode()Hashcode is produced from summing 4bytes of weakSum into 2bytestoString()Returns a String representation of this pair.
-
Constructor Details
-
ChecksumPair
public ChecksumPair(int weak, byte[] strong, long offset, int length, int seq) Create a new checksum pair.- Parameters:
weak- The weak, rolling checksum.strong- The strong checksum.offset- The offset at which this checksum was computed.length- The length of the data over which this sum was computed.seq- The sequence number of this checksum pair.
-
ChecksumPair
public ChecksumPair(int weak, byte[] strong, long offset) Create a new checksum pair with no length or sequence fields.- Parameters:
weak- The weak checksum.strong- The strong checksum.offset- The offset at which this checksum was computed.
-
ChecksumPair
public ChecksumPair(int weak, byte[] strong) Create a new checksum pair with no associated offset.- Parameters:
weak- The weak checksum.strong- The strong checksum.
-
ChecksumPair
public ChecksumPair(int weak) Create a new checksum pair with only weak checksum- Parameters:
weak- The weak checksum.
-
ChecksumPair
public ChecksumPair(int weak, byte[] strong, int seq) Create a new checksum pair with no associated offset.- Parameters:
weak- The weak checksum.strong- The strong checksum.seq- The sequence number
-
-
Method Details
-
getWeak
public int getWeak()Get the weak checksum.- Returns:
- The weak checksum.
- Since:
- 1.1
-
getWeakHex
Get the weak checksum in hexadecimal format.- Returns:
- The weak checksum.
-
getStrongHex
Get the strong checksum in hexadecimal format.- Returns:
- The strong checksum.
-
getStrong
public byte[] getStrong()Get the strong checksum.- Returns:
- The strong checksum.
- Since:
- 1.1
-
getOffset
public long getOffset()Return the offset from where this checksum pair was generated.- Returns:
- The offset.
-
getLength
public int getLength()Return the length of the data for which this checksum pair was generated.- Returns:
- The length.
-
getSequence
public int getSequence()Return the sequence number of this checksum pair, if any.- Returns:
- The sequence number.
-
hashCode
public int hashCode()Hashcode is produced from summing 4bytes of weakSum into 2bytes -
equals
We define equality for this object as equality between two weak sums and equality between two strong sums. -
toString
Returns a String representation of this pair.
-