org.eclipse.jgit.storage.file
Class PackFile

java.lang.Object
  extended by org.eclipse.jgit.storage.file.PackFile
All Implemented Interfaces:
java.lang.Iterable<PackIndex.MutableEntry>

public class PackFile
extends java.lang.Object
implements java.lang.Iterable<PackIndex.MutableEntry>

A Git version 2 pack file representation. A pack file contains Git objects in delta packed format yielding high compression of lots of object where some objects are similar.


Field Summary
static java.util.Comparator<PackFile> SORT
          Sorts PackFiles to be most recently created to least recently created.
 
Constructor Summary
PackFile(java.io.File packFile)
          Construct a reader for an existing, pre-indexed packfile.
 
Method Summary
 void close()
          Close the resources utilized by this repository
 PackIndex getIndex()
           
 java.io.File getPackFile()
           
 java.lang.String getPackName()
           
 boolean hasObject(AnyObjectId id)
          Determine if an object is contained within the pack file.
 java.util.Iterator<PackIndex.MutableEntry> iterator()
          Provide iterator over entries in associated pack index, that should also exist in this pack file.
 boolean shouldBeKept()
          Determines whether a .keep file exists for this pack file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SORT

public static final java.util.Comparator<PackFile> SORT
Sorts PackFiles to be most recently created to least recently created.

Constructor Detail

PackFile

public PackFile(java.io.File packFile)
Construct a reader for an existing, pre-indexed packfile.

Parameters:
packFile - path of the .pack file holding the data.
Method Detail

getPackFile

public java.io.File getPackFile()
Returns:
the File object which locates this pack on disk.

getIndex

public PackIndex getIndex()
                   throws java.io.IOException
Returns:
the index for this pack file.
Throws:
java.io.IOException

getPackName

public java.lang.String getPackName()
Returns:
name extracted from pack-*.pack pattern.

hasObject

public boolean hasObject(AnyObjectId id)
                  throws java.io.IOException
Determine if an object is contained within the pack file.

For performance reasons only the index file is searched; the main pack content is ignored entirely.

Parameters:
id - the object to look for. Must not be null.
Returns:
true if the object is in this pack; false otherwise.
Throws:
java.io.IOException - the index file cannot be loaded into memory.

shouldBeKept

public boolean shouldBeKept()
Determines whether a .keep file exists for this pack file.

Returns:
true if a .keep file exist.

close

public void close()
Close the resources utilized by this repository


iterator

public java.util.Iterator<PackIndex.MutableEntry> iterator()
Provide iterator over entries in associated pack index, that should also exist in this pack file. Objects returned by such iterator are mutable during iteration.

Iterator returns objects in SHA-1 lexicographical order.

Specified by:
iterator in interface java.lang.Iterable<PackIndex.MutableEntry>
Returns:
iterator over entries of associated pack index
See Also:
PackIndex.iterator()


Copyright © 2013. All Rights Reserved.