FileDocCategorySizeDatePackage
CstBaseMethodRef.javaAPI DocAndroid 1.5 API4960Wed May 06 22:41:02 BST 2009com.android.dx.rop.cst

CstBaseMethodRef

public abstract class CstBaseMethodRef extends CstMemberRef
Base class for constants of "methodish" type.

Note: As a {@link TypeBearer}, this class bears the return type of the method.

Fields Summary
private final com.android.dx.rop.type.Prototype
prototype
non-null; the raw prototype for this method
private com.android.dx.rop.type.Prototype
instancePrototype
null-ok; the prototype for this method taken to be an instance method, or null if not yet calculated
Constructors Summary
CstBaseMethodRef(CstType definingClass, CstNat nat)
Constructs an instance.

param
definingClass non-null; the type of the defining class
param
nat non-null; the name-and-type

        super(definingClass, nat);

        String descriptor = getNat().getDescriptor().getString();
        this.prototype = Prototype.intern(descriptor);
        this.instancePrototype = null;
    
Methods Summary
protected final intcompareTo0(Constant other)
{@inheritDoc}

        int cmp = super.compareTo0(other);

        if (cmp != 0) {
            return cmp;
        }

        CstBaseMethodRef otherMethod = (CstBaseMethodRef) other;
        return prototype.compareTo(otherMethod.prototype);
    
public final intgetParameterWordCount(boolean isStatic)
Gets the number of words of parameters required by this method's descriptor. Since instances of this class have no way to know if they will be used in a static or instance context, one has to indicate this explicitly as an argument. This method is just a convenient shorthand for getPrototype().getParameterTypes().getWordCount(), plus 1 if the method is to be treated as an instance method.

param
isStatic whether the method should be considered static
return
>= 0; the argument word count

        return getPrototype(isStatic).getParameterTypes().getWordCount();
    
public final com.android.dx.rop.type.PrototypegetPrototype()
Gets the raw prototype of this method. This doesn't include a this argument.

return
non-null; the method prototype

        return prototype;
    
public final com.android.dx.rop.type.PrototypegetPrototype(boolean isStatic)
Gets the prototype of this method as either a static or instance method. In the case of a static method, this is the same as the raw prototype. In the case of an instance method, this has an appropriately-typed this argument as the first one.

param
isStatic whether the method should be considered static
return
non-null; the method prototype

        if (isStatic) {
            return prototype;
        } else {
            if (instancePrototype == null) {
                Type thisType = getDefiningClass().getClassType();
                instancePrototype = prototype.withFirstParameter(thisType);
            }
            return instancePrototype;
        }
    
public final com.android.dx.rop.type.TypegetType()
{@inheritDoc} In this case, this method returns the return type of this method.

return
non-null; the method's return type

        return prototype.getReturnType();
    
public final booleanisClassInit()
Gets whether this is a reference to a class initialization method. This is just a convenient shorthand for getNat().isClassInit().

return
true iff this is a reference to an instance initialization method

        return getNat().isClassInit();
    
public final booleanisInstanceInit()
Gets whether this is a reference to an instance initialization method. This is just a convenient shorthand for getNat().isInstanceInit().

return
true iff this is a reference to an instance initialization method

        return getNat().isInstanceInit();