org.eclipse.jgit.diff
Class DiffEntry

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

public class DiffEntry
extends Object

A value class representing a change to a file


Nested Class Summary
static class DiffEntry.ChangeType
          General type of change a single file-level patch describes.
static class DiffEntry.Side
          Specify the old or new side for more generalized access.
 
Field Summary
protected  DiffEntry.ChangeType changeType
          General type of change indicated by the patch.
static 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.
protected  String newPath
          File name of the new (post-image).
protected  AbbreviatedObjectId oldId
          ObjectId listed on the index line for the old (pre-image)
protected  FileMode oldMode
          Old mode of the file, if described by the patch, else null.
protected  String oldPath
          File name of the old (pre-image).
protected  int score
          Similarity score if changeType is a copy or rename.
 
Constructor Summary
protected DiffEntry()
          Create an empty DiffEntry
 
Method Summary
 DiffEntry.ChangeType getChangeType()
           
 AbbreviatedObjectId getId(DiffEntry.Side side)
          Get the object id.
 FileMode getMode(DiffEntry.Side side)
          Get the mode associated with this file.
 AbbreviatedObjectId getNewId()
          Get the new object id from the index.
 FileMode getNewMode()
           
 String getNewPath()
          Get the new name associated with this file.
 AbbreviatedObjectId getOldId()
          Get the old object id from the index.
 FileMode getOldMode()
           
 String getOldPath()
          Get the old name associated with this file.
 String getPath(DiffEntry.Side side)
          Get the path associated with this file.
 int getScore()
           
static List<DiffEntry> scan(TreeWalk walk)
          Convert the TreeWalk into DiffEntry headers.
static List<DiffEntry> scan(TreeWalk walk, boolean includeTrees)
          Convert the TreeWalk into DiffEntry headers, depending on includeTrees it will add tree objects into result or not.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEV_NULL

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

See Also:
Constant Field Values

oldPath

protected String oldPath
File name of the old (pre-image).


newPath

protected String newPath
File name of the new (post-image).


oldMode

protected FileMode oldMode
Old mode of the file, if described by the patch, else null.


newMode

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


changeType

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


score

protected int score
Similarity score if changeType is a copy or rename.


oldId

protected AbbreviatedObjectId oldId
ObjectId listed on the index line for the old (pre-image)


newId

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

Constructor Detail

DiffEntry

protected DiffEntry()
Create an empty DiffEntry

Method Detail

scan

public static List<DiffEntry> scan(TreeWalk walk)
                            throws IOException
Convert the TreeWalk into DiffEntry headers.

Parameters:
walk - the TreeWalk to walk through. Must have exactly two trees.
Returns:
headers describing the changed files.
Throws:
IOException - the repository cannot be accessed.
IllegalArgumentException - When given TreeWalk doesn't have exactly two trees.

scan

public static List<DiffEntry> scan(TreeWalk walk,
                                   boolean includeTrees)
                            throws IOException
Convert the TreeWalk into DiffEntry headers, depending on includeTrees it will add tree objects into result or not.

Parameters:
walk - the TreeWalk to walk through. Must have exactly two trees and when includeTrees parameter is true it can't be recursive.
includeTrees - include tree object's.
Returns:
headers describing the changed files.
Throws:
IOException - the repository cannot be accessed.
IllegalArgumentException - when includeTrees is true and given TreeWalk is recursive. Or when given TreeWalk doesn't have exactly two trees

getOldPath

public String getOldPath()
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.

getNewPath

public String getNewPath()
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.

getPath

public String getPath(DiffEntry.Side side)
Get the path associated with this file.

Parameters:
side - which path to obtain.
Returns:
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

getMode

public FileMode getMode(DiffEntry.Side side)
Get the mode associated with this file.

Parameters:
side - which mode to obtain.
Returns:
the mode.

getChangeType

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

getScore

public int getScore()
Returns:
similarity score between getOldPath() and getNewPath() if getChangeType() is DiffEntry.ChangeType.COPY or DiffEntry.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

getId

public AbbreviatedObjectId getId(DiffEntry.Side side)
Get the object id.

Parameters:
side - the side of the id to get.
Returns:
the object id; null if there is no index line

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2012. All Rights Reserved.