Class UnifiedDiffUtils


  • public final class UnifiedDiffUtils
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private UnifiedDiffUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.List<java.lang.String> generateUnifiedDiff​(java.lang.String originalFileName, java.lang.String revisedFileName, java.util.List<java.lang.String> originalLines, Patch<java.lang.String> patch, int contextSize)
      generateUnifiedDiff takes a Patch and some other arguments, returning the Unified Diff format text representing the Patch.
      private static java.util.List<java.lang.String> getDeltaText​(AbstractDelta<java.lang.String> delta)
      getDeltaText returns the lines to be added to the Unified Diff text from the Delta parameter.
      static Patch<java.lang.String> parseUnifiedDiff​(java.util.List<java.lang.String> diff)
      Parse the given text in unified format and creates the list of deltas for it.
      private static java.util.List<java.lang.String> processDeltas​(java.util.List<java.lang.String> origLines, java.util.List<AbstractDelta<java.lang.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 void processLinesInPrevChunk​(java.util.List<java.lang.String[]> rawChunk, Patch<java.lang.String> patch, int old_ln, int new_ln)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • UNIFIED_DIFF_CHUNK_REGEXP

        private static final java.util.regex.Pattern UNIFIED_DIFF_CHUNK_REGEXP
      • NULL_FILE_INDICATOR

        private static final java.lang.String NULL_FILE_INDICATOR
        See Also:
        Constant Field Values
    • Constructor Detail

      • UnifiedDiffUtils

        private UnifiedDiffUtils()
    • Method Detail

      • parseUnifiedDiff

        public static Patch<java.lang.String> parseUnifiedDiff​(java.util.List<java.lang.String> diff)
        Parse the given text in unified format and creates the list of deltas for it.
        Parameters:
        diff - the text in unified format
        Returns:
        the patch with deltas.
      • processLinesInPrevChunk

        private static void processLinesInPrevChunk​(java.util.List<java.lang.String[]> rawChunk,
                                                    Patch<java.lang.String> patch,
                                                    int old_ln,
                                                    int new_ln)
      • generateUnifiedDiff

        public static java.util.List<java.lang.String> generateUnifiedDiff​(java.lang.String originalFileName,
                                                                           java.lang.String revisedFileName,
                                                                           java.util.List<java.lang.String> originalLines,
                                                                           Patch<java.lang.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 file
        originalLines - - Lines of the original file
        patch - - Patch created by the diff() function
        contextSize - - 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 java.util.List<java.lang.String> processDeltas​(java.util.List<java.lang.String> origLines,
                                                                      java.util.List<AbstractDelta<java.lang.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 file
        deltas - - the Deltas to be output as a single block
        contextSize - - the number of lines of context to place around block
        Returns:
      • getDeltaText

        private static java.util.List<java.lang.String> getDeltaText​(AbstractDelta<java.lang.String> delta)
        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.