org.apache.wicket.util.diff.myers
Class MyersDiff

java.lang.Object
  extended by org.apache.wicket.util.diff.myers.MyersDiff
All Implemented Interfaces:
DiffAlgorithm

public class MyersDiff
extends java.lang.Object
implements DiffAlgorithm

A clean-room implementation of Eugene Myers differencing algorithm.

See the paper at http://www.cs.arizona.edu/people/gene/PAPERS/diff.ps

Version:
$Revision: 1.1 $ $Date: 2006/03/12 00:24:21 $
Author:
Juanco Anez
See Also:
Delta, Revision, Diff

Constructor Summary
MyersDiff()
          Constructs an instance of the Myers differencing algorithm.
 
Method Summary
static PathNode buildPath(java.lang.Object[] orig, java.lang.Object[] rev)
          Computes the minimum diffpath that expresses de differences between the original and revised sequences, according to Gene Myers differencing algorithm.
static Revision buildRevision(PathNode path, java.lang.Object[] orig, java.lang.Object[] rev)
          Constructs a Revision from a difference path.
 Revision diff(java.lang.Object[] orig, java.lang.Object[] rev)
          Computes the difference between the original sequence and the revised sequence and returns it as a Revision object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MyersDiff

public MyersDiff()
Constructs an instance of the Myers differencing algorithm.

Method Detail

diff

public Revision diff(java.lang.Object[] orig,
                     java.lang.Object[] rev)
              throws DifferentiationFailedException
Computes the difference between the original sequence and the revised sequence and returns it as a Revision object.

The revision can be used to construct the revised sequence from the original sequence.

Specified by:
diff in interface DiffAlgorithm
rev - the revised text
Returns:
the revision script.
Throws:
DifferentiationFailedException - if the diff could not be computed.

buildPath

public static PathNode buildPath(java.lang.Object[] orig,
                                 java.lang.Object[] rev)
                          throws DifferentiationFailedException
Computes the minimum diffpath that expresses de differences between the original and revised sequences, according to Gene Myers differencing algorithm.

Parameters:
orig - The original sequence.
rev - The revised sequence.
Returns:
A minimum Path across the differences graph.
Throws:
DifferentiationFailedException - if a diff path could not be found.

buildRevision

public static Revision buildRevision(PathNode path,
                                     java.lang.Object[] orig,
                                     java.lang.Object[] rev)
Constructs a Revision from a difference path.

Parameters:
path - The path.
orig - The original sequence.
rev - The revised sequence.
Returns:
A Revision script corresponding to the path.
Throws:
DifferentiationFailedException - if a Revision could not be built from the given path.


Copyright © 2004-2010 Apache Software Foundation. All Rights Reserved.