org.gitective.core
Class BlobUtils

java.lang.Object
  extended by org.gitective.core.BlobUtils

public abstract class BlobUtils
extends Object

Utilities for dealing with Git blobs.

This class provides helpers for getting the content and the ids of blobs at different paths and commits.

This class also provides helpers for computing the differences between the content of blobs.


Constructor Summary
BlobUtils()
           
 
Method Summary
static Collection<org.eclipse.jgit.diff.Edit> diff(org.eclipse.jgit.lib.ObjectReader reader, org.eclipse.jgit.lib.ObjectId blob1, org.eclipse.jgit.lib.ObjectId blob2)
          Diff the blobs at the given object ids using the RawTextComparator.DEFAULT comparator.
static Collection<org.eclipse.jgit.diff.Edit> diff(org.eclipse.jgit.lib.ObjectReader reader, org.eclipse.jgit.lib.ObjectId blob1, org.eclipse.jgit.lib.ObjectId blob2, org.eclipse.jgit.diff.RawTextComparator comparator)
          Diff the blobs at the given object ids.
static Collection<org.eclipse.jgit.diff.Edit> diff(org.eclipse.jgit.lib.Repository repository, org.eclipse.jgit.lib.ObjectId blob1, org.eclipse.jgit.lib.ObjectId blob2)
          Diff the blobs at the given object ids using the RawTextComparator.DEFAULT comparator.
static Collection<org.eclipse.jgit.diff.Edit> diff(org.eclipse.jgit.lib.Repository repository, org.eclipse.jgit.lib.ObjectId blob1, org.eclipse.jgit.lib.ObjectId blob2, org.eclipse.jgit.diff.RawTextComparator comparator)
          Diff the blobs at the given object ids.
protected static byte[] getBytes(org.eclipse.jgit.lib.ObjectReader reader, org.eclipse.jgit.lib.ObjectId id)
          Get the contents of the the blob with the given id as a byte array.
protected static byte[] getBytes(org.eclipse.jgit.lib.Repository repository, org.eclipse.jgit.lib.ObjectId id)
          Get the contents of the the blob with the given id as a byte array.
protected static byte[] getBytes(org.eclipse.jgit.lib.Repository repository, org.eclipse.jgit.revwalk.RevCommit commit, String path)
          Get the contents of the the blob in the commit located at the given path as a byte array.
static String getContent(org.eclipse.jgit.lib.Repository repository, org.eclipse.jgit.lib.ObjectId id)
          Get the contents of the the blob with the given id as a UTF-8 String.
static String getContent(org.eclipse.jgit.lib.Repository repository, org.eclipse.jgit.lib.ObjectId commitId, String path)
          Get the contents of the blob in the commit located at the given path.
static String getContent(org.eclipse.jgit.lib.Repository repository, String revision, String path)
          Get the contents of the blob at the given path in the commit that the revision references.
static String getHeadContent(org.eclipse.jgit.lib.Repository repository, String path)
          Get the contents of the blob at the given path in the commit that HEAD references.
static org.eclipse.jgit.lib.ObjectId getHeadId(org.eclipse.jgit.lib.Repository repository, String path)
          Get the id of the blob at the path in the commit that HEAD currently references.
static org.eclipse.jgit.lib.ObjectStream getHeadStream(org.eclipse.jgit.lib.Repository repository, String path)
          Open a stream to the contents of the blob at the path in the commit that HEAD currently references.
static org.eclipse.jgit.lib.ObjectId getId(org.eclipse.jgit.lib.Repository repository, org.eclipse.jgit.lib.ObjectId commitId, String path)
          Get the id of the blob at the path in the commit that the given revision references.
static org.eclipse.jgit.lib.ObjectId getId(org.eclipse.jgit.lib.Repository repository, String revision, String path)
          Get the id of the blob at the path in the commit that the given revision references.
static byte[] getRawContent(org.eclipse.jgit.lib.Repository repository, org.eclipse.jgit.lib.ObjectId commitId, String path)
          Get the raw contents of the blob in the commit located at the given path.
static byte[] getRawContent(org.eclipse.jgit.lib.Repository repository, String revision, String path)
          Get raw contents of the blob at the given path in the commit that the revision references.
static byte[] getRawHeadContent(org.eclipse.jgit.lib.Repository repository, String path)
          Get the raw contents of the blob at the given path in the commit that HEAD references.
static org.eclipse.jgit.lib.ObjectStream getStream(org.eclipse.jgit.lib.Repository repository, org.eclipse.jgit.lib.ObjectId commitId, String path)
          Open a stream to the contents of the blob at the path in the given commit
static org.eclipse.jgit.lib.ObjectStream getStream(org.eclipse.jgit.lib.Repository repository, String revision, String path)
          Open a stream to the contents of the blob at the path in the commit that the given revision references.
protected static org.eclipse.jgit.lib.ObjectId lookupId(org.eclipse.jgit.lib.Repository repository, org.eclipse.jgit.revwalk.RevCommit commit, String path)
          Get the id of the blob at the path in the given commit.
protected static String toString(org.eclipse.jgit.lib.Repository repository, byte[] raw)
          Convert byte array to UTF-8 String
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BlobUtils

public BlobUtils()
Method Detail

getBytes

protected static byte[] getBytes(org.eclipse.jgit.lib.Repository repository,
                                 org.eclipse.jgit.lib.ObjectId id)
Get the contents of the the blob with the given id as a byte array.

Parameters:
repository -
id -
Returns:
blob bytes

getBytes

protected static byte[] getBytes(org.eclipse.jgit.lib.ObjectReader reader,
                                 org.eclipse.jgit.lib.ObjectId id)
Get the contents of the the blob with the given id as a byte array.

Parameters:
reader -
id -
Returns:
blob bytes

toString

protected static String toString(org.eclipse.jgit.lib.Repository repository,
                                 byte[] raw)
Convert byte array to UTF-8 String

Parameters:
repository -
raw -
Returns:
UTF-8 string or null if bytes are null

getContent

public static String getContent(org.eclipse.jgit.lib.Repository repository,
                                org.eclipse.jgit.lib.ObjectId id)
Get the contents of the the blob with the given id as a UTF-8 String.

Parameters:
repository -
id -
Returns:
content of blob as UTF-8 string

lookupId

protected static org.eclipse.jgit.lib.ObjectId lookupId(org.eclipse.jgit.lib.Repository repository,
                                                        org.eclipse.jgit.revwalk.RevCommit commit,
                                                        String path)
Get the id of the blob at the path in the given commit.

Parameters:
repository -
commit -
path -
Returns:
blob id, null if not present

getBytes

protected static byte[] getBytes(org.eclipse.jgit.lib.Repository repository,
                                 org.eclipse.jgit.revwalk.RevCommit commit,
                                 String path)
Get the contents of the the blob in the commit located at the given path as a byte array.

Parameters:
repository -
commit -
path -
Returns:
raw content

getRawContent

public static byte[] getRawContent(org.eclipse.jgit.lib.Repository repository,
                                   String revision,
                                   String path)
Get raw contents of the blob at the given path in the commit that the revision references.

Parameters:
repository -
revision -
path -
Returns:
raw content or null if no blob with path at given revision

getRawContent

public static byte[] getRawContent(org.eclipse.jgit.lib.Repository repository,
                                   org.eclipse.jgit.lib.ObjectId commitId,
                                   String path)
Get the raw contents of the blob in the commit located at the given path.

Parameters:
repository -
commitId -
path -
Returns:
raw content or null if no blob with path at given commit

getContent

public static String getContent(org.eclipse.jgit.lib.Repository repository,
                                org.eclipse.jgit.lib.ObjectId commitId,
                                String path)
Get the contents of the blob in the commit located at the given path.

Parameters:
repository -
commitId -
path -
Returns:
contents or null if no blob with path at given commit

getContent

public static String getContent(org.eclipse.jgit.lib.Repository repository,
                                String revision,
                                String path)
Get the contents of the blob at the given path in the commit that the revision references.

Parameters:
repository -
revision -
path -
Returns:
contents or null if no blob with path at given revision

getHeadContent

public static String getHeadContent(org.eclipse.jgit.lib.Repository repository,
                                    String path)
Get the contents of the blob at the given path in the commit that HEAD references.

Parameters:
repository -
path -
Returns:
content or null if no blob with path at HEAD commit

getRawHeadContent

public static byte[] getRawHeadContent(org.eclipse.jgit.lib.Repository repository,
                                       String path)
Get the raw contents of the blob at the given path in the commit that HEAD references.

Parameters:
repository -
path -
Returns:
content or null if no blob with path at HEAD commit

getId

public static org.eclipse.jgit.lib.ObjectId getId(org.eclipse.jgit.lib.Repository repository,
                                                  String revision,
                                                  String path)
Get the id of the blob at the path in the commit that the given revision references.

Parameters:
repository -
revision -
path -
Returns:
blob id

getHeadId

public static org.eclipse.jgit.lib.ObjectId getHeadId(org.eclipse.jgit.lib.Repository repository,
                                                      String path)
Get the id of the blob at the path in the commit that HEAD currently references.

Parameters:
repository -
path -
Returns:
blob id

getId

public static org.eclipse.jgit.lib.ObjectId getId(org.eclipse.jgit.lib.Repository repository,
                                                  org.eclipse.jgit.lib.ObjectId commitId,
                                                  String path)
Get the id of the blob at the path in the commit that the given revision references.

Parameters:
repository -
commitId -
path -
Returns:
blob id

getStream

public static org.eclipse.jgit.lib.ObjectStream getStream(org.eclipse.jgit.lib.Repository repository,
                                                          org.eclipse.jgit.lib.ObjectId commitId,
                                                          String path)
Open a stream to the contents of the blob at the path in the given commit

Parameters:
repository -
commitId -
path -
Returns:
stream, null if no blob at given path

getHeadStream

public static org.eclipse.jgit.lib.ObjectStream getHeadStream(org.eclipse.jgit.lib.Repository repository,
                                                              String path)
Open a stream to the contents of the blob at the path in the commit that HEAD currently references.

Parameters:
repository -
path -
Returns:
stream

getStream

public static org.eclipse.jgit.lib.ObjectStream getStream(org.eclipse.jgit.lib.Repository repository,
                                                          String revision,
                                                          String path)
Open a stream to the contents of the blob at the path in the commit that the given revision references.

Parameters:
repository -
revision -
path -
Returns:
stream

diff

public static Collection<org.eclipse.jgit.diff.Edit> diff(org.eclipse.jgit.lib.Repository repository,
                                                          org.eclipse.jgit.lib.ObjectId blob1,
                                                          org.eclipse.jgit.lib.ObjectId blob2)
Diff the blobs at the given object ids using the RawTextComparator.DEFAULT comparator.

Parameters:
repository -
blob1 -
blob2 -
Returns:
list of edits
See Also:
diff(Repository, ObjectId, ObjectId, RawTextComparator)

diff

public static Collection<org.eclipse.jgit.diff.Edit> diff(org.eclipse.jgit.lib.Repository repository,
                                                          org.eclipse.jgit.lib.ObjectId blob1,
                                                          org.eclipse.jgit.lib.ObjectId blob2,
                                                          org.eclipse.jgit.diff.RawTextComparator comparator)
Diff the blobs at the given object ids.

This method will return an empty list if the content of either blob is binary.

Parameters:
repository -
blob1 -
blob2 -
comparator -
Returns:
list of edits, never null

diff

public static Collection<org.eclipse.jgit.diff.Edit> diff(org.eclipse.jgit.lib.ObjectReader reader,
                                                          org.eclipse.jgit.lib.ObjectId blob1,
                                                          org.eclipse.jgit.lib.ObjectId blob2)
Diff the blobs at the given object ids using the RawTextComparator.DEFAULT comparator.

Parameters:
reader -
blob1 -
blob2 -
Returns:
list of edits
See Also:
diff(ObjectReader, ObjectId, ObjectId, RawTextComparator)

diff

public static Collection<org.eclipse.jgit.diff.Edit> diff(org.eclipse.jgit.lib.ObjectReader reader,
                                                          org.eclipse.jgit.lib.ObjectId blob1,
                                                          org.eclipse.jgit.lib.ObjectId blob2,
                                                          org.eclipse.jgit.diff.RawTextComparator comparator)
Diff the blobs at the given object ids.

This method will return an empty list if the content of either blob is binary.

Parameters:
reader -
blob1 -
blob2 -
comparator -
Returns:
list of edits, never null


Copyright © 2011-2012. All Rights Reserved.