Class SVNPatchHunk
- java.lang.Object
-
- org.tmatesoft.svn.core.internal.wc.patch.SVNPatchHunk
-
public class SVNPatchHunk extends java.lang.ObjectA single hunk inside a patch.- Version:
- 1.3
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSVNPatchHunk.SVNPatchHunkRange
-
Field Summary
Fields Modifier and Type Field Description static java.util.ComparatorCOMPARATORCompare function for sorting hunks after parsing.private SVNPatchFileStreamdiffTextThe hunk's unidiff text as it appeared in the patch file, without range information.private longleadingContextNumber of lines starting with ' ' before first '+' or '-'.private SVNPatchHunk.SVNPatchHunkRangemodifiedprivate static SVNPatchFileStream.SVNPatchFileLineFiltermodified_line_filterA stream line-filter which allows only modified text from a hunk, and filters special lines (which start with a backslash).private SVNPatchFileStreammodifiedTextprivate SVNPatchHunk.SVNPatchHunkRangeoriginalHunk ranges as they appeared in the patch file.private static SVNPatchFileStream.SVNPatchFileLineFilteroriginal_line_filterA stream line-filter which allows only original text from a hunk, and filters special lines (which start with a backslash).private SVNPatchFileStreamoriginalTextThe original and modified texts in the hunk range.private static SVNPatchFileStream.SVNPatchFileLineTransformerremove_leading_char_transformerLine-transformer callback to shave leading diff symbols.private longtrailingContextNumber 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 voidclose()private static chargetChar(java.lang.String line, int i)SVNPatchFileStreamgetDiffText()longgetLeadingContext()SVNPatchHunk.SVNPatchHunkRangegetModified()SVNPatchFileStreamgetModifiedText()SVNPatchHunk.SVNPatchHunkRangegetOriginal()SVNPatchFileStreamgetOriginalText()longgetTrailingContext()private static booleanparseHunkHeader(java.lang.String header, SVNPatchHunk hunk)Try to parse a hunk header in string HEADER, putting parsed information into HUNK.static SVNPatchHunkparseNextHunk(SVNPatch patch)Return the next HUNK from a PATCH, using STREAM to read data from the patch file.private static java.lang.IntegerparseOffset(java.lang.String number)Try to parse a positive number from a decimal number encoded in the string NUMBER.private static booleanparseRange(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.IOExceptionSVNException
-
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.
-
-