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