Package org.eclipse.jgit.patch
Class HunkHeader
- java.lang.Object
-
- org.eclipse.jgit.patch.HunkHeader
-
- Direct Known Subclasses:
CombinedHunkHeader
public class HunkHeader extends java.lang.Object
Hunk header describing the layout of a single block of lines
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
HunkHeader.OldImage
Details about an old image of the file.
-
Field Summary
Fields Modifier and Type Field Description private EditList
editList
(package private) int
endOffset
Position 1 past the end of this hunk withinfile
's buf.(package private) FileHeader
file
(package private) int
nContext
Total number of lines of context appearing in this hunk(package private) int
newLineCount
Total number of post-image lines this hunk covers (context + inserted)(package private) int
newStartLine
First line number in the post-image file where the hunk startsprivate HunkHeader.OldImage
old
(package private) int
startOffset
Offset withinfile
.buf to the "@@ -" line.
-
Constructor Summary
Constructors Constructor Description HunkHeader(FileHeader fh, int offset)
HunkHeader(FileHeader fh, int offset, HunkHeader.OldImage oi)
HunkHeader(FileHeader fh, EditList editList)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) void
copyLine(java.lang.StringBuilder sb, java.lang.String[] text, int[] offsets, int fileIdx)
(package private) void
extractFileLines(java.io.OutputStream[] out)
(package private) void
extractFileLines(java.lang.StringBuilder sb, java.lang.String[] text, int[] offsets)
byte[]
getBuffer()
Get the byte array holding this hunk's patch script.int
getEndOffset()
Get offset one past the end of the hunk ingetBuffer()
.FileHeader
getFileHeader()
Get header for the file this hunk applies to.int
getLinesContext()
Get total number of lines of context appearing in this hunk.int
getNewLineCount()
Get total number of post-image lines this hunk covers.int
getNewStartLine()
Get first line number in the post-image file where the hunk starts.HunkHeader.OldImage
getOldImage()
Get information about the old image mentioned in this hunk.int
getStartOffset()
Get offset of the start of this hunk ingetBuffer()
.(package private) int
parseBody(Patch script, int end)
(package private) void
parseHeader()
(package private) void
skipLine(java.lang.String[] text, int[] offsets, int fileIdx)
EditList
toEditList()
Convert to a list describing the content edits performed within the hunk.java.lang.String
toString()
-
-
-
Field Detail
-
file
final FileHeader file
-
startOffset
final int startOffset
Offset withinfile
.buf to the "@@ -" line.
-
endOffset
int endOffset
Position 1 past the end of this hunk withinfile
's buf.
-
old
private final HunkHeader.OldImage old
-
newStartLine
int newStartLine
First line number in the post-image file where the hunk starts
-
newLineCount
int newLineCount
Total number of post-image lines this hunk covers (context + inserted)
-
nContext
int nContext
Total number of lines of context appearing in this hunk
-
editList
private EditList editList
-
-
Constructor Detail
-
HunkHeader
HunkHeader(FileHeader fh, int offset)
-
HunkHeader
HunkHeader(FileHeader fh, int offset, HunkHeader.OldImage oi)
-
HunkHeader
HunkHeader(FileHeader fh, EditList editList)
-
-
Method Detail
-
getFileHeader
public FileHeader getFileHeader()
Get header for the file this hunk applies to.- Returns:
- header for the file this hunk applies to.
-
getBuffer
public byte[] getBuffer()
Get the byte array holding this hunk's patch script.- Returns:
- the byte array holding this hunk's patch script.
-
getStartOffset
public int getStartOffset()
Get offset of the start of this hunk ingetBuffer()
.- Returns:
- offset of the start of this hunk in
getBuffer()
.
-
getEndOffset
public int getEndOffset()
Get offset one past the end of the hunk ingetBuffer()
.- Returns:
- offset one past the end of the hunk in
getBuffer()
.
-
getOldImage
public HunkHeader.OldImage getOldImage()
Get information about the old image mentioned in this hunk.- Returns:
- information about the old image mentioned in this hunk.
-
getNewStartLine
public int getNewStartLine()
Get first line number in the post-image file where the hunk starts.- Returns:
- first line number in the post-image file where the hunk starts.
-
getNewLineCount
public int getNewLineCount()
Get total number of post-image lines this hunk covers.- Returns:
- total number of post-image lines this hunk covers.
-
getLinesContext
public int getLinesContext()
Get total number of lines of context appearing in this hunk.- Returns:
- total number of lines of context appearing in this hunk.
-
toEditList
public EditList toEditList()
Convert to a list describing the content edits performed within the hunk.- Returns:
- a list describing the content edits performed within the hunk.
-
parseHeader
void parseHeader()
-
parseBody
int parseBody(Patch script, int end)
-
extractFileLines
void extractFileLines(java.io.OutputStream[] out) throws java.io.IOException
- Throws:
java.io.IOException
-
extractFileLines
void extractFileLines(java.lang.StringBuilder sb, java.lang.String[] text, int[] offsets)
-
copyLine
void copyLine(java.lang.StringBuilder sb, java.lang.String[] text, int[] offsets, int fileIdx)
-
skipLine
void skipLine(java.lang.String[] text, int[] offsets, int fileIdx)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-