Codota Logo
DiffMatchPatch
Code IndexAdd Codota to your IDE (free)

How to use
DiffMatchPatch
in
org.jboss.aerogear.sync.diffmatchpatch

Best Java code snippets using org.jboss.aerogear.sync.diffmatchpatch.DiffMatchPatch (Showing top 16 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Dictionary d =
  • Codota Iconnew Hashtable()
  • Codota IconBundle bundle;bundle.getHeaders()
  • Codota Iconnew Properties()
  • Smart code suggestions by Codota
}
origin: org.jboss.aerogear/sync-diffmatchpatch-core

/**
 * Compute a list of patches to turn text1 into text2.
 * A set of diffs will be computed.
 *
 * @param text1 Old text.
 * @param text2 New text.
 * @return LinkedList of Patch objects.
 */
public LinkedList<Patch> patchMake(String text1, String text2) {
  if (text1 == null || text2 == null) {
    throw new IllegalArgumentException("Null inputs. (patchMake)");
  }
  // No diffs provided, compute our own.
  LinkedList<Diff> diffs = diffMain(text1, text2, true);
  if (diffs.size() > 2) {
    diff_cleanupSemantic(diffs);
    diffCleanupEfficiency(diffs);
  }
  return patchMake(text1, diffs);
}
origin: org.jboss.aerogear/sync-diffmatchpatch-core

public DiffMatchPatch build() {
  return new DiffMatchPatch(this);
}
origin: org.jboss.aerogear/sync-diffmatchpatch-core

/**
 * Compute a list of patches to turn text1 into text2.
 * text1 will be derived from the provided diffs.
 *
 * @param diffs Array of Diff objects for text1 to text2.
 * @return LinkedList of Patch objects.
 */
public LinkedList<Patch> patchMake(LinkedList<Diff> diffs) {
  if (diffs == null) {
    throw new IllegalArgumentException("Null inputs. (patchMake)");
  }
  // No origin string provided, compute our own.
  String text1 = diffText1(diffs);
  return patchMake(text1, diffs);
}
origin: org.jboss.aerogear/sync-diffmatchpatch-core

patches = patch_deepCopy(patches);
String nullPadding = patchAddPadding(patches);
text = nullPadding + text + nullPadding;
patchSplitMax(patches);
for (Patch aPatch : patches) {
  int expected_loc = aPatch.start2 + delta;
  String text1 = diffText1(aPatch.diffs);
  int start_loc;
  int end_loc = -1;
    start_loc = matchMain(text,
        text1.substring(0, this.matchMaxbits), expected_loc);
    if (start_loc != -1) {
      end_loc = matchMain(text,
          text1.substring(text1.length() - this.matchMaxbits),
          expected_loc + text1.length() - this.matchMaxbits);
    start_loc = matchMain(text, text1, expected_loc);
      text = text.substring(0, start_loc) + diffText2(aPatch.diffs)
          + text.substring(start_loc + text1.length());
    } else {
      LinkedList<DiffMatchPatch.Diff> diffs = diffMain(text1, text2, false);
      if (text1.length() > this.matchMaxbits
          && diffLevenshtein(diffs) / (float) text1.length()
          > this.patchDeleteThreshold) {
origin: org.jboss.aerogear/sync-diffmatchpatch-core

LinesToCharsResult b = diffLinesToChars(text1, text2);
text1 = b.chars1;
text2 = b.chars2;
List<String> linearray = b.lineArray;
LinkedList<Diff> diffs = diffMain(text1, text2, false, deadline);
diffCharsToLines(diffs, linearray);
diff_cleanupSemantic(diffs);
          pointer.remove();
        for (Diff newDiff : diffMain(text_delete, text_insert, false,
            deadline)) {
          pointer.add(newDiff);
origin: org.jboss.aerogear/sync-diffmatchpatch-core

String[] hm = diffHalfMatch(text1, text2);
if (hm != null) {
  String mid_common = hm[4];
  LinkedList<Diff> diffs_a = diffMain(text1_a, text2_a,
      checklines, deadline);
  LinkedList<Diff> diffs_b = diffMain(text1_b, text2_b,
      checklines, deadline);
  return diffLineMode(text1, text2, deadline);
return diffBisect(text1, text2, deadline);
origin: org.jboss.aerogear/sync-diffmatchpatch-server

@Override
public DiffMatchPatchEdit clientDiff(final Document<String> document, final ShadowDocument<String> shadowDocument) {
  final String shadowText = shadowDocument.document().content();
  final LinkedList<DiffMatchPatch.Diff> diffs = diffMatchPatch.diffMain(document.content(), shadowText);
  return DiffMatchPatchEdit.withChecksum(checksum(shadowText)).diffs(asAeroGearDiffs(diffs)).build();
}
origin: org.jboss.aerogear/sync-diffmatchpatch-core

/**
 * Find the differences between two texts.
 * Run a faster, slightly less optimal diff.
 * This method allows the 'checklines' of diffMain() to be optional.
 * Most of the time checklines is wanted, so default to true.
 *
 * @param text1 Old string to be diffed.
 * @param text2 New string to be diffed.
 * @return Linked List of Diff objects.
 */
public LinkedList<Diff> diffMain(String text1, String text2) {
  return diffMain(text1, text2, true);
}
origin: org.jboss.aerogear/sync-diffmatchpatch-core

/**
 * Compute a list of patches to turn text1 into text2.
 * text2 is ignored, diffs are the delta between text2 and text2.
 *
 * @param text1 Old text
 * @param text2 Ignored.
 * @param diffs Array of Diff objects for text1 to text2.
 * @return LinkedList of Patch objects.
 * @deprecated Prefer {@link #patchMake(java.lang.String, java.util.LinkedList) }.
 */
public LinkedList<Patch> patchMake(String text1, String text2, LinkedList<Diff> diffs) {
  return patchMake(text1, diffs);
}
origin: org.jboss.aerogear/sync-diffmatchpatch-server

public DiffMatchPatchServerSynchronizer() {
  this(builder().build());
}
origin: org.jboss.aerogear/sync-diffmatchpatch-server

private static LinkedList<DiffMatchPatch.Diff> asDiffUtilDiffs(final LinkedList<DiffMatchPatchDiff> diffs) {
  final LinkedList<DiffMatchPatch.Diff> dsf = new LinkedList<DiffMatchPatch.Diff>();
  for (DiffMatchPatchDiff d : diffs) {
    dsf.add(DiffMatchPatch.diff(diffutilOp(d.operation()), d.text()));
  }
  return dsf;
}
origin: org.jboss.aerogear/sync-diffmatchpatch-core

if (x1 >= x2) {
  return diffBisectSplit(text1, text2, x1, y1, deadline);
if (x1 >= x2) {
  return diffBisectSplit(text1, text2, x1, y1, deadline);
origin: org.jboss.aerogear/sync-diffmatchpatch-server

@Override
public DiffMatchPatchEdit serverDiff(final Document<String> document, final ShadowDocument<String> shadowDocument) {
  final String shadowText = shadowDocument.document().content();
  final LinkedList<DiffMatchPatch.Diff> diffs = diffMatchPatch.diffMain(shadowText, document.content());
  return DiffMatchPatchEdit.withChecksum(checksum(shadowText))
      .serverVersion(shadowDocument.serverVersion())
      .clientVersion(shadowDocument.clientVersion())
      .diffs(asAeroGearDiffs(diffs))
      .build();
}
origin: org.jboss.aerogear/sync-diffmatchpatch-core

/**
 * Find the differences between two texts.
 *
 * @param text1      Old string to be diffed.
 * @param text2      New string to be diffed.
 * @param checklines Speedup flag.  If false, then don't run a
 *                   line-level diff first to identify the changed areas.
 *                   If true, then run a faster slightly less optimal diff.
 * @return Linked List of Diff objects.
 */
public LinkedList<Diff> diffMain(String text1, String text2, boolean checklines) {
  // Set a deadline by which time the diff must be complete.
  long deadline;
  if (diffTimeout <= 0) {
    deadline = Long.MAX_VALUE;
  } else {
    deadline = System.currentTimeMillis() + (long) (diffTimeout * 1000);
  }
  return diffMain(text1, text2, checklines, deadline);
}
origin: org.jboss.aerogear/sync-diffmatchpatch-server

private LinkedList<Patch> patchesFrom(final DiffMatchPatchEdit edit) {
  return diffMatchPatch.patchMake(asDiffUtilDiffs(edit.diff().diffs()));
}
origin: org.jboss.aerogear/sync-diffmatchpatch-core

/**
 * Given the location of the 'middle snake', split the diff in two parts
 * and recurse.
 *
 * @param text1    Old string to be diffed.
 * @param text2    New string to be diffed.
 * @param x        Index of split point in text1.
 * @param y        Index of split point in text2.
 * @param deadline Time at which to bail if not yet complete.
 * @return LinkedList of Diff objects.
 */
private LinkedList<Diff> diffBisectSplit(String text1, String text2, int x, int y, long deadline) {
  String text1a = text1.substring(0, x);
  String text2a = text2.substring(0, y);
  String text1b = text1.substring(x);
  String text2b = text2.substring(y);
  // Compute both diffs serially.
  LinkedList<Diff> diffs = diffMain(text1a, text2a, false, deadline);
  LinkedList<Diff> diffsb = diffMain(text1b, text2b, false, deadline);
  diffs.addAll(diffsb);
  return diffs;
}
org.jboss.aerogear.sync.diffmatchpatchDiffMatchPatch

Javadoc

This class was taken from https://code.google.com/p/java-diff-utils/source/checkout and slightly modified to follow some java coding styles.

Most used methods

  • diffMain
    Find the differences between two texts. Simplifies the problem by stripping any common prefix or suf
  • patchMake
    Compute a list of patches to turn text1 into text2. text1 will be derived from the provided diffs.
  • <init>
  • builder
  • checksum
  • diff
  • diffBisect
    Find the 'middle snake' of a diff, split the problem in two and return the recursively constructed d
  • diffBisectSplit
    Given the location of the 'middle snake', split the diff in two parts and recurse.
  • diffCharsToLines
    Rehydrate the text in a diff from a string of line hashes to real lines of text.
  • diffCleanupEfficiency
    Reduce the number of edits by eliminating operationally trivial equalities.
  • diffCleanupMerge
    Reorder and merge like edit sections. Merge equalities. Any edit section can move as long as it does
  • diffCleanupSemanticLossLess
    Look for single edits surrounded on both sides by equalities which can be shifted sideways to align
  • diffCleanupMerge,
  • diffCleanupSemanticLossLess,
  • diffCleanupSemanticScore,
  • diffCommonOverlap,
  • diffCommonPrefix,
  • diffCommonSuffix,
  • diffCompute,
  • diffHalfMatch,
  • diffLevenshtein,
  • diffLineMode

Popular in Java

  • Reading from database using SQL prepared statement
  • notifyDataSetChanged (ArrayAdapter)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • orElseThrow (Optional)
  • GridBagLayout (java.awt)
    The GridBagLayout class is a flexible layout manager that aligns components vertically and horizonta
  • FileNotFoundException (java.io)
    Thrown when a file specified by a program cannot be found.
  • ByteBuffer (java.nio)
    A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate(i
  • Date (java.util)
    A specific moment in time, with millisecond precision. Values typically come from System#currentTime
  • JTable (javax.swing)
  • DateTimeFormat (org.joda.time.format)
    Factory that creates instances of DateTimeFormatter from patterns and styles. Datetime formatting i
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now