diff options
author | Shawn O. Pearce <spearce@spearce.org> | 2010-06-28 11:54:58 -0700 |
---|---|---|
committer | Shawn O. Pearce <spearce@spearce.org> | 2010-06-28 11:54:58 -0700 |
commit | acb7be2c5adb270d21182d389ce93f3bca38cd29 (patch) | |
tree | 56f8a6d9adc48a303beec91b9313537b0a7ce57a /org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectDatabase.java | |
parent | 6b62e53b607630b6c00411741972838ced552f4d (diff) | |
download | jgit-acb7be2c5adb270d21182d389ce93f3bca38cd29.tar.gz jgit-acb7be2c5adb270d21182d389ce93f3bca38cd29.zip |
Refactor Repository.openObject to be Repository.open
We drop the "Object" suffix, because its pretty clear here that
we want to open an object, given that we pass in AnyObjectId as
the main parameter. We also fix the calling convention to throw
a MissingObjectException or IncorrectObjectTypeException, so that
callers don't have to do this error checking themselves.
Change-Id: I72c43353cea8372278b032f5086d52082c1eee39
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectDatabase.java')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectDatabase.java | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectDatabase.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectDatabase.java index c2d2beda9a..a095663bf4 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectDatabase.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectDatabase.java @@ -45,6 +45,7 @@ package org.eclipse.jgit.lib; import java.io.IOException; +import org.eclipse.jgit.errors.IncorrectObjectTypeException; import org.eclipse.jgit.errors.MissingObjectException; /** @@ -143,9 +144,36 @@ public abstract class ObjectDatabase { */ public ObjectLoader openObject(final AnyObjectId objectId) throws IOException { + return openObject(objectId, ObjectReader.OBJ_ANY); + } + + /** + * Open an object from this database. + * <p> + * This is a one-shot call interface which may be faster than allocating a + * {@link #newReader()} to perform the lookup. + * + * @param objectId + * identity of the object to open. + * @param typeHint + * hint about the type of object being requested; + * {@link ObjectReader#OBJ_ANY} if the object type is not known, + * or does not matter to the caller. + * @return a {@link ObjectLoader} for accessing the object. + * @throws MissingObjectException + * the object does not exist. + * @throws IncorrectObjectTypeException + * typeHint was not OBJ_ANY, and the object's actual type does + * not match typeHint. + * @throws IOException + * the object store cannot be accessed. + */ + public ObjectLoader openObject(AnyObjectId objectId, int typeHint) + throws MissingObjectException, IncorrectObjectTypeException, + IOException { final ObjectReader or = newReader(); try { - return or.openObject(objectId); + return or.openObject(objectId, typeHint); } finally { or.release(); } |