org.metastatic.rsync
Class ChecksumPair

java.lang.Object
  |
  +--org.metastatic.rsync.ChecksumPair
All Implemented Interfaces:
Serializable

public class ChecksumPair
extends Object
implements 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.

See Also:
Serialized Form

Constructor Summary
ChecksumPair(int weak, byte[] strong)
          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
 boolean equals(Object obj)
          We define equality for this object as equality between two weak sums and equality between two strong sums.
 int getLength()
          Return the length of the data for which this checksum pair was generated.
 long getOffset()
          Return the offset from where this checksum pair was generated.
 int getSequence()
          Return the sequence number of this checksum pair, if any.
 byte[] getStrong()
          Get the strong checksum.
 int getWeak()
          Get the weak checksum.
 int hashCode()
           
 String toString()
          Returns a String representation of this pair.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

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.
Method Detail

getWeak

public int getWeak()
Get the weak checksum.

Returns:
The weak checksum.
Since:
1.1

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()
Overrides:
hashCode in class Object

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