/**
  * Add use information to the documentation tree.
  *
  * @param mems list of program elements for which the use information will be added
  * @param heading the section heading
  * @param tableSummary the summary for the use table
  * @param contentTree the content tree to which the use information will be added
  */
 protected void addUseInfo(
     List<? extends ProgramElementDoc> mems,
     Content heading,
     String tableSummary,
     Content contentTree) {
   if (mems == null) {
     return;
   }
   List<? extends ProgramElementDoc> members = mems;
   boolean printedUseTableHeader = false;
   if (members.size() > 0) {
     Content caption = writer.getTableCaption(heading);
     Content table =
         (configuration.isOutputHtml5())
             ? HtmlTree.TABLE(HtmlStyle.useSummary, caption)
             : HtmlTree.TABLE(HtmlStyle.useSummary, tableSummary, caption);
     Content tbody = new HtmlTree(HtmlTag.TBODY);
     Iterator<? extends ProgramElementDoc> it = members.iterator();
     for (int i = 0; it.hasNext(); i++) {
       ProgramElementDoc pgmdoc = it.next();
       ClassDoc cd = pgmdoc.containingClass();
       if (!printedUseTableHeader) {
         table.addContent(writer.getSummaryTableHeader(this.getSummaryTableHeader(pgmdoc), "col"));
         printedUseTableHeader = true;
       }
       HtmlTree tr = new HtmlTree(HtmlTag.TR);
       if (i % 2 == 0) {
         tr.addStyle(HtmlStyle.altColor);
       } else {
         tr.addStyle(HtmlStyle.rowColor);
       }
       HtmlTree tdFirst = new HtmlTree(HtmlTag.TD);
       tdFirst.addStyle(HtmlStyle.colFirst);
       writer.addSummaryType(this, pgmdoc, tdFirst);
       tr.addContent(tdFirst);
       HtmlTree tdLast = new HtmlTree(HtmlTag.TD);
       tdLast.addStyle(HtmlStyle.colLast);
       if (cd != null && !(pgmdoc instanceof ConstructorDoc) && !(pgmdoc instanceof ClassDoc)) {
         HtmlTree name = new HtmlTree(HtmlTag.SPAN);
         name.addStyle(HtmlStyle.typeNameLabel);
         name.addContent(cd.name() + ".");
         tdLast.addContent(name);
       }
       addSummaryLink(
           pgmdoc instanceof ClassDoc ? LinkInfoImpl.Kind.CLASS_USE : LinkInfoImpl.Kind.MEMBER,
           cd,
           pgmdoc,
           tdLast);
       writer.addSummaryLinkComment(this, pgmdoc, tdLast);
       tr.addContent(tdLast);
       tbody.addContent(tr);
     }
     table.addContent(tbody);
     contentTree.addContent(table);
   }
 }
 /**
  * Add the line numbers for the source code.
  *
  * @param pre the content tree to which the line number will be added
  * @param lineno The line number
  */
 private static void addLineNo(Content pre, int lineno) {
   HtmlTree span = new HtmlTree(HtmlTag.SPAN);
   span.addStyle(HtmlStyle.sourceLineNo);
   if (lineno < 10) {
     span.addContent("00" + Integer.toString(lineno));
   } else if (lineno < 100) {
     span.addContent("0" + Integer.toString(lineno));
   } else {
     span.addContent(Integer.toString(lineno));
   }
   pre.addContent(span);
 }
 /**
  * Add the modifier and type for the member in the member summary.
  *
  * @param member the member to add the type for
  * @param type the type to add
  * @param tdSummaryType the content tree to which the modified and type will be added
  */
 protected void addModifierAndType(ProgramElementDoc member, Type type, Content tdSummaryType) {
   HtmlTree code = new HtmlTree(HtmlTag.CODE);
   addModifier(member, code);
   if (type == null) {
     if (member.isClass()) {
       code.addContent("class");
     } else {
       code.addContent("interface");
     }
     code.addContent(writer.getSpace());
   } else {
     if (member instanceof ExecutableMemberDoc
         && ((ExecutableMemberDoc) member).typeParameters().length > 0) {
       Content typeParameters =
           ((AbstractExecutableMemberWriter) this).getTypeParameters((ExecutableMemberDoc) member);
       code.addContent(typeParameters);
       // Code to avoid ugly wrapping in member summary table.
       if (typeParameters.charCount() > 10) {
         code.addContent(new HtmlTree(HtmlTag.BR));
       } else {
         code.addContent(writer.getSpace());
       }
       code.addContent(
           writer.getLink(
               new LinkInfoImpl(configuration, LinkInfoImpl.Kind.SUMMARY_RETURN_TYPE, type)));
     } else {
       code.addContent(
           writer.getLink(
               new LinkInfoImpl(configuration, LinkInfoImpl.Kind.SUMMARY_RETURN_TYPE, type)));
     }
   }
   tdSummaryType.addContent(code);
 }
 /**
  * Add the list of classes that use the given package.
  *
  * @param contentTree the content tree to which the class list will be added
  */
 protected void addClassList(Content contentTree) throws IOException {
   String[] classTableHeader =
       new String[] {
         configuration.getText(
             "doclet.0_and_1",
             configuration.getText("doclet.Class"),
             configuration.getText("doclet.Description"))
       };
   Iterator<String> itp = usingPackageToUsedClasses.keySet().iterator();
   while (itp.hasNext()) {
     String packageName = itp.next();
     PackageDoc usingPackage = configuration.root.packageNamed(packageName);
     HtmlTree li = new HtmlTree(HtmlTag.LI);
     li.addStyle(HtmlStyle.blockList);
     if (usingPackage != null) {
       li.addContent(getMarkerAnchor(usingPackage.name()));
     }
     String tableSummary =
         configuration.getText(
             "doclet.Use_Table_Summary", configuration.getText("doclet.classes"));
     Content table =
         HtmlTree.TABLE(
             HtmlStyle.useSummary,
             0,
             3,
             0,
             tableSummary,
             getTableCaption(
                 configuration.getResource(
                     "doclet.ClassUse_Classes.in.0.used.by.1",
                     getPackageLink(pkgdoc, Util.getPackageName(pkgdoc)),
                     getPackageLink(usingPackage, Util.getPackageName(usingPackage)))));
     table.addContent(getSummaryTableHeader(classTableHeader, "col"));
     Content tbody = new HtmlTree(HtmlTag.TBODY);
     Iterator<ClassDoc> itc = usingPackageToUsedClasses.get(packageName).iterator();
     for (int i = 0; itc.hasNext(); i++) {
       HtmlTree tr = new HtmlTree(HtmlTag.TR);
       if (i % 2 == 0) {
         tr.addStyle(HtmlStyle.altColor);
       } else {
         tr.addStyle(HtmlStyle.rowColor);
       }
       addClassRow(itc.next(), packageName, tr);
       tbody.addContent(tr);
     }
     table.addContent(tbody);
     li.addContent(table);
     contentTree.addContent(li);
   }
 }
 /**
  * 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);
 }
 /** Generate the class use list. */
 protected void generateClassUseFile() throws IOException {
   Content body = getClassUseHeader();
   HtmlTree div = new HtmlTree(HtmlTag.DIV);
   div.addStyle(HtmlStyle.classUseContainer);
   if (pkgSet.size() > 0) {
     addClassUse(div);
   } else {
     div.addContent(getResource("doclet.ClassUse_No.usage.of.0", classdoc.qualifiedName()));
   }
   body.addContent(div);
   addNavLinks(false, body);
   addBottom(body);
   printHtmlDocument(null, true, body);
 }
 /** Generate the package use list. */
 protected void generatePackageUseFile() throws IOException {
   Content body = getPackageUseHeader();
   HtmlTree div = new HtmlTree(HtmlTag.DIV);
   div.addStyle(HtmlStyle.contentContainer);
   if (usingPackageToUsedClasses.isEmpty()) {
     div.addContent(getResource("doclet.ClassUse_No.usage.of.0", pkgdoc.name()));
   } else {
     addPackageUse(div);
   }
   body.addContent(div);
   addNavLinks(false, body);
   addBottom(body);
   printHtmlDocument(null, true, body);
 }
 /**
  * Add the package use information.
  *
  * @param pkg the package that used the given package
  * @param contentTree the content tree to which the information will be added
  */
 protected void addPackageUse(PackageDoc pkg, Content contentTree) throws IOException {
   Content tdFirst =
       HtmlTree.TD(
           HtmlStyle.colFirst,
           getHyperLink(Util.getPackageName(pkg), new StringContent(Util.getPackageName(pkg))));
   contentTree.addContent(tdFirst);
   HtmlTree tdLast = new HtmlTree(HtmlTag.TD);
   tdLast.addStyle(HtmlStyle.colLast);
   if (pkg != null && pkg.name().length() != 0) {
     addSummaryComment(pkg, tdLast);
   } else {
     tdLast.addContent(getSpace());
   }
   contentTree.addContent(tdLast);
 }
 /**
  * Add the class list that use the given class.
  *
  * @param contentTree the content tree to which the class list will be added
  */
 protected void addClassList(Content contentTree) throws IOException {
   HtmlTree ul = new HtmlTree(HtmlTag.UL);
   ul.addStyle(HtmlStyle.blockList);
   for (PackageDoc pkg : pkgSet) {
     Content li = HtmlTree.LI(HtmlStyle.blockList, getMarkerAnchor(pkg.name()));
     Content link =
         getResource(
             "doclet.ClassUse_Uses.of.0.in.1",
             getLink(
                 new LinkInfoImpl(configuration, LinkInfoImpl.Kind.CLASS_USE_HEADER, classdoc)),
             getPackageLink(pkg, Util.getPackageName(pkg)));
     Content heading = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING, link);
     li.addContent(heading);
     addClassUse(pkg, li);
     ul.addContent(li);
   }
   Content li = HtmlTree.LI(HtmlStyle.blockList, ul);
   contentTree.addContent(li);
 }
 /**
  * Add the member summary for the given class.
  *
  * @param classDoc the class that is being documented
  * @param member the member being documented
  * @param firstSentenceTags the first sentence tags to be added to the summary
  * @param tableContents the list of contents to which the documentation will be added
  * @param counter the counter for determining id and style for the table row
  */
 public void addMemberSummary(
     ClassDoc classDoc,
     ProgramElementDoc member,
     Tag[] firstSentenceTags,
     List<Content> tableContents,
     int counter) {
   HtmlTree tdSummaryType = new HtmlTree(HtmlTag.TD);
   tdSummaryType.addStyle(HtmlStyle.colFirst);
   writer.addSummaryType(this, member, tdSummaryType);
   HtmlTree tdSummary = new HtmlTree(HtmlTag.TD);
   setSummaryColumnStyle(tdSummary);
   addSummaryLink(classDoc, member, tdSummary);
   writer.addSummaryLinkComment(this, member, firstSentenceTags, tdSummary);
   HtmlTree tr = HtmlTree.TR(tdSummaryType);
   tr.addContent(tdSummary);
   if (member instanceof MethodDoc && !member.isAnnotationTypeElement()) {
     int methodType =
         (member.isStatic()) ? MethodTypes.STATIC.value() : MethodTypes.INSTANCE.value();
     if (member.containingClass().isInterface()) {
       methodType =
           (((MethodDoc) member).isAbstract())
               ? methodType | MethodTypes.ABSTRACT.value()
               : methodType | MethodTypes.DEFAULT.value();
     } else {
       methodType =
           (((MethodDoc) member).isAbstract())
               ? methodType | MethodTypes.ABSTRACT.value()
               : methodType | MethodTypes.CONCRETE.value();
     }
     if (utils.isDeprecated(member) || utils.isDeprecated(classdoc)) {
       methodType = methodType | MethodTypes.DEPRECATED.value();
     }
     methodTypesOr = methodTypesOr | methodType;
     String tableId = "i" + counter;
     typeMap.put(tableId, methodType);
     tr.addAttr(HtmlAttr.ID, tableId);
   }
   if (counter % 2 == 0) tr.addStyle(HtmlStyle.altColor);
   else tr.addStyle(HtmlStyle.rowColor);
   tableContents.add(tr);
 }