FileDocCategorySizeDatePackage
CstType.javaAPI DocAndroid 1.5 API7471Wed May 06 22:41:02 BST 2009com.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
non-null; map of interned types
public static final CstType
OBJECT
non-null; instance corresponding to the class Object
public static final CstType
BOOLEAN
non-null; instance corresponding to the class Boolean
public static final CstType
BYTE
non-null; instance corresponding to the class Byte
public static final CstType
CHARACTER
non-null; instance corresponding to the class Character
public static final CstType
DOUBLE
non-null; instance corresponding to the class Double
public static final CstType
FLOAT
non-null; instance corresponding to the class Float
public static final CstType
LONG
non-null; instance corresponding to the class Long
public static final CstType
INTEGER
non-null; instance corresponding to the class Integer
public static final CstType
SHORT
non-null; instance corresponding to the class Short
public static final CstType
VOID
non-null; instance corresponding to the class Void
public static final CstType
BOOLEAN_ARRAY
non-null; instance corresponding to the type boolean[]
public static final CstType
BYTE_ARRAY
non-null; instance corresponding to the type byte[]
public static final CstType
CHAR_ARRAY
non-null; instance corresponding to the type char[]
public static final CstType
DOUBLE_ARRAY
non-null; instance corresponding to the type double[]
public static final CstType
FLOAT_ARRAY
non-null; instance corresponding to the type float[]
public static final CstType
LONG_ARRAY
non-null; instance corresponding to the type long[]
public static final CstType
INT_ARRAY
non-null; instance corresponding to the type int[]
public static final CstType
SHORT_ARRAY
non-null; instance corresponding to the type short[]
private final com.android.dx.rop.type.Type
type
non-null; the underlying type
private CstUtf8
descriptor
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 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 java.lang.Integer.

param
primitiveType non-null; the primitive type
return
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 Class).

return
non-null; the type corresponding to the name

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

return
non-null; the descriptor

        if (descriptor == null) {
            descriptor = new CstUtf8(type.getDescriptor());
        }
        
        return descriptor;
    
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 non-null; the underlying type
return
non-null; an appropriately-constructed instance

        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";