Example usage for org.eclipse.jgit.lib Constants OBJ_BAD

List of usage examples for org.eclipse.jgit.lib Constants OBJ_BAD

Introduction

In this page you can find the example usage for org.eclipse.jgit.lib Constants OBJ_BAD.

Prototype

int OBJ_BAD

To view the source code for org.eclipse.jgit.lib Constants OBJ_BAD.

Click Source Link

Document

An unknown or invalid object type code.

Usage

From source file:net.erdfelt.android.sdkfido.git.internal.GitInfo.java

License:Apache License

public static String asObjectType(int objectType) {
    switch (objectType) {
    case Constants.OBJ_BAD:
        return "BAD";
    case Constants.OBJ_BLOB:
        return "BLOB";
    case Constants.OBJ_COMMIT:
        return "COMMIT";
    case Constants.OBJ_EXT:
        return "EXT(future)";
    case Constants.OBJ_OFS_DELTA:
        return "OFS_DELTA(offset_delta)";
    case Constants.OBJ_REF_DELTA:
        return "REF_DELTA(reference_delta)";
    case Constants.OBJ_TAG:
        return "TAG";
    case Constants.OBJ_TREE:
        return "TREE";
    case Constants.OBJ_TYPE_5:
        return "TYPE_S(future)";
    default:/*from w w  w  .  j a  v a  2 s .co m*/
        return "[" + objectType + "]";
    }
}

From source file:net.erdfelt.android.sdkfido.git.internal.GitInfo.java

License:Apache License

public static String getObjectName(Repository repo, ObjectId objectId) {
    try {/*from  w ww  . j  a va  2 s.co  m*/
        ObjectLoader loader = repo.open(objectId);
        StringBuilder ret = new StringBuilder();

        if (loader.isLarge()) {
            ret.append("LARGE! ");
        }

        switch (loader.getType()) {
        case Constants.OBJ_BAD:
            ret.append("BAD ");
            break;
        case Constants.OBJ_BLOB:
            ret.append("BLOB ");
            break;
        case Constants.OBJ_COMMIT:
            ret.append("COMMIT ");
            break;
        case Constants.OBJ_EXT:
            ret.append("EXT ");
            break;
        case Constants.OBJ_OFS_DELTA:
            ret.append("OFS_DELTA ");
            break;
        case Constants.OBJ_REF_DELTA:
            ret.append("REF_DELTA ");
            break;
        case Constants.OBJ_TAG:
            ret.append("TAG ");
            break;
        case Constants.OBJ_TREE:
            ret.append("TREE ");
            break;
        case Constants.OBJ_TYPE_5:
            ret.append("TYPE_5 ");
            break;
        default:
            ret.append("UNKNOWN[").append(loader.getType()).append("] ");
            break;
        }

        ret.append(String.format("Size=%,d", loader.getSize()));
        return ret.toString();
    } catch (MissingObjectException e) {
        LOG.log(Level.WARNING, "Unable to open objectId: " + objectId, e);
        return "<missing object>";
    } catch (IOException e) {
        LOG.log(Level.WARNING, "Unable to open objectId: " + objectId, e);
        return "<unable to open object>";
    }
}

From source file:org.webcat.core.git.GitRepository.java

License:Open Source License

/**
 * Gets the type of the object with the specified ID (either a tree, tag,
 * blob, or commit)./*w w  w.j  a v a2  s.com*/
 *
 * @param id the object ID
 * @return the object type, one of the {@code OBJ_*} constants in the
 *     {@link Constants} class.
 */
public int typeOfObject(ObjectId id) {
    ObjectReader reader = repository.newObjectReader();

    try {
        ObjectLoader loader = reader.open(id);
        return loader.getType();
    } catch (Exception e) {
        return Constants.OBJ_BAD;
    } finally {
        reader.release();
    }
}