Top Description Inners Fields Constructors Methods
org.eclipse.jgit.patch

public Class HunkHeader

extends Object
Class Inheritance
Known Direct Subclasses
org.eclipse.jgit.patch.CombinedHunkHeader
Static Imports
org.eclipse.jgit.util.RawParseUtils.match, .RawParseUtils.nextLF, .RawParseUtils.parseBase10

Hunk header describing the layout of a single block of lines

Nested and Inner Type Summary

Modifier and TypeClass and Description
public abstract static class
HunkHeader.OldImage

Details about an old image of the file.

Field Summary

Modifier and TypeField and Description
private EditList
pack-priv int
endOffset

Position 1 past the end of this hunk within file's buf.

pack-priv final FileHeader
pack-priv int
nContext

Total number of lines of context appearing in this hunk

pack-priv int
newLineCount

Total number of post-image lines this hunk covers (context + inserted)

pack-priv int
newStartLine

First line number in the post-image file where the hunk starts

private final HunkHeader.OldImage
pack-priv final int
startOffset

Offset within file.buf to the "@@ -" line.

Constructor Summary

AccessConstructor and Description
pack-priv
HunkHeader(FileHeader fh, int offset)

pack-priv
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv void
copyLine(final StringBuilder sb, final String[] text, final int[] offsets, final int fileIdx)

pack-priv void
pack-priv void
extractFileLines(final StringBuilder sb, final String[] text, final int[] offsets)

public byte[]

Returns:

the byte array holding this hunk's patch script.
getBuffer
()

Get the byte array holding this hunk's patch script.

public int

Returns:

offset one past the end of the hunk in getBuffer().
getEndOffset
()

Get offset one past the end of the hunk in getBuffer().

public FileHeader

Returns:

header for the file this hunk applies to.
getFileHeader
()

Get header for the file this hunk applies to.

public int

Returns:

total number of lines of context appearing in this hunk.
getLinesContext
()

Get total number of lines of context appearing in this hunk.

public int

Returns:

total number of post-image lines this hunk covers.
getNewLineCount
()

Get total number of post-image lines this hunk covers.

public int

Returns:

first line number in the post-image file where the hunk starts.
getNewStartLine
()

Get first line number in the post-image file where the hunk starts.

public HunkHeader.OldImage

Returns:

information about the old image mentioned in this hunk.
getOldImage
()

Get information about the old image mentioned in this hunk.

public int

Returns:

offset of the start of this hunk in getBuffer().
getStartOffset
()

Get offset of the start of this hunk in getBuffer().

pack-priv int
parseBody(Patch script, int end)

pack-priv void
pack-priv void
skipLine(final String[] text, final int[] offsets, final int fileIdx)

public EditList

Returns:

a list describing the content edits performed within the hunk.
toEditList
()

Convert to a list describing the content edits performed within the hunk.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

editListback to summary
private EditList editList
endOffsetback to summary
pack-priv int endOffset

Position 1 past the end of this hunk within file's buf.

fileback to summary
pack-priv final FileHeader file
nContextback to summary
pack-priv int nContext

Total number of lines of context appearing in this hunk

newLineCountback to summary
pack-priv int newLineCount

Total number of post-image lines this hunk covers (context + inserted)

newStartLineback to summary
pack-priv int newStartLine

First line number in the post-image file where the hunk starts

oldback to summary
private final HunkHeader.OldImage old
startOffsetback to summary
pack-priv final int startOffset

Offset within file.buf to the "@@ -" line.

Constructor Detail

HunkHeaderback to summary
pack-priv HunkHeader(FileHeader fh, int offset)
HunkHeaderback to summary
pack-priv HunkHeader(FileHeader fh, int offset, HunkHeader.OldImage oi)
HunkHeaderback to summary
pack-priv HunkHeader(FileHeader fh, EditList editList)

Method Detail

copyLineback to summary
pack-priv void copyLine(final StringBuilder sb, final String[] text, final int[] offsets, final int fileIdx)
extractFileLinesback to summary
pack-priv void extractFileLines(OutputStream[] out) throws IOException
extractFileLinesback to summary
pack-priv void extractFileLines(final StringBuilder sb, final String[] text, final int[] offsets)
getBufferback to summary
public byte[] getBuffer()

Get the byte array holding this hunk's patch script.

Returns:byte[]

the byte array holding this hunk's patch script.

getEndOffsetback to summary
public int getEndOffset()

Get offset one past the end of the hunk in getBuffer().

Returns:int

offset one past the end of the hunk in getBuffer().

getFileHeaderback to summary
public FileHeader getFileHeader()

Get header for the file this hunk applies to.

Returns:FileHeader

header for the file this hunk applies to.

getLinesContextback to summary
public int getLinesContext()

Get total number of lines of context appearing in this hunk.

Returns:int

total number of lines of context appearing in this hunk.

getNewLineCountback to summary
public int getNewLineCount()

Get total number of post-image lines this hunk covers.

Returns:int

total number of post-image lines this hunk covers.

getNewStartLineback to summary
public int getNewStartLine()

Get first line number in the post-image file where the hunk starts.

Returns:int

first line number in the post-image file where the hunk starts.

getOldImageback to summary
public HunkHeader.OldImage getOldImage()

Get information about the old image mentioned in this hunk.

Returns:HunkHeader.OldImage

information about the old image mentioned in this hunk.

getStartOffsetback to summary
public int getStartOffset()

Get offset of the start of this hunk in getBuffer().

Returns:int

offset of the start of this hunk in getBuffer().

parseBodyback to summary
pack-priv int parseBody(Patch script, int end)
parseHeaderback to summary
pack-priv void parseHeader()
skipLineback to summary
pack-priv void skipLine(final String[] text, final int[] offsets, final int fileIdx)
toEditListback to summary
public EditList toEditList()

Convert to a list describing the content edits performed within the hunk.

Returns:EditList

a list describing the content edits performed within the hunk.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@SuppressWarnings:nls
@Override
org.eclipse.jgit.patch back to summary

public abstract Class HunkHeader.OldImage

extends Object
Class Inheritance
Known Direct Subclasses
org.eclipse.jgit.patch.CombinedHunkHeader.CombinedOldImage

Details about an old image of the file.

Field Summary

Modifier and TypeField and Description
pack-priv int
lineCount

Total number of lines this hunk covers in this file.

pack-priv int
nAdded

Number of lines added by the post-image not in this file.

pack-priv int
nDeleted

Number of lines deleted by the post-image from this file.

pack-priv int
startLine

First line number the hunk starts on in this file.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public abstract AbbreviatedObjectId

Returns:

object id of the pre-image file.
getId
()

Get id of the pre-image file

public int

Returns:

total number of lines this hunk covers in this file.
getLineCount
()

Get number of lines this hunk covers

public int

Returns:

number of lines added by the post-image not in this file.
getLinesAdded
()

Get number of lines added by the post-image

public int

Returns:

number of lines deleted by the post-image from this file.
getLinesDeleted
()

Get number of lines deleted by the post-image

public int

Returns:

first line number the hunk starts on in this file.
getStartLine
()

Get line number where hunk starts

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

lineCountback to summary
pack-priv int lineCount

Total number of lines this hunk covers in this file.

nAddedback to summary
pack-priv int nAdded

Number of lines added by the post-image not in this file.

nDeletedback to summary
pack-priv int nDeleted

Number of lines deleted by the post-image from this file.

startLineback to summary
pack-priv int startLine

First line number the hunk starts on in this file.

Constructor Detail

OldImageback to summary
public OldImage()

Method Detail

getIdback to summary
public abstract AbbreviatedObjectId getId()

Get id of the pre-image file

Returns:AbbreviatedObjectId

object id of the pre-image file.

getLineCountback to summary
public int getLineCount()

Get number of lines this hunk covers

Returns:int

total number of lines this hunk covers in this file.

getLinesAddedback to summary
public int getLinesAdded()

Get number of lines added by the post-image

Returns:int

number of lines added by the post-image not in this file.

getLinesDeletedback to summary
public int getLinesDeleted()

Get number of lines deleted by the post-image

Returns:int

number of lines deleted by the post-image from this file.

getStartLineback to summary
public int getStartLine()

Get line number where hunk starts

Returns:int

first line number the hunk starts on in this file.