Class UnifiedDiffUtils
java.lang.Object
com.github.difflib.UnifiedDiffUtils
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongenerateOriginalAndDiff(List<String> original, List<String> revised) Compare the differences between two files and return to the original file and diff format (This method compares the original file with the comparison file to obtain a diff, and inserts the diff into the corresponding position of the original file.generateOriginalAndDiff(List<String> original, List<String> revised, String originalFileName, String revisedFileName) Compare the differences between two files and return to the original file and diff format (This method compares the original file with the comparison file to obtain a diff, and inserts the diff into the corresponding position of the original file.generateUnifiedDiff(String originalFileName, String revisedFileName, List<String> originalLines, Patch<String> patch, int contextSize) generateUnifiedDiff takes a Patch and some other arguments, returning the Unified Diff format text representing the Patch.getDeltaText(AbstractDelta<String> delta) getDeltaText returns the lines to be added to the Unified Diff text from the Delta parameter.getOrigList(List<String> originalWithPrefix, int start, int end) private static voidinsertOrig(List<String> original, List<String> unifiedDiff) private static voidparseUnifiedDiff(List<String> diff) Parse the given text in unified format and creates the list of deltas for it.processDeltas(List<String> origLines, List<AbstractDelta<String>> deltas, int contextSize, boolean newFile) processDeltas takes a list of Deltas and outputs them together in a single block of Unified-Diff-format text.private static voidprocessLinesInPrevChunk(List<String[]> rawChunk, Patch<String> patch, int old_ln, int new_ln)
-
Field Details
-
UNIFIED_DIFF_CHUNK_REGEXP
-
NULL_FILE_INDICATOR
- See Also:
-
-
Constructor Details
-
UnifiedDiffUtils
private UnifiedDiffUtils()
-
-
Method Details
-
parseUnifiedDiff
-
processLinesInPrevChunk
-
generateUnifiedDiff
public static List<String> generateUnifiedDiff(String originalFileName, String revisedFileName, List<String> originalLines, Patch<String> patch, int contextSize) generateUnifiedDiff takes a Patch and some other arguments, returning the Unified Diff format text representing the Patch. Author: Bill James (tankerbay@gmail.com).- Parameters:
originalFileName- - Filename of the original (unrevised file)revisedFileName- - Filename of the revised fileoriginalLines- - Lines of the original filepatch- - Patch created by the diff() functioncontextSize- - number of lines of context output around each difference in the file.- Returns:
- List of strings representing the Unified Diff representation of the Patch argument.
-
processDeltas
private static List<String> processDeltas(List<String> origLines, List<AbstractDelta<String>> deltas, int contextSize, boolean newFile) processDeltas takes a list of Deltas and outputs them together in a single block of Unified-Diff-format text. Author: Bill James (tankerbay@gmail.com).- Parameters:
origLines- - the lines of the original filedeltas- - the Deltas to be output as a single blockcontextSize- - the number of lines of context to place around block- Returns:
-
getDeltaText
getDeltaText returns the lines to be added to the Unified Diff text from the Delta parameter. Author: Bill James (tankerbay@gmail.com).- Parameters:
delta- - the Delta to output- Returns:
- list of String lines of code.
-
generateOriginalAndDiff
Compare the differences between two files and return to the original file and diff format (This method compares the original file with the comparison file to obtain a diff, and inserts the diff into the corresponding position of the original file. You can see all the differences and unmodified places from the original file. Also, this will be very easy and useful for making side-by-side comparison display applications, for example, if you use diff2html (https://github.com/rtfpessoa/diff2html#usage) Wait for tools to display your differences on html pages, you only need to insert the return value into your js code)- Parameters:
original- Original file contentrevised- revised file content
-
generateOriginalAndDiff
public static List<String> generateOriginalAndDiff(List<String> original, List<String> revised, String originalFileName, String revisedFileName) Compare the differences between two files and return to the original file and diff format (This method compares the original file with the comparison file to obtain a diff, and inserts the diff into the corresponding position of the original file. You can see all the differences and unmodified places from the original file. Also, this will be very easy and useful for making side-by-side comparison display applications, for example, if you use diff2html (https://github.com/rtfpessoa/diff2html#usage) Wait for tools to display your differences on html pages, you only need to insert the return value into your js code)- Parameters:
original- Original file contentrevised- revised file contentoriginalFileName- Original file namerevisedFileName- revised file name
-
insertOrig
-
insertOrig
-
insert
-
getRowMap
-
getOrigList
-