Browse Source

Rename openObject, hasObject to just open, has

Similar to what we did on Repository, the openObject method
already implied we wanted to open an object, given its main
argument was of type AnyObjectId.  Simplify the method name
to just the action, has or open.

Change-Id: If055e5e0d8de0e2424c18a773f6d2bc2f66054f4
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
stable-0.9
Shawn O. Pearce 15 years ago
parent
commit
aa4b06e087
  1. 2
      org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/IpLogGenerator.java
  2. 12
      org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectDatabase.java
  3. 10
      org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectReader.java
  4. 6
      org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java
  5. 2
      org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevObject.java
  6. 2
      org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevWalk.java
  7. 2
      org.eclipse.jgit/src/org/eclipse/jgit/storage/file/CachedObjectDirectory.java
  8. 2
      org.eclipse.jgit/src/org/eclipse/jgit/storage/file/FileObjectDatabase.java
  9. 4
      org.eclipse.jgit/src/org/eclipse/jgit/storage/file/ObjectDirectoryInserter.java
  10. 6
      org.eclipse.jgit/src/org/eclipse/jgit/storage/file/WindowCursor.java
  11. 2
      org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java
  12. 4
      org.eclipse.jgit/src/org/eclipse/jgit/transport/IndexPack.java
  13. 2
      org.eclipse.jgit/src/org/eclipse/jgit/treewalk/CanonicalTreeParser.java

2
org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/IpLogGenerator.java

@ -416,7 +416,7 @@ public class IpLogGenerator {
private byte[] openBlob(int side) throws IOException {
tw.getObjectId(idbuf, side);
return curs.openObject(idbuf, Constants.OBJ_BLOB).getCachedBytes();
return curs.open(idbuf, Constants.OBJ_BLOB).getCachedBytes();
}
/**

12
org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectDatabase.java

@ -119,10 +119,10 @@ public abstract class ObjectDatabase {
* @throws IOException
* the object store cannot be accessed.
*/
public boolean hasObject(final AnyObjectId objectId) throws IOException {
public boolean has(final AnyObjectId objectId) throws IOException {
final ObjectReader or = newReader();
try {
return or.hasObject(objectId);
return or.has(objectId);
} finally {
or.release();
}
@ -142,9 +142,9 @@ public abstract class ObjectDatabase {
* @throws IOException
* the object store cannot be accessed.
*/
public ObjectLoader openObject(final AnyObjectId objectId)
public ObjectLoader open(final AnyObjectId objectId)
throws IOException {
return openObject(objectId, ObjectReader.OBJ_ANY);
return open(objectId, ObjectReader.OBJ_ANY);
}
/**
@ -168,12 +168,12 @@ public abstract class ObjectDatabase {
* @throws IOException
* the object store cannot be accessed.
*/
public ObjectLoader openObject(AnyObjectId objectId, int typeHint)
public ObjectLoader open(AnyObjectId objectId, int typeHint)
throws MissingObjectException, IncorrectObjectTypeException,
IOException {
final ObjectReader or = newReader();
try {
return or.openObject(objectId, typeHint);
return or.open(objectId, typeHint);
} finally {
or.release();
}

10
org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectReader.java

@ -68,9 +68,9 @@ public abstract class ObjectReader {
* @throws IOException
* the object store cannot be accessed.
*/
public boolean hasObject(AnyObjectId objectId) throws IOException {
public boolean has(AnyObjectId objectId) throws IOException {
try {
openObject(objectId);
open(objectId);
return true;
} catch (MissingObjectException notFound) {
return false;
@ -88,9 +88,9 @@ public abstract class ObjectReader {
* @throws IOException
* the object store cannot be accessed.
*/
public ObjectLoader openObject(AnyObjectId objectId)
public ObjectLoader open(AnyObjectId objectId)
throws MissingObjectException, IOException {
return openObject(objectId, OBJ_ANY);
return open(objectId, OBJ_ANY);
}
/**
@ -111,7 +111,7 @@ public abstract class ObjectReader {
* @throws IOException
* the object store cannot be accessed.
*/
public abstract ObjectLoader openObject(AnyObjectId objectId, int typeHint)
public abstract ObjectLoader open(AnyObjectId objectId, int typeHint)
throws MissingObjectException, IncorrectObjectTypeException,
IOException;

6
org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java

@ -213,7 +213,7 @@ public abstract class Repository {
*/
public boolean hasObject(AnyObjectId objectId) {
try {
return getObjectDatabase().hasObject(objectId);
return getObjectDatabase().has(objectId);
} catch (IOException e) {
// Legacy API, assume error means "no"
return false;
@ -236,7 +236,7 @@ public abstract class Repository {
*/
public ObjectLoader open(final AnyObjectId objectId)
throws MissingObjectException, IOException {
return getObjectDatabase().openObject(objectId);
return getObjectDatabase().open(objectId);
}
/**
@ -263,7 +263,7 @@ public abstract class Repository {
public ObjectLoader open(AnyObjectId objectId, int typeHint)
throws MissingObjectException, IncorrectObjectTypeException,
IOException {
return getObjectDatabase().openObject(objectId, typeHint);
return getObjectDatabase().open(objectId, typeHint);
}
/**

2
org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevObject.java

@ -77,7 +77,7 @@ public abstract class RevObject extends ObjectId {
final byte[] loadCanonical(final RevWalk walk) throws IOException,
MissingObjectException, IncorrectObjectTypeException,
CorruptObjectException {
return walk.curs.openObject(this, getType()).getCachedBytes();
return walk.curs.open(this, getType()).getCachedBytes();
}
/**

2
org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevWalk.java

@ -720,7 +720,7 @@ public class RevWalk implements Iterable<RevCommit> {
throws MissingObjectException, IOException {
RevObject r = objects.get(id);
if (r == null) {
final ObjectLoader ldr = curs.openObject(id);
final ObjectLoader ldr = curs.open(id);
final byte[] data = ldr.getCachedBytes();
final int type = ldr.getType();
switch (type) {

2
org.eclipse.jgit/src/org/eclipse/jgit/storage/file/CachedObjectDirectory.java

@ -149,7 +149,7 @@ class CachedObjectDirectory extends FileObjectDatabase {
}
@Override
public boolean hasObject(final AnyObjectId objectId) {
public boolean has(final AnyObjectId objectId) {
return hasObjectImpl1(objectId);
}

2
org.eclipse.jgit/src/org/eclipse/jgit/storage/file/FileObjectDatabase.java

@ -69,7 +69,7 @@ abstract class FileObjectDatabase extends ObjectDatabase {
* @return true if the specified object is stored in this database, or any
* of the alternate databases.
*/
public boolean hasObject(final AnyObjectId objectId) {
public boolean has(final AnyObjectId objectId) {
return hasObjectImpl1(objectId) || hasObjectImpl2(objectId.name());
}

4
org.eclipse.jgit/src/org/eclipse/jgit/storage/file/ObjectDirectoryInserter.java

@ -83,7 +83,7 @@ class ObjectDirectoryInserter extends ObjectInserter {
final MessageDigest md = digest();
final File tmp = toTemp(md, type, len, is);
final ObjectId id = ObjectId.fromRaw(md.digest());
if (db.hasObject(id)) {
if (db.has(id)) {
// Object is already in the repository, remove temporary file.
//
tmp.delete();
@ -102,7 +102,7 @@ class ObjectDirectoryInserter extends ObjectInserter {
if (tmp.renameTo(dst))
return id;
if (db.hasObject(id)) {
if (db.has(id)) {
tmp.delete();
return id;
}

6
org.eclipse.jgit/src/org/eclipse/jgit/storage/file/WindowCursor.java

@ -77,11 +77,11 @@ final class WindowCursor extends ObjectReader implements ObjectReuseAsIs {
this.db = db;
}
public boolean hasObject(AnyObjectId objectId) throws IOException {
return db.hasObject(objectId);
public boolean has(AnyObjectId objectId) throws IOException {
return db.has(objectId);
}
public ObjectLoader openObject(AnyObjectId objectId, int typeHint)
public ObjectLoader open(AnyObjectId objectId, int typeHint)
throws MissingObjectException, IncorrectObjectTypeException,
IOException {
final ObjectLoader ldr = db.openObject(this, objectId);

2
org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java

@ -714,7 +714,7 @@ public class PackWriter {
private void writeWholeObjectDeflate(PackOutputStream out,
final ObjectToPack otp) throws IOException {
final ObjectLoader loader = reader.openObject(otp, otp.getType());
final ObjectLoader loader = reader.open(otp, otp.getType());
final byte[] data = loader.getCachedBytes();
out.writeHeader(otp, data.length);
deflater.reset();

4
org.eclipse.jgit/src/org/eclipse/jgit/transport/IndexPack.java

@ -595,7 +595,7 @@ public class IndexPack {
baseObjectIds.add(baseId);
final ObjectLoader ldr;
try {
ldr = readCurs.openObject(baseId);
ldr = readCurs.open(baseId);
} catch (MissingObjectException notFound) {
missing.add(baseId);
continue;
@ -856,7 +856,7 @@ public class IndexPack {
}
try {
final ObjectLoader ldr = readCurs.openObject(id, type);
final ObjectLoader ldr = readCurs.open(id, type);
final byte[] existingData = ldr.getCachedBytes();
if (!Arrays.equals(data, existingData)) {
throw new IOException(MessageFormat.format(JGitText.get().collisionOn, id.name()));

2
org.eclipse.jgit/src/org/eclipse/jgit/treewalk/CanonicalTreeParser.java

@ -198,7 +198,7 @@ public class CanonicalTreeParser extends AbstractTreeIterator {
public void reset(final Repository repo, final AnyObjectId id,
final ObjectReader curs)
throws IncorrectObjectTypeException, IOException {
reset(curs.openObject(id, Constants.OBJ_TREE).getCachedBytes());
reset(curs.open(id, Constants.OBJ_TREE).getCachedBytes());
}
@Override

Loading…
Cancel
Save