Class SVNPatchHunk


  • public class SVNPatchHunk
    extends java.lang.Object
    A single hunk inside a patch.
    Version:
    1.3
    • Field Detail

      • COMPARATOR

        public static final java.util.Comparator COMPARATOR
        Compare function for sorting hunks after parsing. We sort hunks by their original line offset.
      • original_line_filter

        private static final SVNPatchFileStream.SVNPatchFileLineFilter original_line_filter
        A stream line-filter which allows only original text from a hunk, and filters special lines (which start with a backslash).
      • modified_line_filter

        private static final SVNPatchFileStream.SVNPatchFileLineFilter modified_line_filter
        A stream line-filter which allows only modified text from a hunk, and filters special lines (which start with a backslash).
      • diffText

        private SVNPatchFileStream diffText
        The hunk's unidiff text as it appeared in the patch file, without range information.
      • originalText

        private SVNPatchFileStream originalText
        The original and modified texts in the hunk range. Derived from the diff text. For example, consider a hunk such as:
      • leadingContext

        private long leadingContext
        Number of lines starting with ' ' before first '+' or '-'.
      • trailingContext

        private long trailingContext
        Number of lines starting with ' ' after last '+' or '-'.
    • Constructor Detail

      • SVNPatchHunk

        public SVNPatchHunk()
    • Method Detail

      • getLeadingContext

        public long getLeadingContext()
      • getTrailingContext

        public long getTrailingContext()
      • close

        public void close()
                   throws java.io.IOException
        Throws:
        java.io.IOException
      • parseNextHunk

        public static SVNPatchHunk parseNextHunk​(SVNPatch patch)
                                          throws java.io.IOException,
                                                 SVNException
        Return the next HUNK from a PATCH, using STREAM to read data from the patch file. If no hunk can be found, set HUNK to NULL.
        Throws:
        java.io.IOException
        SVNException
      • getChar

        private static char getChar​(java.lang.String line,
                                    int i)
      • parseHunkHeader

        private static boolean parseHunkHeader​(java.lang.String header,
                                               SVNPatchHunk hunk)
        Try to parse a hunk header in string HEADER, putting parsed information into HUNK. Return TRUE if the header parsed correctly.
      • parseRange

        private static boolean parseRange​(SVNPatchHunk.SVNPatchHunkRange hunkRange,
                                          java.lang.StringBuffer range)
        Try to parse a hunk range specification from the string RANGE. Return parsed information in START and LENGTH, and return TRUE if the range parsed correctly. Note: This function may modify the input value RANGE.
      • parseOffset

        private static java.lang.Integer parseOffset​(java.lang.String number)
        Try to parse a positive number from a decimal number encoded in the string NUMBER. Return parsed number in OFFSET, and return TRUE if parsing was successful.