|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.openstreetmap.josm.tools.Diff
public class Diff
A class to compare vectors of objects. The result of comparison
is a list of change
objects which form an
edit script. The objects compared are traditionally lines
of text from two files. Comparison options such as "ignore
whitespace" are implemented by modifying the equals
and hashcode
methods for the objects compared.
The basic algorithm is described in: "An O(ND) Difference Algorithm and its Variations", Eugene Myers, Algorithmica Vol. 1 No. 2, 1986, p 251.
This class outputs different results from GNU diff 1.15 on some inputs. Our results are actually better (smaller change list, smaller total size of changes), but it would be nice to know why. Perhaps there is a memory overwrite bug in GNU diff 1.15.
Nested Class Summary | |
---|---|
static class |
Diff.change
The result of comparison is an "edit script": a chain of change objects. |
(package private) class |
Diff.file_data
Data on one input file being compared. |
(package private) static class |
Diff.ForwardScript
|
(package private) static class |
Diff.ReverseScript
Scan the tables of which lines are inserted and deleted, producing an edit script in reverse order. |
static interface |
Diff.ScriptBuilder
|
Field Summary | |
---|---|
private int[] |
bdiag
|
private int |
bdiagoff
|
private int |
cost
|
private int |
equiv_max
1 more than the maximum equivalence value used for this or its sibling file. |
private int[] |
fdiag
|
private int |
fdiagoff
|
private Diff.file_data[] |
filevec
|
static Diff.ScriptBuilder |
forwardScript
Standard ScriptBuilders. |
boolean |
heuristic
When set to true, the comparison uses a heuristic to speed it up. |
private boolean |
inhibit
|
boolean |
no_discards
When set to true, the algorithm returns a guarranteed minimal set of changes. |
static Diff.ScriptBuilder |
reverseScript
Standard ScriptBuilders. |
private static int |
SNAKE_LIMIT
Snakes bigger than this are considered "big". |
private int[] |
xvec
|
private int[] |
yvec
|
Constructor Summary | |
---|---|
Diff(java.lang.Object[] a,
java.lang.Object[] b)
Prepare to find differences between two arrays. |
Method Summary | |
---|---|
private void |
compareseq(int xoff,
int xlim,
int yoff,
int ylim)
Compare in detail contiguous subsequences of the two files which are known, as a whole, to match each other. |
private int |
diag(int xoff,
int xlim,
int yoff,
int ylim)
Find the midpoint of the shortest edit script for a specified portion of the two files. |
Diff.change |
diff_2(boolean reverse)
|
Diff.change |
diff(Diff.ScriptBuilder bld)
Get the results of comparison as an edit script. |
private void |
discard_confusing_lines()
Discard lines from one file that have no matches in the other file. |
private void |
shift_boundaries()
Adjust inserts/deletes of blank lines to join changes as much as possible. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private int equiv_max
public boolean heuristic
public boolean no_discards
private int[] xvec
private int[] yvec
private int[] fdiag
private int[] bdiag
private int fdiagoff
private int bdiagoff
private final Diff.file_data[] filevec
private int cost
private static final int SNAKE_LIMIT
private boolean inhibit
public static final Diff.ScriptBuilder forwardScript
public static final Diff.ScriptBuilder reverseScript
Constructor Detail |
---|
public Diff(java.lang.Object[] a, java.lang.Object[] b)
equals
. The original Object arrays
are no longer needed for computing the differences. They will
be needed again later to print the results of the comparison as
an edit script, if desired.
Method Detail |
---|
private int diag(int xoff, int xlim, int yoff, int ylim)
private void compareseq(int xoff, int xlim, int yoff, int ylim)
private void discard_confusing_lines()
private void shift_boundaries()
public final Diff.change diff_2(boolean reverse)
public Diff.change diff(Diff.ScriptBuilder bld)
bld
- an object to build the script from change flags
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |