org.metastatic.rsync
Class Matcher

java.lang.Object
  |
  +--org.metastatic.rsync.Matcher

public final class Matcher
extends Object

Methods for performing the checksum search. The result of a search is a List of Delta objects that, when applied to a method in Rebuilder, will reconstruct the new version of the data.


Field Summary
protected  int chunkSize
          The size of allocated byte arrays.
protected  List deltas
          The list of deltas being built.
protected  MatcherStream matcher
          The underlying matcher stream.
 
Constructor Summary
Matcher(Configuration config)
          Create a matcher with the specified configuration.
 
Method Summary
 List hashSearch(List sums, byte[] buf)
          Search the given byte buffer.
 List hashSearch(List sums, byte[] buf, int off, int len)
          Search a portion of a byte buffer.
 List hashSearch(List sums, File f)
          Search a file.
 List hashSearch(List sums, InputStream in)
          Search an input stream.
 List hashSearch(List sums, String filename)
          Search a file by name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

deltas

protected final List deltas
The list of deltas being built.


matcher

protected final MatcherStream matcher
The underlying matcher stream.


chunkSize

protected final int chunkSize
The size of allocated byte arrays.

Constructor Detail

Matcher

public Matcher(Configuration config)
Create a matcher with the specified configuration.

Parameters:
config - The Configuration for this Matcher.
Method Detail

hashSearch

public List hashSearch(List sums,
                       byte[] buf)
Search the given byte buffer.

Parameters:
sums - The checksums to search for.
buf - The data buffer to search.
Returns:
A collection of Deltas derived from this search.

hashSearch

public List hashSearch(List sums,
                       byte[] buf,
                       int off,
                       int len)
Search a portion of a byte buffer.

Parameters:
sums - The checksums to search for.
buf - The data buffer to search.
off - The offset in buf to begin.
len - The number of bytes to search from buf.
Returns:
A collection of Deltas derived from this search.

hashSearch

public List hashSearch(List sums,
                       String filename)
                throws IOException
Search a file by name.

Parameters:
sums - The checksums to search for.
filename - The name of the file to search.
Returns:
A list of deltas derived from this search.
Throws:
IOException - If filename cannot be read.

hashSearch

public List hashSearch(List sums,
                       File f)
                throws IOException
Search a file.

Parameters:
sums - The checksums to search for.
f - The file to search.
Returns:
A list of Deltas derived from this search.
Throws:
IOException - If f cannot be read.

hashSearch

public List hashSearch(List sums,
                       InputStream in)
                throws IOException
Search an input stream.

Parameters:
in - The input stream to search.
Returns:
A collection of Deltas derived from this search.
Throws:
IOException - If an exception occurs while reading.