FileDocCategorySizeDatePackage
ImplementedMethods.javaAPI DocExample3891Wed Apr 19 11:17:18 BST 2000com.sun.tools.doclets

ImplementedMethods

public class ImplementedMethods extends Object
For a given class method, build an array of interface methods which it implements.
author
Atul M Dambalkar

Fields Summary
private List
methlist
private final ClassDoc
classdoc
private final MethodDoc
method
Constructors Summary
public ImplementedMethods(MethodDoc method)


       
        this.method = method;
        classdoc = method.containingClass(); 
    
Methods Summary
public com.sun.javadoc.MethodDoc[]build()
Return the array of interface methods which the method passed in the constructor is implementing. The search/build order is as follows:
1. Search in all the immediate interfaces which this method's class is
implementing. Do it recursively for the superinterfaces as well.
2. Traverse all the superclasses and search recursively in the
interfaces which those superclasses implement.

return
MethodDoc[] Array of implemented methods.

        ClassDoc icd = classdoc;
        while (icd != null) {
            buildImplementedMethodList(icd.interfaces());
            icd = icd.superclass();
        }
        return (MethodDoc[])methlist.toArray(new MethodDoc[methlist.size()]);
    
private voidbuildImplementedMethodList(com.sun.javadoc.ClassDoc[] intfacs)
Search the method in the array of interfaces. If found check if it is not overridden by any other subinterface method which this class implements. If it is not overidden, add it in the method list. Do it recursively for all the extended interfaces for each interface from the array passed.

        for (int i = 0; i < intfacs.length; i++) {
            MethodDoc found = Util.findMethod(intfacs[i], method);
            if (found != null) {
  	        removeOverriddenMethod(found);
  	        if (!overriddingMethodFound(found)) {
                    methlist.add(method);
                }   
            }
            ClassDoc[] iin = intfacs[i].interfaces();
            buildImplementedMethodList(iin);
        }
    
private booleanoverriddingMethodFound(com.sun.javadoc.MethodDoc method)
Search in the already found methods' list if it contains a method which is overridding the method as parameter or this method itself.

param
method Is this method overridden by a method in the method list.

        ClassDoc containingClass = method.containingClass();
	for (int i = 0; i < methlist.size(); i++) {
            ClassDoc cd = ((MethodDoc)methlist.get(i)).overriddenClass();
            if (cd == containingClass || cd.subclassOf(containingClass)) {
                return true;
            }
        }
        return false;
    
private voidremoveOverriddenMethod(com.sun.javadoc.MethodDoc method)
Search in the already found methods' list if it contains a method which is overridden by the method as parameter, remove the overridden method from the method list.

param
method Is this method overridding a method in the method list.

        ClassDoc overriddenClass = method.overriddenClass();  
        if (overriddenClass != null) {
            for (int i = 0; i < methlist.size(); i++) {
                ClassDoc cd = ((MethodDoc)methlist.get(i)).containingClass();
	        if (cd == overriddenClass || overriddenClass.subclassOf(cd)) {
	            methlist.remove(i);  // remove overridden method
                    return;
                }
            } 
        }