java.lang.Object
org.eclipse.jgit.diff.DiffEntry
org.eclipse.jgit.patch.FileHeader
- Direct Known Subclasses:
CombinedFileHeader
Patch header describing an action for a single file path.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
Type of patch used by this file.Nested classes/interfaces inherited from class org.eclipse.jgit.diff.DiffEntry
DiffEntry.ChangeType, DiffEntry.Side
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionFileHeader
(byte[] headerLines, EditList edits, FileHeader.PatchType type) Constructs a new FileHeader -
Method Summary
Modifier and TypeMethodDescriptionbyte[]
Get the byte array holding this file's patch script.int
Get offset one past the end of the file script.Get the new-image delta/literal if this is aFileHeader.PatchType.GIT_BINARY
.List<? extends HunkHeader>
getHunks()
Get hunks altering this file; in order of appearance in patchGet style of patch used to modify this file.Get the old-image delta/literal if this is aFileHeader.PatchType.GIT_BINARY
.Convert the patch script for this file into a string.getScriptText
(Charset oldCharset, Charset newCharset) Convert the patch script for this file into a string.int
Get offset of the start of this file's script ingetBuffer()
.boolean
Whether this patch modifies metadata about a fileConvert to a list describing the content edits performed on this file.Methods inherited from class org.eclipse.jgit.diff.DiffEntry
getChangeType, getDiffAttribute, getId, getMode, getNewId, getNewMode, getNewPath, getOldId, getOldMode, getOldPath, getPath, getScore, getTreeFilterMarks, isMarked, scan, scan, scan, toString
-
Constructor Details
-
FileHeader
Constructs a new FileHeader- Parameters:
headerLines
- buffer holding the diff header for this fileedits
- the edits for this filetype
- the type of patch used to modify this file
-
-
Method Details
-
getBuffer
public byte[] getBuffer()Get the byte array holding this file's patch script.- Returns:
- the byte array holding this file's patch script.
-
getStartOffset
public int getStartOffset()Get offset of the start of this file's script ingetBuffer()
.- Returns:
- offset of the start of this file's script in
getBuffer()
.
-
getEndOffset
public int getEndOffset()Get offset one past the end of the file script.- Returns:
- offset one past the end of the file script.
-
getScriptText
Convert the patch script for this file into a string.The default character encoding (
StandardCharsets.UTF_8
) is assumed for both the old and new files.- Returns:
- the patch script, as a Unicode string.
-
getScriptText
Convert the patch script for this file into a string.- Parameters:
oldCharset
- hint character set to decode the old lines with.newCharset
- hint character set to decode the new lines with.- Returns:
- the patch script, as a Unicode string.
-
getPatchType
Get style of patch used to modify this file.- Returns:
- style of patch used to modify this file.
-
hasMetaDataChanges
public boolean hasMetaDataChanges()Whether this patch modifies metadata about a file- Returns:
true
if this patch modifies metadata about a file .
-
getHunks
Get hunks altering this file; in order of appearance in patch- Returns:
- hunks altering this file; in order of appearance in patch.
-
getForwardBinaryHunk
Get the new-image delta/literal if this is aFileHeader.PatchType.GIT_BINARY
.- Returns:
- the new-image delta/literal if this is a
FileHeader.PatchType.GIT_BINARY
.
-
getReverseBinaryHunk
Get the old-image delta/literal if this is aFileHeader.PatchType.GIT_BINARY
.- Returns:
- the old-image delta/literal if this is a
FileHeader.PatchType.GIT_BINARY
.
-
toEditList
Convert to a list describing the content edits performed on this file.- Returns:
- a list describing the content edits performed on this file.
-