Class ChecksumPair

java.lang.Object
io.milton.zsync.ChecksumPair
All Implemented Interfaces:
Serializable, Cloneable

public class ChecksumPair extends Object implements Cloneable, Serializable
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

    Constructors
    Constructor
    Description
    ChecksumPair(int weak)
    Create a new checksum pair with only weak checksum
    ChecksumPair(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 Type
    Method
    Description
    boolean
    We define equality for this object as equality between two weak sums and equality between two strong sums.
    int
    Return the length of the data for which this checksum pair was generated.
    long
    Return the offset from where this checksum pair was generated.
    int
    Return the sequence number of this checksum pair, if any.
    byte[]
    Get the strong checksum.
    Get the strong checksum in hexadecimal format.
    int
    Get the weak checksum.
    Get the weak checksum in hexadecimal format.
    int
    Hashcode is produced from summing 4bytes of weakSum into 2bytes
    Returns a String representation of this pair.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • 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

      public String getWeakHex()
      Get the weak checksum in hexadecimal format.
      Returns:
      The weak checksum.
    • getStrongHex

      public String 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
      Overrides:
      hashCode in class Object
      Returns:
      Hash value of weaksum
    • equals

      public boolean equals(Object obj)
      We define equality for this object as equality between two weak sums and equality between two strong sums.
      Overrides:
      equals in class Object
      Parameters:
      obj - The Object to test.
      Returns:
      True if both checksum pairs are equal.
    • toString

      public String toString()
      Returns a String representation of this pair.
      Overrides:
      toString in class Object
      Returns:
      The String representation of this pair.
      Since:
      1.2