Example #1
0
 /**
  * Adjust the Class Tree. Add the class interface in to it's super-class' or super-interface's
  * sub-interface list.
  *
  * @param map the entire map.
  * @param superclass java.lang.Object or the super-interface.
  * @param cd sub-interface to be mapped.
  * @returns boolean true if class added, false if class already processed.
  */
 private boolean add(Map map, ClassDoc superclass, ClassDoc cd) {
   List list = (List) map.get(superclass);
   if (list == null) {
     list = new ArrayList();
     map.put(superclass, list);
   }
   if (list.contains(cd)) {
     return false;
   } else {
     list.add(cd);
   }
   return true;
 }
Example #2
0
 /**
  * Return a list of all direct or indirect, sub-classes and subinterfaces of the ClassDoc
  * argument.
  *
  * @param cd ClassDoc whose sub-classes or sub-interfaces are requested.
  * @param isEnum true if the subclasses should be forced to come from the enum tree.
  */
 public List allSubs(ClassDoc cd, boolean isEnum) {
   List list = subs(cd, isEnum);
   for (int i = 0; i < list.size(); i++) {
     cd = (ClassDoc) list.get(i);
     List tlist = subs(cd, isEnum);
     for (int j = 0; j < tlist.size(); j++) {
       ClassDoc tcd = (ClassDoc) tlist.get(j);
       if (!list.contains(tcd)) {
         list.add(tcd);
       }
     }
   }
   Collections.sort(list);
   return list;
 }
Example #3
0
 /**
  * For the interface passed get the interfaces which it extends, and then put this interface in
  * the sub-interface list of those interfaces. Do it recursively. If a interface doesn't have
  * super-interface just attach that interface in the list of all the baseinterfaces.
  *
  * @param cd Interface under consideration.
  */
 private void processInterface(ClassDoc cd) {
   ClassDoc[] intfacs = cd.interfaces();
   if (intfacs.length > 0) {
     for (int i = 0; i < intfacs.length; i++) {
       if (!add(subinterfaces, intfacs[i], cd)) {
         return;
       } else {
         processInterface(intfacs[i]); // Recurse
       }
     }
   } else {
     // we need to add all the interfaces who do not have
     // super-interfaces to baseinterfaces list to traverse them
     if (!baseinterfaces.contains(cd)) {
       baseinterfaces.add(cd);
     }
   }
 }
Example #4
0
 /**
  * For the class passed map it to it's own sub-class listing. For the Class passed, get the super
  * class, if superclass is non null, (it is not "java.lang.Object") get the "value" from the
  * hashmap for this key Class if entry not found create one and get that. add this Class as a sub
  * class in the list Recurse till hits java.lang.Object Null SuperClass.
  *
  * @param cd class for which sub-class mapping to be generated.
  * @param configuration the current configurtation of the doclet.
  */
 private void processType(ClassDoc cd, Configuration configuration, List bases, Map subs) {
   ClassDoc superclass = Util.getFirstVisibleSuperClassCD(cd, configuration);
   if (superclass != null) {
     if (!add(subs, superclass, cd)) {
       return;
     } else {
       processType(superclass, configuration, bases, subs);
     }
   } else { // cd is java.lang.Object, add it once to the list
     if (!bases.contains(cd)) {
       bases.add(cd);
     }
   }
   List intfacs = Util.getAllInterfaces(cd, configuration);
   for (Iterator iter = intfacs.iterator(); iter.hasNext(); ) {
     add(implementingclasses, ((Type) iter.next()).asClassDoc(), cd);
   }
 }
Example #5
0
  /**
   * Return the list of classes which implement the interface passed.
   *
   * @param cd interface whose implementing-classes list is required.
   */
  public List implementingclasses(ClassDoc cd) {
    List result = get(implementingclasses, cd);
    List subinterfaces = allSubs(cd, false);

    // If class x implements a subinterface of cd, then it follows
    // that class x implements cd.
    Iterator implementingClassesIter, subInterfacesIter = subinterfaces.listIterator();
    ClassDoc c;
    while (subInterfacesIter.hasNext()) {
      implementingClassesIter =
          implementingclasses((ClassDoc) subInterfacesIter.next()).listIterator();
      while (implementingClassesIter.hasNext()) {
        c = (ClassDoc) implementingClassesIter.next();
        if (!result.contains(c)) {
          result.add(c);
        }
      }
    }
    Collections.sort(result);
    return result;
  }