FileDocCategorySizeDatePackage
CstType.javaAPI DocAndroid 5.1 API8438Thu Mar 12 22:18:30 GMT 2015com.android.dx.rop.cst

CstType

public final class CstType extends TypedConstant
Constants that represent an arbitrary type (reference or primitive).

Fields Summary
private static final HashMap
interns
{@code non-null;} map of interned types
public static final CstType
OBJECT
{@code non-null;} instance corresponding to the class {@code Object}
public static final CstType
BOOLEAN
{@code non-null;} instance corresponding to the class {@code Boolean}
public static final CstType
BYTE
{@code non-null;} instance corresponding to the class {@code Byte}
public static final CstType
CHARACTER
{@code non-null;} instance corresponding to the class {@code Character}
public static final CstType
DOUBLE
{@code non-null;} instance corresponding to the class {@code Double}
public static final CstType
FLOAT
{@code non-null;} instance corresponding to the class {@code Float}
public static final CstType
LONG
{@code non-null;} instance corresponding to the class {@code Long}
public static final CstType
INTEGER
{@code non-null;} instance corresponding to the class {@code Integer}
public static final CstType
SHORT
{@code non-null;} instance corresponding to the class {@code Short}
public static final CstType
VOID
{@code non-null;} instance corresponding to the class {@code Void}
public static final CstType
BOOLEAN_ARRAY
{@code non-null;} instance corresponding to the type {@code boolean[]}
public static final CstType
BYTE_ARRAY
{@code non-null;} instance corresponding to the type {@code byte[]}
public static final CstType
CHAR_ARRAY
{@code non-null;} instance corresponding to the type {@code char[]}
public static final CstType
DOUBLE_ARRAY
{@code non-null;} instance corresponding to the type {@code double[]}
public static final CstType
FLOAT_ARRAY
{@code non-null;} instance corresponding to the type {@code float[]}
public static final CstType
LONG_ARRAY
{@code non-null;} instance corresponding to the type {@code long[]}
public static final CstType
INT_ARRAY
{@code non-null;} instance corresponding to the type {@code int[]}
public static final CstType
SHORT_ARRAY
{@code non-null;} instance corresponding to the type {@code short[]}
private final com.android.dx.rop.type.Type
type
{@code non-null;} the underlying type
private CstString
descriptor
{@code null-ok;} the type descriptor corresponding to this instance, if calculated
Constructors Summary
public CstType(com.android.dx.rop.type.Type type)
Constructs an instance.

param
type {@code non-null;} the underlying type

        if (type == null) {
            throw new NullPointerException("type == null");
        }

        if (type == Type.KNOWN_NULL) {
            throw new UnsupportedOperationException(
                    "KNOWN_NULL is not representable");
        }

        this.type = type;
        this.descriptor = null;
    
Methods Summary
protected intcompareTo0(Constant other)
{@inheritDoc}

        String thisDescriptor = type.getDescriptor();
        String otherDescriptor = ((CstType) other).type.getDescriptor();
        return thisDescriptor.compareTo(otherDescriptor);
    
public booleanequals(java.lang.Object other)
{@inheritDoc}

        if (!(other instanceof CstType)) {
            return false;
        }

        return type == ((CstType) other).type;
    
public static com.android.dx.rop.cst.CstTypeforBoxedPrimitiveType(com.android.dx.rop.type.Type primitiveType)
Returns an instance of this class that represents the wrapper class corresponding to a given primitive type. For example, if given {@link Type#INT}, this method returns the class reference {@code java.lang.Integer}.

param
primitiveType {@code non-null;} the primitive type
return
{@code non-null;} the corresponding wrapper class


                                                      
         
        switch (primitiveType.getBasicType()) {
            case Type.BT_BOOLEAN: return BOOLEAN;
            case Type.BT_BYTE:    return BYTE;
            case Type.BT_CHAR:    return CHARACTER;
            case Type.BT_DOUBLE:  return DOUBLE;
            case Type.BT_FLOAT:   return FLOAT;
            case Type.BT_INT:     return INTEGER;
            case Type.BT_LONG:    return LONG;
            case Type.BT_SHORT:   return SHORT;
            case Type.BT_VOID:    return VOID;
        }

        throw new IllegalArgumentException("not primitive: " + primitiveType);
    
public com.android.dx.rop.type.TypegetClassType()
Gets the underlying type (as opposed to the type corresponding to this instance as a constant, which is always {@code Class}).

return
{@code non-null;} the type corresponding to the name

        return type;
    
public CstStringgetDescriptor()
Gets the type descriptor for this instance.

return
{@code non-null;} the descriptor

        if (descriptor == null) {
            descriptor = new CstString(type.getDescriptor());
        }

        return descriptor;
    
public java.lang.StringgetPackageName()
Returns a human readable package name for this type, like "java.util". If this is an array type, this returns the package name of the array's component type. If this is a primitive type, this returns "default".

        // descriptor is a string like "[[Ljava/util/String;"
        String descriptor = getDescriptor().getString();
        int lastSlash = descriptor.lastIndexOf('/");
        int lastLeftSquare = descriptor.lastIndexOf('["); // -1 unless this is an array
        if (lastSlash == -1) {
            return "default";
        } else {
            // +2 to skip the '[' and the 'L' prefix
            return descriptor.substring(lastLeftSquare + 2, lastSlash).replace('/", '.");
        }
    
public com.android.dx.rop.type.TypegetType()
{@inheritDoc}

        return Type.CLASS;
    
public inthashCode()
{@inheritDoc}

        return type.hashCode();
    
public static com.android.dx.rop.cst.CstTypeintern(com.android.dx.rop.type.Type type)
Returns an interned instance of this class for the given type.

param
type {@code non-null;} the underlying type
return
{@code non-null;} an appropriately-constructed instance

        synchronized (interns) {
            CstType cst = interns.get(type);

            if (cst == null) {
                cst = new CstType(type);
                interns.put(type, cst);
            }

            return cst;
        }
    
public booleanisCategory2()
{@inheritDoc}

        return false;
    
public java.lang.StringtoHuman()
{@inheritDoc}

        return type.toHuman();
    
public java.lang.StringtoString()
{@inheritDoc}

        return "type{" + toHuman() + '}";
    
public java.lang.StringtypeName()
{@inheritDoc}

        return "type";