Ejemplo n.º 1
0
 /**
  * Return the sub-class/interface list for the class/interface passed.
  *
  * @param cd class/interface whose sub-class/interface list is required.
  * @param isEnum true if the subclasses should be forced to come from the enum tree.
  */
 public List subs(ClassDoc cd, boolean isEnum) {
   if (isEnum) {
     return get(subEnums, cd);
   } else if (cd.isAnnotationType()) {
     return get(subAnnotationTypes, cd);
   } else if (cd.isInterface()) {
     return get(subinterfaces, cd);
   } else if (cd.isClass()) {
     return get(subclasses, cd);
   } else {
     return null;
   }
 }
Ejemplo n.º 2
0
 /**
  * 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();
 }
Ejemplo n.º 3
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 package annotation list.
  *
  * @param contentTree the content tree to which the package annotation list will be added
  */
 protected void addPackageAnnotationList(Content contentTree) throws IOException {
   if ((!classdoc.isAnnotationType())
       || pkgToPackageAnnotations == null
       || pkgToPackageAnnotations.isEmpty()) {
     return;
   }
   Content table =
       HtmlTree.TABLE(
           HtmlStyle.useSummary,
           0,
           3,
           0,
           useTableSummary,
           getTableCaption(
               configuration.getResource(
                   "doclet.ClassUse_PackageAnnotation",
                   getLink(
                       new LinkInfoImpl(
                           configuration, LinkInfoImpl.Kind.CLASS_USE_HEADER, classdoc)))));
   table.addContent(getSummaryTableHeader(packageTableHeader, "col"));
   Content tbody = new HtmlTree(HtmlTag.TBODY);
   Iterator<PackageDoc> it = pkgToPackageAnnotations.iterator();
   for (int i = 0; it.hasNext(); i++) {
     PackageDoc pkg = it.next();
     HtmlTree tr = new HtmlTree(HtmlTag.TR);
     if (i % 2 == 0) {
       tr.addStyle(HtmlStyle.altColor);
     } else {
       tr.addStyle(HtmlStyle.rowColor);
     }
     Content tdFirst =
         HtmlTree.TD(HtmlStyle.colFirst, getPackageLink(pkg, new StringContent(pkg.name())));
     tr.addContent(tdFirst);
     HtmlTree tdLast = new HtmlTree(HtmlTag.TD);
     tdLast.addStyle(HtmlStyle.colLast);
     addSummaryComment(pkg, tdLast);
     tr.addContent(tdLast);
     tbody.addContent(tr);
   }
   table.addContent(tbody);
   Content li = HtmlTree.LI(HtmlStyle.blockList, table);
   contentTree.addContent(li);
 }
Ejemplo n.º 5
0
 /**
  * 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);
   }
 }
Ejemplo n.º 6
0
  public static boolean start(RootDoc root) {
    try {
      init(root);
      ClassDoc[] classes = root.classes();
      ArrayList<String> generatesTestClasses = new ArrayList<String>();
      for (int i = 0; i < classes.length; i++) {
        ClassDoc classDoc = classes[i];
        if (classDoc.isAbstract()
            || classDoc.isInterface()
            || classDoc.isEnum()
            || classDoc.isPrivate()
            || classDoc.isAnnotationType()) {
        } else if (!hasDefaultConstructor(classDoc)) {
          System.out.println(classDoc.qualifiedTypeName() + " does not have default Constructor.");
        } else {
          ClassBean testClassBean = ClassBeanCreator.create(classDoc);
          if (testClassBean.hasMethods()) {
            JavaCodeWriter writer = getWriter(testClassBean);
            if (writer != null) {
              JavaCodeGenerator.generate(testClassBean, writer);
              generatesTestClasses.add(classDoc.qualifiedTypeName());
              writer.close();
            }
          } else {
            System.out.println(
                classDoc.qualifiedTypeName() + " does not have any methods to cover.");
          }
        }
      }
      System.out.println("---------REPORT-----------------------------------------------");
      for (Iterator iterator = generatesTestClasses.iterator(); iterator.hasNext(); ) {
        String clsName = (String) iterator.next();
        System.out.println("\t" + clsName);
      }
      System.out.println("-------------------------------------------------------------");

      return true;
    } catch (Exception e) {
      e.printStackTrace();
      return false;
    }
  }