public class Diff
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
class |
Diff.Part
This class represents a part of the diff, meaning one operation
(or one line of a "normal" diff)
|
Modifier and Type | Field and Description |
---|---|
protected java.lang.Object[] |
changed |
protected java.lang.Object[] |
original |
private java.util.ArrayList<Diff.Part> |
parts |
Constructor and Description |
---|
Diff(java.lang.Object[] original,
java.lang.Object[] changed,
int minConsecutive) |
Diff(java.lang.String original,
java.lang.String changed) |
Diff(java.lang.String original,
java.lang.String changed,
int minConsecutive) |
Modifier and Type | Method and Description |
---|---|
private void |
addReplacementParts(int startx,
int starty,
int endx,
int endy) |
private static int[] |
findDiagonal(int x,
int y,
boolean[][] matrix,
int minLength)
Search for a diagonal with minimal length
minLength line by line in a submatrix
{ x, y, matrix[0].length, matrix.length} of the matrix : {_1,__,__} -> X axis ,{__,_1,__} ,{__,__,_1} TODO: some optimisation ideas search for a better algorithm on the inet!!! :) pass only the part of the matrix where the search takes place - not the whole matrix everytime break the inner loop if the rest of the matrix is smaller than minLength (and no diagonal has been found yet) return diagonal topologicaly closest to the {0,0} |
java.lang.Object[] |
getNew() |
java.lang.Object[] |
getOriginal() |
Diff.Part[] |
getParts()
A diff is composed of different parts.
|
private void |
parse(int minLength) |
static java.lang.String |
toHTML(Diff[] diffs) |
java.lang.String |
toString() |
private final java.util.ArrayList<Diff.Part> parts
protected final java.lang.Object[] original
protected final java.lang.Object[] changed
public Diff(java.lang.String original, java.lang.String changed)
original
- the original String
changed
- the new String
java.lang.NullPointerException
- if one of the arguments is null
public Diff(java.lang.String original, java.lang.String changed, int minConsecutive)
original
- the original String
changed
- the new String
minConsecutive
- the minimum number of consecutive equal characters in
both Strings. Smaller seperations will only be performed on the end of either
String if neededjava.lang.NullPointerException
- if original
or changed
is
null
public Diff(java.lang.Object[] original, java.lang.Object[] changed, int minConsecutive)
private void parse(int minLength)
private void addReplacementParts(int startx, int starty, int endx, int endy)
private static int[] findDiagonal(int x, int y, boolean[][] matrix, int minLength)
minLength
line by line in a submatrix
{ x, y, matrix[0].length, matrix.length}
of the matrix
: {_1,__,__} -> X axis
,{__,_1,__}
,{__,__,_1}
x
- the starting position of the search on the optical horizontal axisy
- the starting position of the search on the optical vertical axismatrix
- the matrix to search throughminLength
- the minimal desired length of a diagonal to find{ diagStartX, diagStartY, diagLength }
where diagLength >= minLength
public java.lang.Object[] getOriginal()
Object[]
passed to this class on instantiationpublic java.lang.Object[] getNew()
Object[]
passed to this class on instantiationpublic Diff.Part[] getParts()
Diff.Part
public java.lang.String toString()
toString
in class java.lang.Object
public static java.lang.String toHTML(Diff[] diffs)