Esempio n. 1
0
  /**
   * Generate mapping for the sub-classes for every class in this run. Return the sub-class list for
   * java.lang.Object which will be having sub-class listing for itself and also for each sub-class
   * itself will have their own sub-class lists.
   *
   * @param classes all the classes in this run.
   * @param configuration the current configuration of the doclet.
   */
  private void buildTree(ClassDoc[] classes, Configuration configuration) {
    log.info("ClassTree buildTree");
    for (int i = 0; i < classes.length; i++) {
      if (configuration.nodeprecated && classes[i].tags("deprecated").length > 0) {
        continue;
      }
      if (classes[i].isEnum()) {
        processType(classes[i], configuration, baseEnums, subEnums);
      } else if (classes[i].isClass()) {
        processType(classes[i], configuration, baseclasses, subclasses);
      } else if (classes[i].isInterface()) {
        processInterface(classes[i]);
        List list = (List) implementingclasses.get(classes[i]);
        if (list != null) {
          Collections.sort(list);
        }
      } else if (classes[i].isAnnotationType()) {
        processType(classes[i], configuration, baseAnnotationTypes, subAnnotationTypes);
      }
    }

    Collections.sort(baseinterfaces);
    for (Iterator it = subinterfaces.values().iterator(); it.hasNext(); ) {
      Collections.sort((List) it.next());
    }
    for (Iterator it = subclasses.values().iterator(); it.hasNext(); ) {
      Collections.sort((List) it.next());
    }
  }
 public String[] getGroupRoutes(String group) {
   LinkedHashSet<String> routes = new LinkedHashSet<String>();
   for (ApiDoc apiDoc : docs) {
     if (StringUtils.equals(group, apiDoc.group)) Collections.addAll(routes, apiDoc.routes);
   }
   return routes.toArray(new String[routes.size()]);
 }
Esempio n. 3
0
 /**
  * Construct a new MethodBuilder.
  *
  * @param context the build context.
  * @param classDoc the class whoses members are being documented.
  * @param writer the doclet specific writer.
  */
 private MethodBuilder(Context context, ClassDoc classDoc, MethodWriter writer) {
   super(context);
   this.classDoc = classDoc;
   this.writer = writer;
   visibleMemberMap = new VisibleMemberMap(classDoc, VisibleMemberMap.METHODS, configuration);
   methods = new ArrayList<>(visibleMemberMap.getLeafClassMembers(configuration));
   if (configuration.getMemberComparator() != null) {
     Collections.sort(methods, configuration.getMemberComparator());
   }
 }
Esempio n. 4
0
 /**
  * Return array of class members whose documentation is to be generated. If the member is
  * deprecated do not include such a member in the returned array.
  *
  * @param members Array of members to choose from.
  * @return List List of eligible members for whom documentation is getting generated.
  */
 public static List excludeDeprecatedMembersAsList(ProgramElementDoc[] members) {
   List list = new ArrayList();
   for (int i = 0; i < members.length; i++) {
     if (members[i].tags("deprecated").length == 0) {
       list.add(members[i]);
     }
   }
   Collections.sort(list);
   return list;
 }
 public Map<String, String[]> getGroups() {
   LinkedHashMap<String, List<String>> m = new LinkedHashMap<String, List<String>>();
   for (ApiDoc apiDoc : docs) {
     List<String> l = m.get(apiDoc.group);
     if (l == null) {
       l = new ArrayList<String>();
       m.put(apiDoc.group, l);
     }
     Collections.addAll(l, apiDoc.routes);
   }
   return CollectionsHelper.listMapToArrayMap(m, String.class);
 }
Esempio n. 6
0
 /**
  * Construct a new EnumConstantsBuilder.
  *
  * @param configuration the current configuration of the doclet.
  * @param classDoc the class whoses members are being documented.
  * @param writer the doclet specific writer.
  */
 public static EnumConstantBuilder getInstance(
     Configuration configuration, ClassDoc classDoc, EnumConstantWriter writer) {
   EnumConstantBuilder builder = new EnumConstantBuilder(configuration);
   builder.classDoc = classDoc;
   builder.writer = writer;
   builder.visibleMemberMap =
       new VisibleMemberMap(classDoc, VisibleMemberMap.ENUM_CONSTANTS, configuration.nodeprecated);
   builder.enumConstants =
       new ArrayList<ProgramElementDoc>(builder.visibleMemberMap.getMembersFor(classDoc));
   if (configuration.getMemberComparator() != null) {
     Collections.sort(builder.enumConstants, configuration.getMemberComparator());
   }
   return builder;
 }
Esempio n. 7
0
 /**
  * Construct a new FieldBuilder.
  *
  * @param configuration the current configuration of the doclet.
  * @param classDoc the class whoses members are being documented.
  * @param writer the doclet specific writer.
  */
 public static FieldBuilder getInstance(
     Configuration configuration, ClassDoc classDoc, FieldWriter writer) {
   FieldBuilder builder = new FieldBuilder(configuration);
   builder.classDoc = classDoc;
   builder.writer = writer;
   builder.visibleMemberMap =
       new VisibleMemberMap(classDoc, VisibleMemberMap.FIELDS, configuration.nodeprecated);
   builder.fields =
       new ArrayList<ProgramElementDoc>(
           builder.visibleMemberMap.getLeafClassMembers(configuration));
   if (configuration.getMemberComparator() != null) {
     Collections.sort(builder.fields, configuration.getMemberComparator());
   }
   return builder;
 }
Esempio n. 8
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;
 }
Esempio n. 9
0
  /**
   * For the class return all implemented interfaces including the superinterfaces of the
   * implementing interfaces, also iterate over for all the superclasses. For interface return all
   * the extended interfaces as well as superinterfaces for those extended interfaces.
   *
   * @param type type whose implemented or super interfaces are sought.
   * @param configuration the current configuration of the doclet.
   * @param sort if true, return list of interfaces sorted alphabetically.
   * @return List of all the required interfaces.
   */
  public static List<Type> getAllInterfaces(Type type, Configuration configuration, boolean sort) {
    Map<ClassDoc, Type> results =
        sort ? new TreeMap<ClassDoc, Type>() : new LinkedHashMap<ClassDoc, Type>();
    Type[] interfaceTypes = null;
    Type superType = null;
    if (type instanceof ParameterizedType) {
      interfaceTypes = ((ParameterizedType) type).interfaceTypes();
      superType = ((ParameterizedType) type).superclassType();
    } else if (type instanceof ClassDoc) {
      interfaceTypes = ((ClassDoc) type).interfaceTypes();
      superType = ((ClassDoc) type).superclassType();
    } else {
      interfaceTypes = type.asClassDoc().interfaceTypes();
      superType = type.asClassDoc().superclassType();
    }

    for (int i = 0; i < interfaceTypes.length; i++) {
      Type interfaceType = interfaceTypes[i];
      ClassDoc interfaceClassDoc = interfaceType.asClassDoc();
      if (!(interfaceClassDoc.isPublic()
          || (configuration == null || isLinkable(interfaceClassDoc, configuration)))) {
        continue;
      }
      results.put(interfaceClassDoc, interfaceType);
      List<Type> superInterfaces = getAllInterfaces(interfaceType, configuration, sort);
      for (Iterator<Type> iter = superInterfaces.iterator(); iter.hasNext(); ) {
        Type t = iter.next();
        results.put(t.asClassDoc(), t);
      }
    }
    if (superType == null) return new ArrayList<Type>(results.values());
    // Try walking the tree.
    addAllInterfaceTypes(
        results,
        superType,
        superType instanceof ClassDoc
            ? ((ClassDoc) superType).interfaceTypes()
            : ((ParameterizedType) superType).interfaceTypes(),
        false,
        configuration);
    List<Type> resultsList = new ArrayList<Type>(results.values());
    if (sort) {
      Collections.sort(resultsList, new TypeComparator());
    }
    return resultsList;
  }
Esempio n. 10
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;
  }
Esempio n. 11
0
  /**
   * Process each package and the classes/interfaces within it.
   *
   * @param pd an array of PackageDoc objects
   */
  public void processPackages(RootDoc root) {
    PackageDoc[] specified_pd = root.specifiedPackages();
    Map pdl = new TreeMap();
    for (int i = 0; specified_pd != null && i < specified_pd.length; i++) {
      pdl.put(specified_pd[i].name(), specified_pd[i]);
    }

    // Classes may be specified separately, so merge their packages into the
    // list of specified packages.
    ClassDoc[] cd = root.specifiedClasses();
    // This is lists of the specific classes to document
    Map classesToUse = new HashMap();
    for (int i = 0; cd != null && i < cd.length; i++) {
      PackageDoc cpd = cd[i].containingPackage();
      if (cpd == null && !packagesOnly) {
        // If the RootDoc object has been created from a jar file
        // this duplicates classes, so we have to be able to disable it.
        // TODO this is still null?
        cpd = root.packageNamed("anonymous");
      }
      String pkgName = cpd.name();
      String className = cd[i].name();
      if (trace) System.out.println("Found package " + pkgName + " for class " + className);
      if (!pdl.containsKey(pkgName)) {
        if (trace) System.out.println("Adding new package " + pkgName);
        pdl.put(pkgName, cpd);
      }

      // Keep track of the specific classes to be used for this package
      List classes;
      if (classesToUse.containsKey(pkgName)) {
        classes = (ArrayList) classesToUse.get(pkgName);
      } else {
        classes = new ArrayList();
      }
      classes.add(cd[i]);
      classesToUse.put(pkgName, classes);
    }

    PackageDoc[] pd = (PackageDoc[]) pdl.values().toArray(new PackageDoc[0]);
    for (int i = 0; pd != null && i < pd.length; i++) {
      String pkgName = pd[i].name();

      // Check for an exclude tag in the package doc block, but not
      // in the package.htm[l] file.
      if (!shownElement(pd[i], null)) continue;

      if (trace) System.out.println("PROCESSING PACKAGE: " + pkgName);
      outputFile.println("<package name=\"" + pkgName + "\">");

      int tagCount = pd[i].tags().length;
      if (trace) System.out.println("#tags: " + tagCount);

      List classList;
      if (classesToUse.containsKey(pkgName)) {
        // Use only the specified classes in the package
        System.out.println("Using the specified classes");
        classList = (ArrayList) classesToUse.get(pkgName);
      } else {
        // Use all classes in the package
        classList = new LinkedList(Arrays.asList(pd[i].allClasses()));
      }
      Collections.sort(classList);
      ClassDoc[] classes = new ClassDoc[classList.size()];
      classes = (ClassDoc[]) classList.toArray(classes);
      processClasses(classes, pkgName);

      addPkgDocumentation(root, pd[i], 2);

      outputFile.println("</package>");
    }
  } // processPackages
 /** Sort the deprecated lists for class kinds, fields, methods and constructors. */
 private void sortDeprecatedLists() {
   for (int i = 0; i < NUM_TYPES; i++) {
     Collections.sort(getList(i));
   }
 }