Class DiffMatch

java.lang.Object
com.logicaldoc.comparison.basic.DiffMatch

public class DiffMatch extends Object
Class containing the diff, match and patch methods. Also contains the behaviour settings.
  • Constructor Details

    • DiffMatch

      public DiffMatch()
  • Method Details

    • diffMain

      public List<DiffMatch.Diff> diffMain(String text1, String text2)
      Find the differences between two texts. Run a faster, slightly less optimal diff. This method allows the 'checklines' of diff_main() to be optional. Most of the time checklines is wanted, so default to true.
      Parameters:
      text1 - Old string to be diffed.
      text2 - New string to be diffed.
      Returns:
      Linked List of Diff objects.
    • diffMain

      public List<DiffMatch.Diff> diffMain(String text1, String text2, boolean checklines)
      Find the differences between two texts.
      Parameters:
      text1 - Old string to be diffed.
      text2 - New string to be diffed.
      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.
      Returns:
      Linked List of Diff objects.
    • diffCommonPrefix

      public int diffCommonPrefix(String text1, String text2)
      Determine the common prefix of two strings
      Parameters:
      text1 - First string.
      text2 - Second string.
      Returns:
      The number of characters common to the start of each string.
    • diffCommonSuffix

      public int diffCommonSuffix(String text1, String text2)
      Determine the common suffix of two strings
      Parameters:
      text1 - First string.
      text2 - Second string.
      Returns:
      The number of characters common to the end of each string.
    • diffPrettyHtml

      public String diffPrettyHtml(List<DiffMatch.Diff> diffs)
      Convert a Diff list into a pretty HTML report.
      Parameters:
      diffs - LinkedList of Diff objects.
      Returns:
      HTML representation.
    • matchMain

      public int matchMain(String text, String pattern, int loc)
      Locate the best instance of 'pattern' in 'text' near 'loc'. Returns -1 if no match found.
      Parameters:
      text - The text to search.
      pattern - The pattern to search for.
      loc - The location to search around.
      Returns:
      Best match index or -1.