Class SVNPatchHunk
- java.lang.Object
-
- org.tmatesoft.svn.core.internal.wc.patch.SVNPatchHunk
-
public class SVNPatchHunk extends java.lang.Object
A single hunk inside a patch.- Version:
- 1.3
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SVNPatchHunk.SVNPatchHunkRange
-
Field Summary
Fields Modifier and Type Field Description static java.util.Comparator
COMPARATOR
Compare function for sorting hunks after parsing.private SVNPatchFileStream
diffText
The hunk's unidiff text as it appeared in the patch file, without range information.private long
leadingContext
Number of lines starting with ' ' before first '+' or '-'.private SVNPatchHunk.SVNPatchHunkRange
modified
private static 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).private SVNPatchFileStream
modifiedText
private SVNPatchHunk.SVNPatchHunkRange
original
Hunk ranges as they appeared in the patch file.private static 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).private SVNPatchFileStream
originalText
The original and modified texts in the hunk range.private static SVNPatchFileStream.SVNPatchFileLineTransformer
remove_leading_char_transformer
Line-transformer callback to shave leading diff symbols.private long
trailingContext
Number of lines starting with ' ' after last '+' or '-'.
-
Constructor Summary
Constructors Constructor Description SVNPatchHunk()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
private static char
getChar(java.lang.String line, int i)
SVNPatchFileStream
getDiffText()
long
getLeadingContext()
SVNPatchHunk.SVNPatchHunkRange
getModified()
SVNPatchFileStream
getModifiedText()
SVNPatchHunk.SVNPatchHunkRange
getOriginal()
SVNPatchFileStream
getOriginalText()
long
getTrailingContext()
private static boolean
parseHunkHeader(java.lang.String header, SVNPatchHunk hunk)
Try to parse a hunk header in string HEADER, putting parsed information into HUNK.static SVNPatchHunk
parseNextHunk(SVNPatch patch)
Return the next HUNK from a PATCH, using STREAM to read data from the patch file.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.private static boolean
parseRange(SVNPatchHunk.SVNPatchHunkRange hunkRange, java.lang.StringBuffer range)
Try to parse a hunk range specification from the string RANGE.
-
-
-
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).
-
remove_leading_char_transformer
private static final SVNPatchFileStream.SVNPatchFileLineTransformer remove_leading_char_transformer
Line-transformer callback to shave leading diff symbols.
-
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:
-
modifiedText
private SVNPatchFileStream modifiedText
-
original
private SVNPatchHunk.SVNPatchHunkRange original
Hunk ranges as they appeared in the patch file. All numbers are lines, not bytes.
-
modified
private SVNPatchHunk.SVNPatchHunkRange modified
-
leadingContext
private long leadingContext
Number of lines starting with ' ' before first '+' or '-'.
-
trailingContext
private long trailingContext
Number of lines starting with ' ' after last '+' or '-'.
-
-
Method Detail
-
getDiffText
public SVNPatchFileStream getDiffText()
-
getOriginalText
public SVNPatchFileStream getOriginalText()
-
getModifiedText
public SVNPatchFileStream getModifiedText()
-
getOriginal
public SVNPatchHunk.SVNPatchHunkRange getOriginal()
-
getModified
public SVNPatchHunk.SVNPatchHunkRange getModified()
-
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.
-
-