use of com.sksamuel.diffpatch.DiffMatchPatch in project muikku by otavanopisto.
the class CoOpsDmpDiffAlgorithm method unpatch.
@Override
public String unpatch(String data, String patch) throws CoOpsConflictException {
DiffMatchPatch diffMatchPatch = new DiffMatchPatch();
LinkedList<Patch> patches = createUnpatch(new LinkedList<Patch>(diffMatchPatch.patch_fromText(patch)));
Object[] patchResult = diffMatchPatch.patch_apply(patches, data);
for (boolean applied : (boolean[]) patchResult[1]) {
if (!applied) {
throw new CoOpsConflictException();
}
}
return (String) patchResult[0];
}
use of com.sksamuel.diffpatch.DiffMatchPatch in project muikku by otavanopisto.
the class CoOpsDmpDiffAlgorithm method patch.
@Override
public String patch(String data, String patch) throws CoOpsConflictException {
DiffMatchPatch diffMatchPatch = new DiffMatchPatch();
LinkedList<Patch> patches = new LinkedList<Patch>(diffMatchPatch.patch_fromText(patch));
Object[] patchResult = diffMatchPatch.patch_apply(patches, data);
for (boolean applied : (boolean[]) patchResult[1]) {
if (!applied) {
throw new CoOpsConflictException();
}
}
return (String) patchResult[0];
}
use of com.sksamuel.diffpatch.DiffMatchPatch in project muikku by otavanopisto.
the class HtmlMaterialCleaner method createPatch.
private String createPatch(String oldHtml, String newHtml) {
DiffMatchPatch diffMatchPatch = new DiffMatchPatch();
LinkedList<Diff> diffs = diffMatchPatch.diff_main(oldHtml, newHtml);
diffMatchPatch.diff_cleanupEfficiency(diffs);
LinkedList<Patch> patch = diffMatchPatch.patch_make(diffs);
return diffMatchPatch.patch_toText(patch);
}
Aggregations