aoqi@0: /*
aoqi@0: * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
aoqi@0: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0: *
aoqi@0: * This code is free software; you can redistribute it and/or modify it
aoqi@0: * under the terms of the GNU General Public License version 2 only, as
aoqi@0: * published by the Free Software Foundation. Oracle designates this
aoqi@0: * particular file as subject to the "Classpath" exception as provided
aoqi@0: * by Oracle in the LICENSE file that accompanied this code.
aoqi@0: *
aoqi@0: * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0: * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0: * accompanied this code).
aoqi@0: *
aoqi@0: * You should have received a copy of the GNU General Public License version
aoqi@0: * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0: *
aoqi@0: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0: * or visit www.oracle.com if you need additional information or have any
aoqi@0: * questions.
aoqi@0: */
aoqi@0:
aoqi@0: package com.sun.tools.doclets.formats.html;
aoqi@0:
aoqi@0: import java.lang.reflect.Modifier;
aoqi@0: import java.util.*;
aoqi@0:
aoqi@0: import com.sun.javadoc.*;
aoqi@0: import com.sun.tools.doclets.formats.html.markup.*;
aoqi@0: import com.sun.tools.doclets.internal.toolkit.*;
aoqi@0: import com.sun.tools.doclets.internal.toolkit.taglets.*;
aoqi@0: import com.sun.tools.doclets.internal.toolkit.util.*;
aoqi@0:
aoqi@0: /**
aoqi@0: * The base class for member writers.
aoqi@0: *
aoqi@0: *
This is NOT part of any supported API.
aoqi@0: * If you write code that depends on this, you do so at your own risk.
aoqi@0: * This code and its internal interfaces are subject to change or
aoqi@0: * deletion without notice.
aoqi@0: *
aoqi@0: * @author Robert Field
aoqi@0: * @author Atul M Dambalkar
aoqi@0: * @author Jamie Ho (Re-write)
aoqi@0: * @author Bhavesh Patel (Modified)
aoqi@0: */
aoqi@0: public abstract class AbstractMemberWriter {
aoqi@0:
aoqi@0: protected final ConfigurationImpl configuration;
aoqi@0: protected final SubWriterHolderWriter writer;
aoqi@0: protected final ClassDoc classdoc;
aoqi@0: protected Map typeMap = new LinkedHashMap();
aoqi@0: protected Set methodTypes = EnumSet.noneOf(MethodTypes.class);
aoqi@0: private int methodTypesOr = 0;
aoqi@0: public final boolean nodepr;
aoqi@0:
aoqi@0: protected boolean printedSummaryHeader = false;
aoqi@0:
aoqi@0: public AbstractMemberWriter(SubWriterHolderWriter writer, ClassDoc classdoc) {
aoqi@0: this.configuration = writer.configuration;
aoqi@0: this.writer = writer;
aoqi@0: this.nodepr = configuration.nodeprecated;
aoqi@0: this.classdoc = classdoc;
aoqi@0: }
aoqi@0:
aoqi@0: public AbstractMemberWriter(SubWriterHolderWriter writer) {
aoqi@0: this(writer, null);
aoqi@0: }
aoqi@0:
aoqi@0: /*** abstracts ***/
aoqi@0:
aoqi@0: /**
aoqi@0: * Add the summary label for the member.
aoqi@0: *
aoqi@0: * @param memberTree the content tree to which the label will be added
aoqi@0: */
aoqi@0: public abstract void addSummaryLabel(Content memberTree);
aoqi@0:
aoqi@0: /**
aoqi@0: * Get the summary for the member summary table.
aoqi@0: *
aoqi@0: * @return a string for the table summary
aoqi@0: */
aoqi@0: public abstract String getTableSummary();
aoqi@0:
aoqi@0: /**
aoqi@0: * Get the caption for the member summary table.
aoqi@0: *
aoqi@0: * @return a string for the table caption
aoqi@0: */
aoqi@0: public abstract Content getCaption();
aoqi@0:
aoqi@0: /**
aoqi@0: * Get the summary table header for the member.
aoqi@0: *
aoqi@0: * @param member the member to be documented
aoqi@0: * @return the summary table header
aoqi@0: */
aoqi@0: public abstract String[] getSummaryTableHeader(ProgramElementDoc member);
aoqi@0:
aoqi@0: /**
aoqi@0: * Add inherited summary lable for the member.
aoqi@0: *
aoqi@0: * @param cd the class doc to which to link to
aoqi@0: * @param inheritedTree the content tree to which the inherited summary label will be added
aoqi@0: */
aoqi@0: public abstract void addInheritedSummaryLabel(ClassDoc cd, Content inheritedTree);
aoqi@0:
aoqi@0: /**
aoqi@0: * Add the anchor for the summary section of the member.
aoqi@0: *
aoqi@0: * @param cd the class doc to be documented
aoqi@0: * @param memberTree the content tree to which the summary anchor will be added
aoqi@0: */
aoqi@0: public abstract void addSummaryAnchor(ClassDoc cd, Content memberTree);
aoqi@0:
aoqi@0: /**
aoqi@0: * Add the anchor for the inherited summary section of the member.
aoqi@0: *
aoqi@0: * @param cd the class doc to be documented
aoqi@0: * @param inheritedTree the content tree to which the inherited summary anchor will be added
aoqi@0: */
aoqi@0: public abstract void addInheritedSummaryAnchor(ClassDoc cd, Content inheritedTree);
aoqi@0:
aoqi@0: /**
aoqi@0: * Add the summary type for the member.
aoqi@0: *
aoqi@0: * @param member the member to be documented
aoqi@0: * @param tdSummaryType the content tree to which the type will be added
aoqi@0: */
aoqi@0: protected abstract void addSummaryType(ProgramElementDoc member,
aoqi@0: Content tdSummaryType);
aoqi@0:
aoqi@0: /**
aoqi@0: * Add the summary link for the member.
aoqi@0: *
aoqi@0: * @param cd the class doc to be documented
aoqi@0: * @param member the member to be documented
aoqi@0: * @param tdSummary the content tree to which the link will be added
aoqi@0: */
aoqi@0: protected void addSummaryLink(ClassDoc cd, ProgramElementDoc member,
aoqi@0: Content tdSummary) {
aoqi@0: addSummaryLink(LinkInfoImpl.Kind.MEMBER, cd, member, tdSummary);
aoqi@0: }
aoqi@0:
aoqi@0: /**
aoqi@0: * Add the summary link for the member.
aoqi@0: *
aoqi@0: * @param context the id of the context where the link will be printed
aoqi@0: * @param cd the class doc to be documented
aoqi@0: * @param member the member to be documented
aoqi@0: * @param tdSummary the content tree to which the summary link will be added
aoqi@0: */
aoqi@0: protected abstract void addSummaryLink(LinkInfoImpl.Kind context,
aoqi@0: ClassDoc cd, ProgramElementDoc member, Content tdSummary);
aoqi@0:
aoqi@0: /**
aoqi@0: * Add the inherited summary link for the member.
aoqi@0: *
aoqi@0: * @param cd the class doc to be documented
aoqi@0: * @param member the member to be documented
aoqi@0: * @param linksTree the content tree to which the inherited summary link will be added
aoqi@0: */
aoqi@0: protected abstract void addInheritedSummaryLink(ClassDoc cd,
aoqi@0: ProgramElementDoc member, Content linksTree);
aoqi@0:
aoqi@0: /**
aoqi@0: * Get the deprecated link.
aoqi@0: *
aoqi@0: * @param member the member being linked to
aoqi@0: * @return a content tree representing the link
aoqi@0: */
aoqi@0: protected abstract Content getDeprecatedLink(ProgramElementDoc member);
aoqi@0:
aoqi@0: /**
aoqi@0: * Get the navigation summary link.
aoqi@0: *
aoqi@0: * @param cd the class doc to be documented
aoqi@0: * @param link true if its a link else the label to be printed
aoqi@0: * @return a content tree for the navigation summary link.
aoqi@0: */
aoqi@0: protected abstract Content getNavSummaryLink(ClassDoc cd, boolean link);
aoqi@0:
aoqi@0: /**
aoqi@0: * Add the navigation detail link.
aoqi@0: *
aoqi@0: * @param link true if its a link else the label to be printed
aoqi@0: * @param liNav the content tree to which the navigation detail link will be added
aoqi@0: */
aoqi@0: protected abstract void addNavDetailLink(boolean link, Content liNav);
aoqi@0:
aoqi@0: /**
aoqi@0: * Add the member name to the content tree.
aoqi@0: *
aoqi@0: * @param name the member name to be added to the content tree.
aoqi@0: * @param htmltree the content tree to which the name will be added.
aoqi@0: */
aoqi@0: protected void addName(String name, Content htmltree) {
aoqi@0: htmltree.addContent(name);
aoqi@0: }
aoqi@0:
aoqi@0: /**
aoqi@0: * Return a string describing the access modifier flags.
aoqi@0: * Don't include native or synchronized.
aoqi@0: *
aoqi@0: * The modifier names are returned in canonical order, as
aoqi@0: * specified by The Java Language Specification.
aoqi@0: */
aoqi@0: protected String modifierString(MemberDoc member) {
aoqi@0: int ms = member.modifierSpecifier();
aoqi@0: int no = Modifier.NATIVE | Modifier.SYNCHRONIZED;
aoqi@0: return Modifier.toString(ms & ~no);
aoqi@0: }
aoqi@0:
aoqi@0: protected String typeString(MemberDoc member) {
aoqi@0: String type = "";
aoqi@0: if (member instanceof MethodDoc) {
aoqi@0: type = ((MethodDoc)member).returnType().toString();
aoqi@0: } else if (member instanceof FieldDoc) {
aoqi@0: type = ((FieldDoc)member).type().toString();
aoqi@0: }
aoqi@0: return type;
aoqi@0: }
aoqi@0:
aoqi@0: /**
aoqi@0: * Add the modifier for the member.
aoqi@0: *
aoqi@0: * @param member the member for which teh modifier will be added.
aoqi@0: * @param htmltree the content tree to which the modifier information will be added.
aoqi@0: */
aoqi@0: protected void addModifiers(MemberDoc member, Content htmltree) {
aoqi@0: String mod = modifierString(member);
aoqi@0: // According to JLS, we should not be showing public modifier for
aoqi@0: // interface methods.
aoqi@0: if ((member.isField() || member.isMethod()) &&
aoqi@0: writer instanceof ClassWriterImpl &&
aoqi@0: ((ClassWriterImpl) writer).getClassDoc().isInterface()) {
aoqi@0: // This check for isDefault() and the default modifier needs to be
aoqi@0: // added for it to appear on the method details section. Once the
aoqi@0: // default modifier is added to the Modifier list on DocEnv and once
aoqi@0: // it is updated to use the javax.lang.model.element.Modifier, we
aoqi@0: // will need to remove this.
aoqi@0: mod = (member.isMethod() && ((MethodDoc)member).isDefault()) ?
aoqi@0: Util.replaceText(mod, "public", "default").trim() :
aoqi@0: Util.replaceText(mod, "public", "").trim();
aoqi@0: }
aoqi@0: if(mod.length() > 0) {
aoqi@0: htmltree.addContent(mod);
aoqi@0: htmltree.addContent(writer.getSpace());
aoqi@0: }
aoqi@0: }
aoqi@0:
aoqi@0: protected String makeSpace(int len) {
aoqi@0: if (len <= 0) {
aoqi@0: return "";
aoqi@0: }
aoqi@0: StringBuilder sb = new StringBuilder(len);
aoqi@0: for (int i = 0; i < len; i++) {
aoqi@0: sb.append(' ');
aoqi@0: }
aoqi@0: return sb.toString();
aoqi@0: }
aoqi@0:
aoqi@0: /**
aoqi@0: * Add the modifier and type for the member in the member summary.
aoqi@0: *
aoqi@0: * @param member the member to add the type for
aoqi@0: * @param type the type to add
aoqi@0: * @param tdSummaryType the content tree to which the modified and type will be added
aoqi@0: */
aoqi@0: protected void addModifierAndType(ProgramElementDoc member, Type type,
aoqi@0: Content tdSummaryType) {
aoqi@0: HtmlTree code = new HtmlTree(HtmlTag.CODE);
aoqi@0: addModifier(member, code);
aoqi@0: if (type == null) {
aoqi@0: if (member.isClass()) {
aoqi@0: code.addContent("class");
aoqi@0: } else {
aoqi@0: code.addContent("interface");
aoqi@0: }
aoqi@0: code.addContent(writer.getSpace());
aoqi@0: } else {
aoqi@0: if (member instanceof ExecutableMemberDoc &&
aoqi@0: ((ExecutableMemberDoc) member).typeParameters().length > 0) {
aoqi@0: Content typeParameters = ((AbstractExecutableMemberWriter) this).getTypeParameters(
aoqi@0: (ExecutableMemberDoc) member);
aoqi@0: code.addContent(typeParameters);
aoqi@0: //Code to avoid ugly wrapping in member summary table.
aoqi@0: if (typeParameters.charCount() > 10) {
aoqi@0: code.addContent(new HtmlTree(HtmlTag.BR));
aoqi@0: } else {
aoqi@0: code.addContent(writer.getSpace());
aoqi@0: }
aoqi@0: code.addContent(
aoqi@0: writer.getLink(new LinkInfoImpl(configuration,
aoqi@0: LinkInfoImpl.Kind.SUMMARY_RETURN_TYPE, type)));
aoqi@0: } else {
aoqi@0: code.addContent(
aoqi@0: writer.getLink(new LinkInfoImpl(configuration,
aoqi@0: LinkInfoImpl.Kind.SUMMARY_RETURN_TYPE, type)));
aoqi@0: }
aoqi@0:
aoqi@0: }
aoqi@0: tdSummaryType.addContent(code);
aoqi@0: }
aoqi@0:
aoqi@0: /**
aoqi@0: * Add the modifier for the member.
aoqi@0: *
aoqi@0: * @param member the member to add the type for
aoqi@0: * @param code the content tree to which the modified will be added
aoqi@0: */
aoqi@0: private void addModifier(ProgramElementDoc member, Content code) {
aoqi@0: if (member.isProtected()) {
aoqi@0: code.addContent("protected ");
aoqi@0: } else if (member.isPrivate()) {
aoqi@0: code.addContent("private ");
aoqi@0: } else if (!member.isPublic()) { // Package private
aoqi@0: code.addContent(configuration.getText("doclet.Package_private"));
aoqi@0: code.addContent(" ");
aoqi@0: }
aoqi@0: if (member.isMethod()) {
aoqi@0: if (!(member.containingClass().isInterface()) &&
aoqi@0: ((MethodDoc)member).isAbstract()) {
aoqi@0: code.addContent("abstract ");
aoqi@0: }
aoqi@0: // This check for isDefault() and the default modifier needs to be
aoqi@0: // added for it to appear on the "Modifier and Type" column in the
aoqi@0: // method summary section. Once the default modifier is added
aoqi@0: // to the Modifier list on DocEnv and once it is updated to use the
aoqi@0: // javax.lang.model.element.Modifier, we will need to remove this.
aoqi@0: if (((MethodDoc)member).isDefault()) {
aoqi@0: code.addContent("default ");
aoqi@0: }
aoqi@0: }
aoqi@0: if (member.isStatic()) {
aoqi@0: code.addContent("static ");
aoqi@0: }
aoqi@0: }
aoqi@0:
aoqi@0: /**
aoqi@0: * Add the deprecated information for the given member.
aoqi@0: *
aoqi@0: * @param member the member being documented.
aoqi@0: * @param contentTree the content tree to which the deprecated information will be added.
aoqi@0: */
aoqi@0: protected void addDeprecatedInfo(ProgramElementDoc member, Content contentTree) {
aoqi@0: Content output = (new DeprecatedTaglet()).getTagletOutput(member,
aoqi@0: writer.getTagletWriterInstance(false));
aoqi@0: if (!output.isEmpty()) {
aoqi@0: Content deprecatedContent = output;
aoqi@0: Content div = HtmlTree.DIV(HtmlStyle.block, deprecatedContent);
aoqi@0: contentTree.addContent(div);
aoqi@0: }
aoqi@0: }
aoqi@0:
aoqi@0: /**
aoqi@0: * Add the comment for the given member.
aoqi@0: *
aoqi@0: * @param member the member being documented.
aoqi@0: * @param htmltree the content tree to which the comment will be added.
aoqi@0: */
aoqi@0: protected void addComment(ProgramElementDoc member, Content htmltree) {
aoqi@0: if (member.inlineTags().length > 0) {
aoqi@0: writer.addInlineComment(member, htmltree);
aoqi@0: }
aoqi@0: }
aoqi@0:
aoqi@0: protected String name(ProgramElementDoc member) {
aoqi@0: return member.name();
aoqi@0: }
aoqi@0:
aoqi@0: /**
aoqi@0: * Get the header for the section.
aoqi@0: *
aoqi@0: * @param member the member being documented.
aoqi@0: * @return a header content for the section.
aoqi@0: */
aoqi@0: protected Content getHead(MemberDoc member) {
aoqi@0: Content memberContent = new StringContent(member.name());
aoqi@0: Content heading = HtmlTree.HEADING(HtmlConstants.MEMBER_HEADING, memberContent);
aoqi@0: return heading;
aoqi@0: }
aoqi@0:
aoqi@0: /**
aoqi@0: * Return true if the given ProgramElement
is inherited
aoqi@0: * by the class that is being documented.
aoqi@0: *
aoqi@0: * @param ped The ProgramElement
being checked.
aoqi@0: * return true if the ProgramElement
is being inherited and
aoqi@0: * false otherwise.
aoqi@0: */
aoqi@0: protected boolean isInherited(ProgramElementDoc ped){
aoqi@0: if(ped.isPrivate() || (ped.isPackagePrivate() &&
aoqi@0: ! ped.containingPackage().equals(classdoc.containingPackage()))){
aoqi@0: return false;
aoqi@0: }
aoqi@0: return true;
aoqi@0: }
aoqi@0:
aoqi@0: /**
aoqi@0: * Add deprecated information to the documentation tree
aoqi@0: *
aoqi@0: * @param deprmembers list of deprecated members
aoqi@0: * @param headingKey the caption for the deprecated members table
aoqi@0: * @param tableSummary the summary for the deprecated members table
aoqi@0: * @param tableHeader table headers for the deprecated members table
aoqi@0: * @param contentTree the content tree to which the deprecated members table will be added
aoqi@0: */
aoqi@0: protected void addDeprecatedAPI(List deprmembers, String headingKey,
aoqi@0: String tableSummary, String[] tableHeader, Content contentTree) {
aoqi@0: if (deprmembers.size() > 0) {
aoqi@0: Content table = HtmlTree.TABLE(HtmlStyle.deprecatedSummary, 0, 3, 0, tableSummary,
aoqi@0: writer.getTableCaption(configuration.getResource(headingKey)));
aoqi@0: table.addContent(writer.getSummaryTableHeader(tableHeader, "col"));
aoqi@0: Content tbody = new HtmlTree(HtmlTag.TBODY);
aoqi@0: for (int i = 0; i < deprmembers.size(); i++) {
aoqi@0: ProgramElementDoc member =(ProgramElementDoc)deprmembers.get(i);
aoqi@0: HtmlTree td = HtmlTree.TD(HtmlStyle.colOne, getDeprecatedLink(member));
aoqi@0: if (member.tags("deprecated").length > 0)
aoqi@0: writer.addInlineDeprecatedComment(member,
aoqi@0: member.tags("deprecated")[0], td);
aoqi@0: HtmlTree tr = HtmlTree.TR(td);
aoqi@0: if (i%2 == 0)
aoqi@0: tr.addStyle(HtmlStyle.altColor);
aoqi@0: else
aoqi@0: tr.addStyle(HtmlStyle.rowColor);
aoqi@0: tbody.addContent(tr);
aoqi@0: }
aoqi@0: table.addContent(tbody);
aoqi@0: Content li = HtmlTree.LI(HtmlStyle.blockList, table);
aoqi@0: Content ul = HtmlTree.UL(HtmlStyle.blockList, li);
aoqi@0: contentTree.addContent(ul);
aoqi@0: }
aoqi@0: }
aoqi@0:
aoqi@0: /**
aoqi@0: * Add use information to the documentation tree.
aoqi@0: *
aoqi@0: * @param mems list of program elements for which the use information will be added
aoqi@0: * @param heading the section heading
aoqi@0: * @param tableSummary the summary for the use table
aoqi@0: * @param contentTree the content tree to which the use information will be added
aoqi@0: */
aoqi@0: protected void addUseInfo(List extends ProgramElementDoc> mems,
aoqi@0: Content heading, String tableSummary, Content contentTree) {
aoqi@0: if (mems == null) {
aoqi@0: return;
aoqi@0: }
aoqi@0: List extends ProgramElementDoc> members = mems;
aoqi@0: boolean printedUseTableHeader = false;
aoqi@0: if (members.size() > 0) {
aoqi@0: Content table = HtmlTree.TABLE(HtmlStyle.useSummary, 0, 3, 0, tableSummary,
aoqi@0: writer.getTableCaption(heading));
aoqi@0: Content tbody = new HtmlTree(HtmlTag.TBODY);
aoqi@0: Iterator extends ProgramElementDoc> it = members.iterator();
aoqi@0: for (int i = 0; it.hasNext(); i++) {
aoqi@0: ProgramElementDoc pgmdoc = it.next();
aoqi@0: ClassDoc cd = pgmdoc.containingClass();
aoqi@0: if (!printedUseTableHeader) {
aoqi@0: table.addContent(writer.getSummaryTableHeader(
aoqi@0: this.getSummaryTableHeader(pgmdoc), "col"));
aoqi@0: printedUseTableHeader = true;
aoqi@0: }
aoqi@0: HtmlTree tr = new HtmlTree(HtmlTag.TR);
aoqi@0: if (i % 2 == 0) {
aoqi@0: tr.addStyle(HtmlStyle.altColor);
aoqi@0: } else {
aoqi@0: tr.addStyle(HtmlStyle.rowColor);
aoqi@0: }
aoqi@0: HtmlTree tdFirst = new HtmlTree(HtmlTag.TD);
aoqi@0: tdFirst.addStyle(HtmlStyle.colFirst);
aoqi@0: writer.addSummaryType(this, pgmdoc, tdFirst);
aoqi@0: tr.addContent(tdFirst);
aoqi@0: HtmlTree tdLast = new HtmlTree(HtmlTag.TD);
aoqi@0: tdLast.addStyle(HtmlStyle.colLast);
aoqi@0: if (cd != null && !(pgmdoc instanceof ConstructorDoc)
aoqi@0: && !(pgmdoc instanceof ClassDoc)) {
aoqi@0: HtmlTree name = new HtmlTree(HtmlTag.SPAN);
aoqi@0: name.addStyle(HtmlStyle.typeNameLabel);
aoqi@0: name.addContent(cd.name() + ".");
aoqi@0: tdLast.addContent(name);
aoqi@0: }
aoqi@0: addSummaryLink(pgmdoc instanceof ClassDoc ?
aoqi@0: LinkInfoImpl.Kind.CLASS_USE : LinkInfoImpl.Kind.MEMBER,
aoqi@0: cd, pgmdoc, tdLast);
aoqi@0: writer.addSummaryLinkComment(this, pgmdoc, tdLast);
aoqi@0: tr.addContent(tdLast);
aoqi@0: tbody.addContent(tr);
aoqi@0: }
aoqi@0: table.addContent(tbody);
aoqi@0: contentTree.addContent(table);
aoqi@0: }
aoqi@0: }
aoqi@0:
aoqi@0: /**
aoqi@0: * Add the navigation detail link.
aoqi@0: *
aoqi@0: * @param members the members to be linked
aoqi@0: * @param liNav the content tree to which the navigation detail link will be added
aoqi@0: */
aoqi@0: protected void addNavDetailLink(List> members, Content liNav) {
aoqi@0: addNavDetailLink(members.size() > 0 ? true : false, liNav);
aoqi@0: }
aoqi@0:
aoqi@0: /**
aoqi@0: * Add the navigation summary link.
aoqi@0: *
aoqi@0: * @param members members to be linked
aoqi@0: * @param visibleMemberMap the visible inherited members map
aoqi@0: * @param liNav the content tree to which the navigation summary link will be added
aoqi@0: */
aoqi@0: protected void addNavSummaryLink(List> members,
aoqi@0: VisibleMemberMap visibleMemberMap, Content liNav) {
aoqi@0: if (members.size() > 0) {
aoqi@0: liNav.addContent(getNavSummaryLink(null, true));
aoqi@0: return;
aoqi@0: }
aoqi@0: ClassDoc icd = classdoc.superclass();
aoqi@0: while (icd != null) {
aoqi@0: List> inhmembers = visibleMemberMap.getMembersFor(icd);
aoqi@0: if (inhmembers.size() > 0) {
aoqi@0: liNav.addContent(getNavSummaryLink(icd, true));
aoqi@0: return;
aoqi@0: }
aoqi@0: icd = icd.superclass();
aoqi@0: }
aoqi@0: liNav.addContent(getNavSummaryLink(null, false));
aoqi@0: }
aoqi@0:
aoqi@0: protected void serialWarning(SourcePosition pos, String key, String a1, String a2) {
aoqi@0: if (configuration.serialwarn) {
aoqi@0: configuration.getDocletSpecificMsg().warning(pos, key, a1, a2);
aoqi@0: }
aoqi@0: }
aoqi@0:
aoqi@0: public ProgramElementDoc[] eligibleMembers(ProgramElementDoc[] members) {
aoqi@0: return nodepr? Util.excludeDeprecatedMembers(members): members;
aoqi@0: }
aoqi@0:
aoqi@0: /**
aoqi@0: * Add the member summary for the given class.
aoqi@0: *
aoqi@0: * @param classDoc the class that is being documented
aoqi@0: * @param member the member being documented
aoqi@0: * @param firstSentenceTags the first sentence tags to be added to the summary
aoqi@0: * @param tableContents the list of contents to which the documentation will be added
aoqi@0: * @param counter the counter for determining id and style for the table row
aoqi@0: */
aoqi@0: public void addMemberSummary(ClassDoc classDoc, ProgramElementDoc member,
aoqi@0: Tag[] firstSentenceTags, List tableContents, int counter) {
aoqi@0: HtmlTree tdSummaryType = new HtmlTree(HtmlTag.TD);
aoqi@0: tdSummaryType.addStyle(HtmlStyle.colFirst);
aoqi@0: writer.addSummaryType(this, member, tdSummaryType);
aoqi@0: HtmlTree tdSummary = new HtmlTree(HtmlTag.TD);
aoqi@0: setSummaryColumnStyle(tdSummary);
aoqi@0: addSummaryLink(classDoc, member, tdSummary);
aoqi@0: writer.addSummaryLinkComment(this, member, firstSentenceTags, tdSummary);
aoqi@0: HtmlTree tr = HtmlTree.TR(tdSummaryType);
aoqi@0: tr.addContent(tdSummary);
aoqi@0: if (member instanceof MethodDoc && !member.isAnnotationTypeElement()) {
aoqi@0: int methodType = (member.isStatic()) ? MethodTypes.STATIC.value() :
aoqi@0: MethodTypes.INSTANCE.value();
aoqi@0: if (member.containingClass().isInterface()) {
aoqi@0: methodType = (((MethodDoc) member).isAbstract())
aoqi@0: ? methodType | MethodTypes.ABSTRACT.value()
aoqi@0: : methodType | MethodTypes.DEFAULT.value();
aoqi@0: } else {
aoqi@0: methodType = (((MethodDoc) member).isAbstract())
aoqi@0: ? methodType | MethodTypes.ABSTRACT.value()
aoqi@0: : methodType | MethodTypes.CONCRETE.value();
aoqi@0: }
aoqi@0: if (Util.isDeprecated(member) || Util.isDeprecated(classdoc)) {
aoqi@0: methodType = methodType | MethodTypes.DEPRECATED.value();
aoqi@0: }
aoqi@0: methodTypesOr = methodTypesOr | methodType;
aoqi@0: String tableId = "i" + counter;
aoqi@0: typeMap.put(tableId, methodType);
aoqi@0: tr.addAttr(HtmlAttr.ID, tableId);
aoqi@0: }
aoqi@0: if (counter%2 == 0)
aoqi@0: tr.addStyle(HtmlStyle.altColor);
aoqi@0: else
aoqi@0: tr.addStyle(HtmlStyle.rowColor);
aoqi@0: tableContents.add(tr);
aoqi@0: }
aoqi@0:
aoqi@0: /**
aoqi@0: * Generate the method types set and return true if the method summary table
aoqi@0: * needs to show tabs.
aoqi@0: *
aoqi@0: * @return true if the table should show tabs
aoqi@0: */
aoqi@0: public boolean showTabs() {
aoqi@0: int value;
aoqi@0: for (MethodTypes type : EnumSet.allOf(MethodTypes.class)) {
aoqi@0: value = type.value();
aoqi@0: if ((value & methodTypesOr) == value) {
aoqi@0: methodTypes.add(type);
aoqi@0: }
aoqi@0: }
aoqi@0: boolean showTabs = methodTypes.size() > 1;
aoqi@0: if (showTabs) {
aoqi@0: methodTypes.add(MethodTypes.ALL);
aoqi@0: }
aoqi@0: return showTabs;
aoqi@0: }
aoqi@0:
aoqi@0: /**
aoqi@0: * Set the style for the summary column.
aoqi@0: *
aoqi@0: * @param tdTree the column for which the style will be set
aoqi@0: */
aoqi@0: public void setSummaryColumnStyle(HtmlTree tdTree) {
aoqi@0: tdTree.addStyle(HtmlStyle.colLast);
aoqi@0: }
aoqi@0:
aoqi@0: /**
aoqi@0: * Add inherited member summary for the given class and member.
aoqi@0: *
aoqi@0: * @param classDoc the class the inherited member belongs to
aoqi@0: * @param nestedClass the inherited member that is summarized
aoqi@0: * @param isFirst true if this is the first member in the list
aoqi@0: * @param isLast true if this is the last member in the list
aoqi@0: * @param linksTree the content tree to which the summary will be added
aoqi@0: */
aoqi@0: public void addInheritedMemberSummary(ClassDoc classDoc,
aoqi@0: ProgramElementDoc nestedClass, boolean isFirst, boolean isLast,
aoqi@0: Content linksTree) {
aoqi@0: writer.addInheritedMemberSummary(this, classDoc, nestedClass, isFirst,
aoqi@0: linksTree);
aoqi@0: }
aoqi@0:
aoqi@0: /**
aoqi@0: * Get the inherited summary header for the given class.
aoqi@0: *
aoqi@0: * @param classDoc the class the inherited member belongs to
aoqi@0: * @return a content tree for the inherited summary header
aoqi@0: */
aoqi@0: public Content getInheritedSummaryHeader(ClassDoc classDoc) {
aoqi@0: Content inheritedTree = writer.getMemberTreeHeader();
aoqi@0: writer.addInheritedSummaryHeader(this, classDoc, inheritedTree);
aoqi@0: return inheritedTree;
aoqi@0: }
aoqi@0:
aoqi@0: /**
aoqi@0: * Get the inherited summary links tree.
aoqi@0: *
aoqi@0: * @return a content tree for the inherited summary links
aoqi@0: */
aoqi@0: public Content getInheritedSummaryLinksTree() {
aoqi@0: return new HtmlTree(HtmlTag.CODE);
aoqi@0: }
aoqi@0:
aoqi@0: /**
aoqi@0: * Get the summary table tree for the given class.
aoqi@0: *
aoqi@0: * @param classDoc the class for which the summary table is generated
aoqi@0: * @param tableContents list of contents to be displayed in the summary table
aoqi@0: * @return a content tree for the summary table
aoqi@0: */
aoqi@0: public Content getSummaryTableTree(ClassDoc classDoc, List tableContents) {
aoqi@0: return writer.getSummaryTableTree(this, classDoc, tableContents, showTabs());
aoqi@0: }
aoqi@0:
aoqi@0: /**
aoqi@0: * Get the member tree to be documented.
aoqi@0: *
aoqi@0: * @param memberTree the content tree of member to be documented
aoqi@0: * @return a content tree that will be added to the class documentation
aoqi@0: */
aoqi@0: public Content getMemberTree(Content memberTree) {
aoqi@0: return writer.getMemberTree(memberTree);
aoqi@0: }
aoqi@0:
aoqi@0: /**
aoqi@0: * Get the member tree to be documented.
aoqi@0: *
aoqi@0: * @param memberTree the content tree of member to be documented
aoqi@0: * @param isLastContent true if the content to be added is the last content
aoqi@0: * @return a content tree that will be added to the class documentation
aoqi@0: */
aoqi@0: public Content getMemberTree(Content memberTree, boolean isLastContent) {
aoqi@0: if (isLastContent)
aoqi@0: return HtmlTree.UL(HtmlStyle.blockListLast, memberTree);
aoqi@0: else
aoqi@0: return HtmlTree.UL(HtmlStyle.blockList, memberTree);
aoqi@0: }
aoqi@0: }