org.eclipse.jgit.patch
Class FileHeader

java.lang.Object
  extended by org.eclipse.jgit.diff.DiffEntry
      extended by org.eclipse.jgit.patch.FileHeader
Direct Known Subclasses:
CombinedFileHeader

public class FileHeader
extends DiffEntry

Patch header describing an action for a single file path.


Nested Class Summary
static class FileHeader.PatchType
          Type of patch used by this file.
 
Nested classes/interfaces inherited from class org.eclipse.jgit.diff.DiffEntry
DiffEntry.ChangeType, DiffEntry.Side
 
Field Summary
 
Fields inherited from class org.eclipse.jgit.diff.DiffEntry
changeType, DEV_NULL, newId, newMode, newPath, oldId, oldMode, oldPath, score
 
Constructor Summary
FileHeader(byte[] headerLines, EditList edits, FileHeader.PatchType type)
          Constructs a new FileHeader
 
Method Summary
 byte[] getBuffer()
           
 int getEndOffset()
           
 BinaryHunk getForwardBinaryHunk()
           
 List<? extends HunkHeader> getHunks()
           
 FileHeader.PatchType getPatchType()
           
 BinaryHunk getReverseBinaryHunk()
           
 String getScriptText()
          Convert the patch script for this file into a string.
 String getScriptText(Charset oldCharset, Charset newCharset)
          Convert the patch script for this file into a string.
 int getStartOffset()
           
 boolean hasMetaDataChanges()
           
 EditList toEditList()
           
 
Methods inherited from class org.eclipse.jgit.diff.DiffEntry
getChangeType, getId, getMode, getNewId, getNewMode, getNewPath, getOldId, getOldMode, getOldPath, getPath, getScore, getTreeFilterMarks, isMarked, scan, scan, scan, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FileHeader

public FileHeader(byte[] headerLines,
                  EditList edits,
                  FileHeader.PatchType type)
Constructs a new FileHeader

Parameters:
headerLines - buffer holding the diff header for this file
edits - the edits for this file
type - the type of patch used to modify this file
Method Detail

getBuffer

public byte[] getBuffer()
Returns:
the byte array holding this file's patch script.

getStartOffset

public int getStartOffset()
Returns:
offset the start of this file's script in getBuffer().

getEndOffset

public int getEndOffset()
Returns:
offset one past the end of the file script.

getScriptText

public String getScriptText()
Convert the patch script for this file into a string.

The default character encoding (Constants.CHARSET) is assumed for both the old and new files.

Returns:
the patch script, as a Unicode string.

getScriptText

public String getScriptText(Charset oldCharset,
                            Charset newCharset)
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

public FileHeader.PatchType getPatchType()
Returns:
style of patch used to modify this file

hasMetaDataChanges

public boolean hasMetaDataChanges()
Returns:
true if this patch modifies metadata about a file

getHunks

public List<? extends HunkHeader> getHunks()
Returns:
hunks altering this file; in order of appearance in patch

getForwardBinaryHunk

public BinaryHunk getForwardBinaryHunk()
Returns:
if a FileHeader.PatchType.GIT_BINARY, the new-image delta/literal

getReverseBinaryHunk

public BinaryHunk getReverseBinaryHunk()
Returns:
if a FileHeader.PatchType.GIT_BINARY, the old-image delta/literal

toEditList

public EditList toEditList()
Returns:
a list describing the content edits performed on this file.


Copyright © 2013. All Rights Reserved.