org.eclipse.jgit.lib
Class AlternateRepositoryDatabase

java.lang.Object
  extended by org.eclipse.jgit.lib.ObjectDatabase
      extended by org.eclipse.jgit.lib.AlternateRepositoryDatabase

public final class AlternateRepositoryDatabase
extends ObjectDatabase

An ObjectDatabase of another Repository.

This ObjectDatabase wraps around another Repository's object database, providing its contents to the caller, and closing the Repository when this database is closed. The primary user of this class is ObjectDirectory, when the info/alternates file points at the objects/ directory of another repository.


Field Summary
 
Fields inherited from class org.eclipse.jgit.lib.ObjectDatabase
NO_ALTERNATES
 
Constructor Summary
AlternateRepositoryDatabase(Repository alt)
           
 
Method Summary
protected  void closeAlternates(ObjectDatabase[] alt)
          Close the list of alternates returned by ObjectDatabase.loadAlternates().
 void closeSelf()
          Close any resources held by this database only; ignoring alternates.
 void create()
          Initialize a new object database at this location.
 boolean exists()
          Does this database exist yet?
 Repository getRepository()
           
protected  boolean hasObject1(AnyObjectId objectId)
          Fast half of ObjectDatabase.hasObject(AnyObjectId).
protected  boolean hasObject2(java.lang.String objectName)
          Slow half of ObjectDatabase.hasObject(AnyObjectId).
protected  ObjectDatabase[] loadAlternates()
          Load the list of alternate databases into memory.
protected  ObjectLoader openObject1(WindowCursor curs, AnyObjectId objectId)
          Fast half of ObjectDatabase.openObject(WindowCursor, AnyObjectId).
protected  ObjectLoader openObject2(WindowCursor curs, java.lang.String objectName, AnyObjectId objectId)
          Slow half of ObjectDatabase.openObject(WindowCursor, AnyObjectId).
protected  boolean tryAgain1()
           
 
Methods inherited from class org.eclipse.jgit.lib.ObjectDatabase
close, closeAlternates, getAlternates, hasObject, openObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AlternateRepositoryDatabase

public AlternateRepositoryDatabase(Repository alt)
Parameters:
alt - the alternate repository to wrap and export.
Method Detail

getRepository

public Repository getRepository()
Returns:
the alternate repository objects are borrowed from.

closeSelf

public void closeSelf()
Description copied from class: ObjectDatabase
Close any resources held by this database only; ignoring alternates.

To fully close this database and its referenced alternates, the caller should instead invoke ObjectDatabase.close().

Overrides:
closeSelf in class ObjectDatabase

create

public void create()
            throws java.io.IOException
Description copied from class: ObjectDatabase
Initialize a new object database at this location.

Overrides:
create in class ObjectDatabase
Throws:
java.io.IOException - the database could not be created.

exists

public boolean exists()
Description copied from class: ObjectDatabase
Does this database exist yet?

Overrides:
exists in class ObjectDatabase
Returns:
true if this database is already created; false if the caller should invoke ObjectDatabase.create() to create this database location.

hasObject1

protected boolean hasObject1(AnyObjectId objectId)
Description copied from class: ObjectDatabase
Fast half of ObjectDatabase.hasObject(AnyObjectId).

Specified by:
hasObject1 in class ObjectDatabase
Parameters:
objectId - identity of the object to test for existence of.
Returns:
true if the specified object is stored in this database.

tryAgain1

protected boolean tryAgain1()
Overrides:
tryAgain1 in class ObjectDatabase
Returns:
true if the fast-half search should be tried again.

hasObject2

protected boolean hasObject2(java.lang.String objectName)
Description copied from class: ObjectDatabase
Slow half of ObjectDatabase.hasObject(AnyObjectId).

Overrides:
hasObject2 in class ObjectDatabase
Parameters:
objectName - identity of the object to test for existence of.
Returns:
true if the specified object is stored in this database.

openObject1

protected ObjectLoader openObject1(WindowCursor curs,
                                   AnyObjectId objectId)
                            throws java.io.IOException
Description copied from class: ObjectDatabase
Fast half of ObjectDatabase.openObject(WindowCursor, AnyObjectId).

Specified by:
openObject1 in class ObjectDatabase
Parameters:
curs - temporary working space associated with the calling thread.
objectId - identity of the object to open.
Returns:
a ObjectLoader for accessing the data of the named object, or null if the object does not exist.
Throws:
java.io.IOException

openObject2

protected ObjectLoader openObject2(WindowCursor curs,
                                   java.lang.String objectName,
                                   AnyObjectId objectId)
                            throws java.io.IOException
Description copied from class: ObjectDatabase
Slow half of ObjectDatabase.openObject(WindowCursor, AnyObjectId).

Overrides:
openObject2 in class ObjectDatabase
Parameters:
curs - temporary working space associated with the calling thread.
objectName - name of the object to open.
objectId - identity of the object to open.
Returns:
a ObjectLoader for accessing the data of the named object, or null if the object does not exist.
Throws:
java.io.IOException

loadAlternates

protected ObjectDatabase[] loadAlternates()
                                   throws java.io.IOException
Description copied from class: ObjectDatabase
Load the list of alternate databases into memory.

This method is invoked by ObjectDatabase.getAlternates() if the alternate list has not yet been populated, or if ObjectDatabase.closeAlternates() has been called on this instance and the alternate list is needed again.

If the alternate array is empty, implementors should consider using the constant ObjectDatabase.NO_ALTERNATES.

Overrides:
loadAlternates in class ObjectDatabase
Returns:
the alternate list for this database.
Throws:
java.io.IOException - the alternate list could not be accessed. The empty alternate array ObjectDatabase.NO_ALTERNATES will be assumed by the caller.

closeAlternates

protected void closeAlternates(ObjectDatabase[] alt)
Description copied from class: ObjectDatabase
Close the list of alternates returned by ObjectDatabase.loadAlternates().

Overrides:
closeAlternates in class ObjectDatabase
Parameters:
alt - the alternate list, from ObjectDatabase.loadAlternates().