org.metastatic.rsync
Class Rebuilder

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

public class Rebuilder
extends Object

Methods for file reconstruction from deltas.


Constructor Summary
Rebuilder()
           
 
Method Summary
static byte[] rebuild(byte[] buf, List deltas)
          Reconstruct data into a new byte array.
static void rebuild(OutputStream out, byte[] buf, List deltas)
          Reconstruct data into an output stream.
static void rebuild(OutputStream out, File oldFile, List deltas)
          Reconstruct a file into an output stream.
static void rebuildFile(File oldFile, File newFile, List deltas)
          Reconstruct a file into newFile.
static File rebuildFile(File oldFile, List deltas)
          Reconstruct a file into a new file created with File.createTempFile(java.lang.String,java.lang.String,java.io.File).
static void rebuildFileInPlace(File file, List deltas)
          Reconstruct a file in-place.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Rebuilder

public Rebuilder()
Method Detail

rebuild

public static byte[] rebuild(byte[] buf,
                             List deltas)
Reconstruct data into a new byte array.

Parameters:
buf - The original data.
deltas - The deltas to apply.
Returns:
The reconstructed data.

rebuild

public static void rebuild(OutputStream out,
                           byte[] buf,
                           List deltas)
                    throws IOException
Reconstruct data into an output stream.

Parameters:
out - The sink for reconstructed data.
buf - The original data.
deltas - The deltas to apply.
IOException

rebuild

public static void rebuild(OutputStream out,
                           File oldFile,
                           List deltas)
                    throws IOException
Reconstruct a file into an output stream.

Parameters:
out - The sink for reconstructed data.
oldFile - The original file.
deltas - The deltas to apply.
IOException

rebuildFile

public static File rebuildFile(File oldFile,
                               List deltas)
                        throws IOException
Reconstruct a file into a new file created with File.createTempFile(java.lang.String,java.lang.String,java.io.File). This file can then be renamed to the destination.

Parameters:
oldFile - The original file.
deltas - A collection of Deltas to apply to the original file.
Returns:
A unique File containing the reconstruction.
IOException

rebuildFile

public static void rebuildFile(File oldFile,
                               File newFile,
                               List deltas)
                        throws IOException
Reconstruct a file into newFile.

Parameters:
oldFile - The original file.
newFile - The file to write the reconstruction to. This must be a different file than oldFile
deltas - The Deltas to apply.
IOException

rebuildFileInPlace

public static void rebuildFileInPlace(File file,
                                      List deltas)
                               throws IOException
Reconstruct a file in-place. The contents of file will be overwritten with the contents of the reconstructed file.

Parameters:
file - The file to reconstruct.
deltas - The Deltas to apply.
IOException