org.metastatic.rsync
Class Offsets

java.lang.Object
  |
  +--org.metastatic.rsync.Offsets
All Implemented Interfaces:
Delta, Serializable

public class Offsets
extends Object
implements Delta, Serializable

This class represents an update to a file or array of bytes wherein the bytes themselves have not changed, but have moved to another location. This is represented by three fields: the offset in the original data, the offset in the new data, and the length, in bytes, of this block.

See Also:
Serialized Form

Field Summary
protected  int blockLength
          The size of the moved block, in bytes.
protected  long newOffset
          The new offset.
protected  long oldOffset
          The original offset.
 
Constructor Summary
Offsets(long oldOffset, long newOffset, int blockLength)
          Create a new pair of offsets.
 
Method Summary
 boolean equals(Object o)
          Test if one object is equal to this one.
 int getBlockLength()
          The size of the block of data this class represents.
 long getNewOffset()
          Get the updated offset.
 long getOldOffset()
          Get the original offset.
 long getWriteOffset()
          Get the offset at which this Delta should be written.
 int hashCode()
          Returns the hash code of this object, defined as: oldOffset + newOffset + blockLength % 2^32
 void setBlockLength(int len)
          Set the block size.
 void setNewOffset(long off)
          Set the updated offset.
 void setOldOffset(long off)
          Set the original offset.
 String toString()
          Return a String representation of this object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

oldOffset

protected long oldOffset
The original offset.

Since:
1.1

newOffset

protected long newOffset
The new offset.

Since:
1.1

blockLength

protected int blockLength
The size of the moved block, in bytes.

Since:
1.1
Constructor Detail

Offsets

public Offsets(long oldOffset,
               long newOffset,
               int blockLength)
Create a new pair of offsets. The idea behind this object is that this sort of Delta represents original data that has simply moved in the new data.

Parameters:
oldOffset - The offset in the original data.
newOffset - The offset in the new data.
blockLength - The size, in bytes, of the block that has moved.
Since:
1.1
Method Detail

getWriteOffset

public long getWriteOffset()
Description copied from interface: Delta
Get the offset at which this Delta should be written.

Specified by:
getWriteOffset in interface Delta
Returns:
The write offset.

getBlockLength

public int getBlockLength()
Description copied from interface: Delta
The size of the block of data this class represents.

Specified by:
getBlockLength in interface Delta
Returns:
The size of the block of data this class represents.

getOldOffset

public long getOldOffset()
Get the original offset.

Returns:
The original offset.

setOldOffset

public void setOldOffset(long off)
Set the original offset.

Parameters:
off - The new value for the original offset.

getNewOffset

public long getNewOffset()
Get the updated offset.

Returns:
The updated offset.

setNewOffset

public void setNewOffset(long off)
Set the updated offset.

Parameters:
off - The new value for the updated offset.

setBlockLength

public void setBlockLength(int len)
Set the block size.

Parameters:
len - The new value for the block size.

toString

public String toString()
Return a String representation of this object.

Overrides:
toString in class Object
Returns:
A string representing this object.

equals

public boolean equals(Object o)
Test if one object is equal to this one.

Overrides:
equals in class Object
Returns:
true If o is an Offsets instance and the oldOffset, newOffset, and blockLength fields are all equal.
Throws:
ClassCastException - If o is not an instance of this class.
NullPointerException - If o is null.

hashCode

public int hashCode()
Returns the hash code of this object, defined as:
oldOffset + newOffset + blockLength % 2^32

Overrides:
hashCode in class Object
Returns:
The hash code of this object.