Class DiffRowGenerator

java.lang.Object
com.github.difflib.text.DiffRowGenerator

public final class DiffRowGenerator extends Object
This class for generating DiffRows for side-by-sidy view. You can customize the way of generating. For example, show inline diffs on not, ignoring white spaces or/and blank lines and so on. All parameters for generating are optional. If you do not specify them, the class will use the default values. These values are: showInlineDiffs = false; ignoreWhiteSpaces = true; ignoreBlankLines = true; ... For instantiating the DiffRowGenerator you should use the its builder. Like in example DiffRowGenerator generator = new DiffRowGenerator.Builder().showInlineDiffs(true). ignoreWhiteSpaces(true).columnWidth(100).build();
  • Field Details

    • DEFAULT_EQUALIZER

      public static final BiPredicate<String,String> DEFAULT_EQUALIZER
    • IGNORE_WHITESPACE_EQUALIZER

      public static final BiPredicate<String,String> IGNORE_WHITESPACE_EQUALIZER
    • LINE_NORMALIZER_FOR_HTML

      public static final Function<String,String> LINE_NORMALIZER_FOR_HTML
    • SPLITTER_BY_CHARACTER

      public static final Function<String, List<String>> SPLITTER_BY_CHARACTER
      Splitting lines by character to achieve char by char diff checking.
    • SPLIT_BY_WORD_PATTERN

      public static final Pattern SPLIT_BY_WORD_PATTERN
    • SPLITTER_BY_WORD

      public static final Function<String, List<String>> SPLITTER_BY_WORD
      Splitting lines by word to achieve word by word diff checking.
    • WHITESPACE_PATTERN

      public static final Pattern WHITESPACE_PATTERN
  • Method Details

    • create

      public static DiffRowGenerator.Builder create()
    • splitStringPreserveDelimiter

      protected static final List<String> splitStringPreserveDelimiter(String str, Pattern SPLIT_PATTERN)
    • generateDiffRows

      public List<DiffRow> generateDiffRows(List<String> original, List<String> revised)
      Get the DiffRows describing the difference between original and revised texts using the given patch. Useful for displaying side-by-side diff.
      Parameters:
      original - the original text
      revised - the revised text
      Returns:
      the DiffRows between original and revised texts
    • generateDiffRows

      public List<DiffRow> generateDiffRows(List<String> original, Patch<String> patch)
      Generates the DiffRows describing the difference between original and revised texts using the given patch. Useful for displaying side-by-side diff.
      Parameters:
      original - the original text
      patch - the given patch
      Returns:
      the DiffRows between original and revised texts