if (precontext.length() != 0) { patch.length1 = patch.length2 = precontext.length(); patch.diffs.add(new Diff(Operation.EQUAL, precontext)); start1 += diff_text.length(); empty = false; patch.diffs.add(new Diff(diff_type, diff_text)); bigpatch.diffs.removeFirst(); } else { empty = false; patch.diffs.add(new Diff(diff_type, diff_text)); if (diff_text.equals(bigpatch.diffs.getFirst().text)) { bigpatch.diffs.removeFirst(); patch.diffs.getLast().text += postcontext; } else { patch.diffs.add(new Diff(Operation.EQUAL, postcontext));
diffs.add(new Diff(Operation.EQUAL, "")); // Add a dummy entry at the end. ListIterator<Diff> pointer = diffs.listIterator(); int count_delete = 0; pointer.next(); } else { pointer.add(new Diff(Operation.EQUAL, text_insert.substring(0, commonlength))); pointer.add(new Diff(Operation.DELETE, text_delete)); pointer.add(new Diff(Operation.INSERT, text_insert));
pointer.set(new Diff(Operation.DELETE, lastequality)); pointer.add(new Diff(Operation.INSERT, lastequality)); pointer.add(new Diff(Operation.EQUAL, insertion.substring(0, overlap_length1))); prevDiff.text = pointer.add(new Diff(Operation.EQUAL, deletion.substring(0, overlap_length2))); prevDiff.operation = Operation.INSERT;
diffs.add(new Diff(Operation.EQUAL, "")); int count_delete = 0; int count_insert = 0;
diffs.add(new Diff(Operation.INSERT, text2)); return diffs; diffs.add(new Diff(Operation.DELETE, text1)); return diffs; diffs.add(new Diff(op, longtext.substring(0, i))); diffs.add(new Diff(Operation.EQUAL, shorttext)); diffs.add(new Diff(op, longtext.substring(i + shorttext.length()))); return diffs; diffs.add(new Diff(Operation.DELETE, text1)); diffs.add(new Diff(Operation.INSERT, text2)); return diffs; diffs.add(new Diff(Operation.EQUAL, mid_common)); diffs.addAll(diffs_b); return diffs;
if (diffs.isEmpty() || diffs.getFirst().operation != Operation.EQUAL) { diffs.addFirst(new Diff(Operation.EQUAL, nullPadding)); if (diffs.isEmpty() || diffs.getLast().operation != Operation.EQUAL) { diffs.addLast(new Diff(Operation.EQUAL, nullPadding)); patch.length1 += paddingLength; patch.length2 += paddingLength;
/** * Given an array of patches, return another array that is identical. * * @param patches Array of Patch objects. * @return Array of Patch objects. */ public LinkedList<Patch> patch_deepCopy(LinkedList<Patch> patches) { LinkedList<Patch> patchesCopy = new LinkedList<Patch>(); for (Patch aPatch : patches) { Patch patchCopy = new Patch(); for (Diff aDiff : aPatch.diffs) { Diff diffCopy = new Diff(aDiff.operation, aDiff.text); patchCopy.diffs.add(diffCopy); } patchCopy.start1 = aPatch.start1; patchCopy.start2 = aPatch.start2; patchCopy.length1 = aPatch.length1; patchCopy.length2 = aPatch.length2; patchesCopy.add(patchCopy); } return patchesCopy; }
public static Diff diff(final Operation operation, final String text) { return new Diff(operation, text); }