Class 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 Detail

      • 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 Detail

      • 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