org.eclipse.jgit.patch
Class FileHeader

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

public class FileHeader
extends java.lang.Object

Patch header describing an action for a single file path.


Nested Class Summary
static class FileHeader.ChangeType
          General type of change a single file-level patch describes.
static class FileHeader.PatchType
          Type of patch used by this file.
 
Field Summary
protected  FileHeader.ChangeType changeType
          General type of change indicated by the patch.
static java.lang.String DEV_NULL
          Magical file name used for file adds or deletes.
protected  AbbreviatedObjectId newId
          ObjectId listed on the index line for the new (post-image)
protected  FileMode newMode
          New mode of the file, if described by the patch, else null.
 
Method Summary
 byte[] getBuffer()
           
 FileHeader.ChangeType getChangeType()
           
 int getEndOffset()
           
 BinaryHunk getForwardBinaryHunk()
           
 java.util.List<? extends HunkHeader> getHunks()
           
 AbbreviatedObjectId getNewId()
          Get the new object id from the index.
 FileMode getNewMode()
           
 java.lang.String getNewName()
          Get the new name associated with this file.
 AbbreviatedObjectId getOldId()
          Get the old object id from the index.
 FileMode getOldMode()
           
 java.lang.String getOldName()
          Get the old name associated with this file.
 FileHeader.PatchType getPatchType()
           
 BinaryHunk getReverseBinaryHunk()
           
 int getScore()
           
 java.lang.String getScriptText()
          Convert the patch script for this file into a string.
 java.lang.String getScriptText(java.nio.charset.Charset oldCharset, java.nio.charset.Charset newCharset)
          Convert the patch script for this file into a string.
 int getStartOffset()
           
 boolean hasMetaDataChanges()
           
 EditList toEditList()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEV_NULL

public static final java.lang.String DEV_NULL
Magical file name used for file adds or deletes.

See Also:
Constant Field Values

newMode

protected FileMode newMode
New mode of the file, if described by the patch, else null.


changeType

protected FileHeader.ChangeType changeType
General type of change indicated by the patch.


newId

protected AbbreviatedObjectId newId
ObjectId listed on the index line for the new (post-image)

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 java.lang.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 java.lang.String getScriptText(java.nio.charset.Charset oldCharset,
                                      java.nio.charset.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.

getOldName

public java.lang.String getOldName()
Get the old name associated with this file.

The meaning of the old name can differ depending on the semantic meaning of this patch:

Returns:
old name for this file.

getNewName

public java.lang.String getNewName()
Get the new name associated with this file.

The meaning of the new name can differ depending on the semantic meaning of this patch:

Returns:
new name for this file.

getOldMode

public FileMode getOldMode()
Returns:
the old file mode, if described in the patch

getNewMode

public FileMode getNewMode()
Returns:
the new file mode, if described in the patch

getChangeType

public FileHeader.ChangeType getChangeType()
Returns:
the type of change this patch makes on getNewName()

getScore

public int getScore()
Returns:
similarity score between getOldName() and getNewName() if getChangeType() is FileHeader.ChangeType.COPY or FileHeader.ChangeType.RENAME.

getOldId

public AbbreviatedObjectId getOldId()
Get the old object id from the index.

Returns:
the object id; null if there is no index line

getNewId

public AbbreviatedObjectId getNewId()
Get the new object id from the index.

Returns:
the object id; null if there is no index line

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 java.util.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.