FileDocCategorySizeDatePackage
SortableType.javaAPI DocAndroid 5.1 API3171Thu Mar 12 22:18:30 GMT 2015com.android.dx.merge

SortableType

public final class SortableType extends Object
Name and structure of a type. Used to order types such that each type is preceded by its supertype and implemented interfaces.

Fields Summary
public static final Comparator
NULLS_LAST_ORDER
private final com.android.dex.Dex
dex
private com.android.dex.ClassDef
classDef
private int
depth
Constructors Summary
public SortableType(com.android.dex.Dex dex, com.android.dex.ClassDef classDef)


         
        this.dex = dex;
        this.classDef = classDef;
    
Methods Summary
public com.android.dex.ClassDefgetClassDef()

        return classDef;
    
public com.android.dex.DexgetDex()

        return dex;
    
public intgetTypeIndex()

        return classDef.getTypeIndex();
    
public booleanisDepthAssigned()

        return depth != -1;
    
public booleantryAssignDepth(com.android.dx.merge.SortableType[] types)
Assigns this type's depth if the depths of its supertype and implemented interfaces are known. Returns false if the depth couldn't be computed yet.

        int max;
        if (classDef.getSupertypeIndex() == ClassDef.NO_INDEX) {
            max = 0; // this is Object.class or an interface
        } else {
            SortableType sortableSupertype = types[classDef.getSupertypeIndex()];
            if (sortableSupertype == null) {
                max = 1; // unknown, so assume it's a root.
            } else if (sortableSupertype.depth == -1) {
                return false;
            } else {
                max = sortableSupertype.depth;
            }
        }

        for (short interfaceIndex : classDef.getInterfaces()) {
            SortableType implemented = types[interfaceIndex];
            if (implemented == null) {
                max = Math.max(max, 1); // unknown, so assume it's a root.
            } else if (implemented.depth == -1) {
                return false;
            } else {
                max = Math.max(max, implemented.depth);
            }
        }

        depth = max + 1;
        return true;