Package com.github.difflib.text
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 exampleDiffRowGenerator generator = new DiffRowGenerator.Builder().showInlineDiffs(true). ignoreWhiteSpaces(true).columnWidth(100).build();
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDiffRowGenerator.BuilderThis class used for building the DiffRowGenerator.
-
Field Summary
Fields Modifier and Type Field Description static BiPredicate<String,String>DEFAULT_EQUALIZERstatic BiPredicate<String,String>IGNORE_WHITESPACE_EQUALIZERstatic Function<String,String>LINE_NORMALIZER_FOR_HTMLstatic PatternSPLIT_BY_WORD_PATTERNstatic Function<String,List<String>>SPLITTER_BY_CHARACTERSplitting lines by character to achieve char by char diff checking.static Function<String,List<String>>SPLITTER_BY_WORDSplitting lines by word to achieve word by word diff checking.static PatternWHITESPACE_PATTERN
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static DiffRowGenerator.Buildercreate()List<DiffRow>generateDiffRows(List<String> original, Patch<String> patch)Generates the DiffRows describing the difference between original and revised texts using the given patch.List<DiffRow>generateDiffRows(List<String> original, List<String> revised)Get the DiffRows describing the difference between original and revised texts using the given patch.protected static List<String>splitStringPreserveDelimiter(String str, Pattern SPLIT_PATTERN)
-
-
-
Field Detail
-
DEFAULT_EQUALIZER
public static final BiPredicate<String,String> DEFAULT_EQUALIZER
-
IGNORE_WHITESPACE_EQUALIZER
public static final BiPredicate<String,String> IGNORE_WHITESPACE_EQUALIZER
-
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
-
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 textrevised- 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 textpatch- the given patch- Returns:
- the DiffRows between original and revised texts
-
-