/**
  * Build the sorted list of all the deprecated APIs in this run. Build separate lists for
  * deprecated packages, classes, constructors, methods and fields.
  *
  * @param configuration the current configuration of the doclet.
  */
 private void buildDeprecatedAPIInfo(Configuration configuration) {
   PackageDoc[] packages = configuration.packages;
   PackageDoc pkg;
   for (int c = 0; c < packages.length; c++) {
     pkg = packages[c];
     if (Util.isDeprecated(pkg)) {
       getList(PACKAGE).add(pkg);
     }
   }
   ClassDoc[] classes = configuration.root.classes();
   for (int i = 0; i < classes.length; i++) {
     ClassDoc cd = classes[i];
     if (Util.isDeprecated(cd)) {
       if (cd.isOrdinaryClass()) {
         getList(CLASS).add(cd);
       } else if (cd.isInterface()) {
         getList(INTERFACE).add(cd);
       } else if (cd.isException()) {
         getList(EXCEPTION).add(cd);
       } else if (cd.isEnum()) {
         getList(ENUM).add(cd);
       } else if (cd.isError()) {
         getList(ERROR).add(cd);
       } else if (cd.isAnnotationType()) {
         getList(ANNOTATION_TYPE).add(cd);
       }
     }
     composeDeprecatedList(getList(FIELD), cd.fields());
     composeDeprecatedList(getList(METHOD), cd.methods());
     composeDeprecatedList(getList(CONSTRUCTOR), cd.constructors());
     if (cd.isEnum()) {
       composeDeprecatedList(getList(ENUM_CONSTANT), cd.enumConstants());
     }
     if (cd.isAnnotationType()) {
       composeDeprecatedList(getList(ANNOTATION_TYPE_MEMBER), ((AnnotationTypeDoc) cd).elements());
     }
   }
   sortDeprecatedLists();
 }
Esempio n. 2
0
 /**
  * Given a ClassDoc, return the name of its type (Class, Interface, etc.).
  *
  * @param cd the ClassDoc to check.
  * @param lowerCaseOnly true if you want the name returned in lower case. If false, the first
  *     letter of the name is capatilized.
  * @return
  */
 public static String getTypeName(Configuration config, ClassDoc cd, boolean lowerCaseOnly) {
   String typeName = "";
   if (cd.isOrdinaryClass()) {
     typeName = "doclet.Class";
   } else if (cd.isInterface()) {
     typeName = "doclet.Interface";
   } else if (cd.isException()) {
     typeName = "doclet.Exception";
   } else if (cd.isError()) {
     typeName = "doclet.Error";
   } else if (cd.isAnnotationType()) {
     typeName = "doclet.AnnotationType";
   } else if (cd.isEnum()) {
     typeName = "doclet.Enum";
   }
   return config.getText(lowerCaseOnly ? typeName.toLowerCase() : typeName);
 }
 /**
  * Add the given class to the catalog.
  *
  * @param classdoc the ClassDoc to add to the catelog.
  */
 public void addClassDoc(ClassDoc classdoc) {
   if (classdoc == null) {
     return;
   }
   addClass(classdoc, allClasses);
   if (classdoc.isOrdinaryClass()) {
     addClass(classdoc, ordinaryClasses);
   } else if (classdoc.isException()) {
     addClass(classdoc, exceptions);
   } else if (classdoc.isEnum()) {
     addClass(classdoc, enums);
   } else if (classdoc.isAnnotationType()) {
     addClass(classdoc, annotationTypes);
   } else if (classdoc.isError()) {
     addClass(classdoc, errors);
   } else if (classdoc.isInterface()) {
     addClass(classdoc, interfaces);
   }
 }
 /**
  * Return true if the given ClassDoc should be included in the serialized form.
  *
  * @param cd the ClassDoc object to check for serializability.
  */
 private static boolean serialClassInclude(ClassDoc cd) {
   if (cd.isEnum()) {
     return false;
   }
   try {
     cd.superclassType();
   } catch (NullPointerException e) {
     // Workaround for null pointer bug in ClassDoc.superclassType().
     return false;
   }
   if (cd.isSerializable()) {
     if (cd.tags("serial").length > 0) {
       return serialDocInclude(cd);
     } else if (cd.isPublic() || cd.isProtected()) {
       return true;
     } else {
       return false;
     }
   }
   return false;
 }
  /**
   * The entry point into the Parser class.
   *
   * @param root A RootDoc intstance obtained via the doclet API
   * @return A XML (XStream) serializable element, containing everything parsed from javadoc doclet
   */
  public static Root ParseRoot(RootDoc root) {
    processingStorage = new HashMap<PackageDoc, ParserMediary>();

    try {
      md5 = MessageDigest.getInstance("MD5");
    } catch (NoSuchAlgorithmException e) {
      log.error("unable to acquire MD5 algorithm", e);
      return null;
    }

    rootXml = new Root();

    ClassDoc[] allClasses = root.classes();

    for (ClassDoc classDoc : allClasses) {
      PackageDoc doc = classDoc.containingPackage();

      ParserMediary mediary = null;

      // the age old 'if I have it pull out existing, if I don't make a new one'
      if (processingStorage.containsKey(doc)) {
        mediary = processingStorage.get(doc);
      } else {
        mediary =
            new ParserMediary(
                doc.name(),
                doc.commentText(),
                ParseAnnotationInstances(doc.annotations(), doc.name()));

        processingStorage.put(doc, mediary);
      }

      if (classDoc.isIncluded()) {
        // dev comment--why do enums show up as ordinary class?
        if (classDoc.isOrdinaryClass() || classDoc.isException() || classDoc.isError()) {
          mediary.addClass(ParseClass(classDoc));
        } else if (classDoc.isEnum()) {
          mediary.addEnum(ParseEnum(classDoc));
        } else if (isAnnotation(classDoc)) {
          mediary.addAnnotation(ParseAnnotation(classDoc));
        } else if (classDoc.isInterface()) {
          mediary.addInterface(ParseInterface(classDoc));
        }
      } else {
        log.debug("Skipping not-included class " + classDoc.qualifiedName());
      }
    }

    if (processingStorage.size() > 0) {
      List list = new ArrayList<Package>();

      for (ParserMediary mediary : processingStorage.values()) {
        list.add(mediary.wrapup());
      }

      rootXml.packages = (Package[]) list.toArray(new Package[] {});
    } else {
      log.warn("No packages found!");
    }

    return rootXml;
  }