FileDocCategorySizeDatePackage
MethodAPI.javaAPI DocAndroid 1.5 API4800Wed May 06 22:41:22 BST 2009jdiff

MethodAPI

public class MethodAPI extends Object implements Comparable
Class to represent a method, analogous to MethodDoc in the Javadoc doclet API. The method used for Collection comparison (compareTo) must make its comparison based upon everything that is known about this method. See the file LICENSE.txt for copyright details.
author
Matthew Doar, mdoar@pobox.com

Fields Summary
public String
name_
Name of the method.
public String
returnType_
Return type of the method.
public String
inheritedFrom_
The fully qualified name of the class or interface this method is inherited from. If this is null, then the method is defined locally in this class or interface.
public String
exceptions_
The exceptions thrown by this method, being all the exception types separated by commas. "no exceptions" if no exceptions are thrown.
public boolean
isAbstract_
Set if this method is abstract.
public boolean
isNative_
Set if this method is native.
public boolean
isSynchronized_
Set if this method is synchronized.
public Modifiers
modifiers_
Modifiers for this class.
public List
params_
public String
doc_
The doc block, default is null.
public String
signature_
Cached result of getSignature().
Constructors Summary
public MethodAPI(String name, String returnType, boolean isAbstract, boolean isNative, boolean isSynchronized, Modifiers modifiers)
Constructor.


      
           
                        
                       
        name_ = name;
        returnType_ = returnType;
        isAbstract_ = isAbstract;
        isNative_ = isNative;
        isSynchronized_ = isSynchronized;
        modifiers_ = modifiers;
        params_ = new ArrayList(); // ParamAPI[]
    
public MethodAPI(MethodAPI m)
Copy constructor.

        name_ = m.name_;
        returnType_ = m.returnType_;
        inheritedFrom_ = m.inheritedFrom_;
        exceptions_ = m.exceptions_;
        isAbstract_ = m.isAbstract_;
        isNative_ = m.isNative_;
        isSynchronized_ = m.isSynchronized_;
        modifiers_ = m.modifiers_; // Note: shallow copy
        params_ = m.params_; // Note: shallow copy
        doc_ = m.doc_;
        signature_ = m.signature_; // Cached
    
Methods Summary
public intcompareTo(java.lang.Object o)
Compare two methods, including the return type, and parameter names and types, and modifiers.

        MethodAPI oMethod = (MethodAPI)o;
        int comp = name_.compareTo(oMethod.name_);
        if (comp != 0)
            return comp;
        comp = returnType_.compareTo(oMethod.returnType_);
        if (comp != 0)
            return comp;
        if (APIComparator.changedInheritance(inheritedFrom_, oMethod.inheritedFrom_) != 0)
            return -1;
        if (isAbstract_ != oMethod.isAbstract_) {
            return -1;
        }
        if (Diff.showAllChanges && 
	    isNative_ != oMethod.isNative_) {
            return -1;
        }
        if (Diff.showAllChanges && 
	    isSynchronized_ != oMethod.isSynchronized_) {
            return -1;
        }
        comp = exceptions_.compareTo(oMethod.exceptions_);
        if (comp != 0)
            return comp;
        comp = modifiers_.compareTo(oMethod.modifiers_);
        if (comp != 0)
            return comp;
        comp = getSignature().compareTo(oMethod.getSignature());
        if (comp != 0)
            return comp;
        if (APIComparator.docChanged(doc_, oMethod.doc_))
            return -1;
        return 0;
    
public booleanequalSignatures(java.lang.Object o)
Tests two methods for equality, using just the signature.

        if (getSignature().compareTo(((MethodAPI)o).getSignature()) == 0)
            return true;
        return false;
    
public booleanequals(java.lang.Object o)
Tests two methods, using just the method name, used by indexOf().

        if (name_.compareTo(((MethodAPI)o).name_) == 0)
            return true;
        return false;
    
public java.lang.StringgetSignature()
Return the signature of the method.


           
       
        if (signature_ != null)
            return signature_;
        String res = "";
        boolean first = true;
        Iterator iter = params_.iterator();
        while (iter.hasNext()) {
            if (!first)
                res += ", ";
            ParamAPI param = (ParamAPI)(iter.next());
            res += param.toString();
            first = false;
        }
        signature_ = res;
        return res;