com.nothome.delta.text
Class Delta

java.lang.Object
  extended by com.nothome.delta.text.Delta

public class Delta
extends Object

Class for computing deltas against a source. The source file is read by blocks and a hash is computed per block. Then the target is scanned for matching blocks.

Essentially a duplicate of com.nothome.delta.Delta for character streams.


Field Summary
static int DEFAULT_CHUNK_SIZE
          Default size of 16.
 
Constructor Summary
Delta()
           
 
Method Summary
 String compute(CharSequence source, CharSequence target)
          Compares the source bytes with target bytes, returning differences.
 void compute(CharSequence source, CharSequence target, Writer output)
          Compares the source bytes with target bytes, writing to output.
 void compute(SeekableSource seekSource, Reader targetIS, DiffTextWriter output)
          Compares the source with a target, writing to output.
static void main(String[] s)
          Creates a patch with file names.
 void setChunkSize(int size)
          Sets the chunk size used.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_CHUNK_SIZE

public static final int DEFAULT_CHUNK_SIZE
Default size of 16. For "Lorem ipsum" files, the ideal size is about 14. Any smaller and the patch size becomes actually be larger.

Use a size like 64 or 128 for large files.

See Also:
Constant Field Values
Constructor Detail

Delta

public Delta()
Method Detail

setChunkSize

public void setChunkSize(int size)
Sets the chunk size used. Larger chunks are faster and use less memory, but create larger patches as well.

Parameters:
size -

compute

public void compute(CharSequence source,
                    CharSequence target,
                    Writer output)
             throws IOException
Compares the source bytes with target bytes, writing to output.

Throws:
IOException

compute

public String compute(CharSequence source,
                      CharSequence target)
               throws IOException
Compares the source bytes with target bytes, returning differences.

Throws:
IOException

compute

public void compute(SeekableSource seekSource,
                    Reader targetIS,
                    DiffTextWriter output)
             throws IOException
Compares the source with a target, writing to output.

Parameters:
targetIS - second file to compare with
output - diff output
Throws:
IOException - if diff generation fails

main

public static void main(String[] s)
                 throws IOException
Creates a patch with file names.

Throws:
IOException


Copyright © 2003-2008. All Rights Reserved.