org.eclipse.jgit.lib
Class PackIndex

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

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

Access path to locate objects by ObjectId in a PackFile.

Indexes are strictly redundant information in that we can rebuild all of the data held in the index file from the on disk representation of the pack file itself, but it is faster to access for random requests because data is stored by ObjectId.


Nested Class Summary
static class PackIndex.MutableEntry
          Represent mutable entry of pack index consisting of object id and offset in pack (both mutable).
 
Field Summary
protected  byte[] packChecksum
          Footer checksum applied on the bottom of the pack file.
 
Constructor Summary
PackIndex()
           
 
Method Summary
 boolean hasObject(AnyObjectId id)
          Determine if an object is contained within the pack file.
abstract  java.util.Iterator<PackIndex.MutableEntry> iterator()
          Provide iterator that gives access to index entries.
static PackIndex open(java.io.File idxFile)
          Open an existing pack .idx file for reading.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

packChecksum

protected byte[] packChecksum
Footer checksum applied on the bottom of the pack file.

Constructor Detail

PackIndex

public PackIndex()
Method Detail

open

public static PackIndex open(java.io.File idxFile)
                      throws java.io.IOException
Open an existing pack .idx file for reading.

The format of the file will be automatically detected and a proper access implementation for that format will be constructed and returned to the caller. The file may or may not be held open by the returned instance.

Parameters:
idxFile - existing pack .idx to read.
Returns:
access implementation for the requested file.
Throws:
java.io.FileNotFoundException - the file does not exist.
java.io.IOException - the file exists but could not be read due to security errors, unrecognized data version, or unexpected data corruption.

hasObject

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

Parameters:
id - the object to look for. Must not be null.
Returns:
true if the object is listed in this index; false otherwise.

iterator

public abstract java.util.Iterator<PackIndex.MutableEntry> iterator()
Provide iterator that gives access to index entries. Note, that iterator returns reference to mutable object, the same reference in each call - for performance reason. If client needs immutable objects, it must copy returned object on its own.

Iterator returns objects in SHA-1 lexicographical order.

Specified by:
iterator in interface java.lang.Iterable<PackIndex.MutableEntry>
Returns:
iterator over pack index entries