1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java Wed Apr 27 01:34:52 2016 +0800 1.3 @@ -0,0 +1,692 @@ 1.4 +/* 1.5 + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. Oracle designates this 1.11 + * particular file as subject to the "Classpath" exception as provided 1.12 + * by Oracle in the LICENSE file that accompanied this code. 1.13 + * 1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.17 + * version 2 for more details (a copy is included in the LICENSE file that 1.18 + * accompanied this code). 1.19 + * 1.20 + * You should have received a copy of the GNU General Public License version 1.21 + * 2 along with this work; if not, write to the Free Software Foundation, 1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.23 + * 1.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.25 + * or visit www.oracle.com if you need additional information or have any 1.26 + * questions. 1.27 + */ 1.28 + 1.29 +package com.sun.tools.doclets.formats.html; 1.30 + 1.31 +import java.lang.reflect.Modifier; 1.32 +import java.util.*; 1.33 + 1.34 +import com.sun.javadoc.*; 1.35 +import com.sun.tools.doclets.formats.html.markup.*; 1.36 +import com.sun.tools.doclets.internal.toolkit.*; 1.37 +import com.sun.tools.doclets.internal.toolkit.taglets.*; 1.38 +import com.sun.tools.doclets.internal.toolkit.util.*; 1.39 + 1.40 +/** 1.41 + * The base class for member writers. 1.42 + * 1.43 + * <p><b>This is NOT part of any supported API. 1.44 + * If you write code that depends on this, you do so at your own risk. 1.45 + * This code and its internal interfaces are subject to change or 1.46 + * deletion without notice.</b> 1.47 + * 1.48 + * @author Robert Field 1.49 + * @author Atul M Dambalkar 1.50 + * @author Jamie Ho (Re-write) 1.51 + * @author Bhavesh Patel (Modified) 1.52 + */ 1.53 +public abstract class AbstractMemberWriter { 1.54 + 1.55 + protected final ConfigurationImpl configuration; 1.56 + protected final SubWriterHolderWriter writer; 1.57 + protected final ClassDoc classdoc; 1.58 + protected Map<String,Integer> typeMap = new LinkedHashMap<String,Integer>(); 1.59 + protected Set<MethodTypes> methodTypes = EnumSet.noneOf(MethodTypes.class); 1.60 + private int methodTypesOr = 0; 1.61 + public final boolean nodepr; 1.62 + 1.63 + protected boolean printedSummaryHeader = false; 1.64 + 1.65 + public AbstractMemberWriter(SubWriterHolderWriter writer, ClassDoc classdoc) { 1.66 + this.configuration = writer.configuration; 1.67 + this.writer = writer; 1.68 + this.nodepr = configuration.nodeprecated; 1.69 + this.classdoc = classdoc; 1.70 + } 1.71 + 1.72 + public AbstractMemberWriter(SubWriterHolderWriter writer) { 1.73 + this(writer, null); 1.74 + } 1.75 + 1.76 + /*** abstracts ***/ 1.77 + 1.78 + /** 1.79 + * Add the summary label for the member. 1.80 + * 1.81 + * @param memberTree the content tree to which the label will be added 1.82 + */ 1.83 + public abstract void addSummaryLabel(Content memberTree); 1.84 + 1.85 + /** 1.86 + * Get the summary for the member summary table. 1.87 + * 1.88 + * @return a string for the table summary 1.89 + */ 1.90 + public abstract String getTableSummary(); 1.91 + 1.92 + /** 1.93 + * Get the caption for the member summary table. 1.94 + * 1.95 + * @return a string for the table caption 1.96 + */ 1.97 + public abstract Content getCaption(); 1.98 + 1.99 + /** 1.100 + * Get the summary table header for the member. 1.101 + * 1.102 + * @param member the member to be documented 1.103 + * @return the summary table header 1.104 + */ 1.105 + public abstract String[] getSummaryTableHeader(ProgramElementDoc member); 1.106 + 1.107 + /** 1.108 + * Add inherited summary lable for the member. 1.109 + * 1.110 + * @param cd the class doc to which to link to 1.111 + * @param inheritedTree the content tree to which the inherited summary label will be added 1.112 + */ 1.113 + public abstract void addInheritedSummaryLabel(ClassDoc cd, Content inheritedTree); 1.114 + 1.115 + /** 1.116 + * Add the anchor for the summary section of the member. 1.117 + * 1.118 + * @param cd the class doc to be documented 1.119 + * @param memberTree the content tree to which the summary anchor will be added 1.120 + */ 1.121 + public abstract void addSummaryAnchor(ClassDoc cd, Content memberTree); 1.122 + 1.123 + /** 1.124 + * Add the anchor for the inherited summary section of the member. 1.125 + * 1.126 + * @param cd the class doc to be documented 1.127 + * @param inheritedTree the content tree to which the inherited summary anchor will be added 1.128 + */ 1.129 + public abstract void addInheritedSummaryAnchor(ClassDoc cd, Content inheritedTree); 1.130 + 1.131 + /** 1.132 + * Add the summary type for the member. 1.133 + * 1.134 + * @param member the member to be documented 1.135 + * @param tdSummaryType the content tree to which the type will be added 1.136 + */ 1.137 + protected abstract void addSummaryType(ProgramElementDoc member, 1.138 + Content tdSummaryType); 1.139 + 1.140 + /** 1.141 + * Add the summary link for the member. 1.142 + * 1.143 + * @param cd the class doc to be documented 1.144 + * @param member the member to be documented 1.145 + * @param tdSummary the content tree to which the link will be added 1.146 + */ 1.147 + protected void addSummaryLink(ClassDoc cd, ProgramElementDoc member, 1.148 + Content tdSummary) { 1.149 + addSummaryLink(LinkInfoImpl.Kind.MEMBER, cd, member, tdSummary); 1.150 + } 1.151 + 1.152 + /** 1.153 + * Add the summary link for the member. 1.154 + * 1.155 + * @param context the id of the context where the link will be printed 1.156 + * @param cd the class doc to be documented 1.157 + * @param member the member to be documented 1.158 + * @param tdSummary the content tree to which the summary link will be added 1.159 + */ 1.160 + protected abstract void addSummaryLink(LinkInfoImpl.Kind context, 1.161 + ClassDoc cd, ProgramElementDoc member, Content tdSummary); 1.162 + 1.163 + /** 1.164 + * Add the inherited summary link for the member. 1.165 + * 1.166 + * @param cd the class doc to be documented 1.167 + * @param member the member to be documented 1.168 + * @param linksTree the content tree to which the inherited summary link will be added 1.169 + */ 1.170 + protected abstract void addInheritedSummaryLink(ClassDoc cd, 1.171 + ProgramElementDoc member, Content linksTree); 1.172 + 1.173 + /** 1.174 + * Get the deprecated link. 1.175 + * 1.176 + * @param member the member being linked to 1.177 + * @return a content tree representing the link 1.178 + */ 1.179 + protected abstract Content getDeprecatedLink(ProgramElementDoc member); 1.180 + 1.181 + /** 1.182 + * Get the navigation summary link. 1.183 + * 1.184 + * @param cd the class doc to be documented 1.185 + * @param link true if its a link else the label to be printed 1.186 + * @return a content tree for the navigation summary link. 1.187 + */ 1.188 + protected abstract Content getNavSummaryLink(ClassDoc cd, boolean link); 1.189 + 1.190 + /** 1.191 + * Add the navigation detail link. 1.192 + * 1.193 + * @param link true if its a link else the label to be printed 1.194 + * @param liNav the content tree to which the navigation detail link will be added 1.195 + */ 1.196 + protected abstract void addNavDetailLink(boolean link, Content liNav); 1.197 + 1.198 + /** 1.199 + * Add the member name to the content tree. 1.200 + * 1.201 + * @param name the member name to be added to the content tree. 1.202 + * @param htmltree the content tree to which the name will be added. 1.203 + */ 1.204 + protected void addName(String name, Content htmltree) { 1.205 + htmltree.addContent(name); 1.206 + } 1.207 + 1.208 + /** 1.209 + * Return a string describing the access modifier flags. 1.210 + * Don't include native or synchronized. 1.211 + * 1.212 + * The modifier names are returned in canonical order, as 1.213 + * specified by <em>The Java Language Specification</em>. 1.214 + */ 1.215 + protected String modifierString(MemberDoc member) { 1.216 + int ms = member.modifierSpecifier(); 1.217 + int no = Modifier.NATIVE | Modifier.SYNCHRONIZED; 1.218 + return Modifier.toString(ms & ~no); 1.219 + } 1.220 + 1.221 + protected String typeString(MemberDoc member) { 1.222 + String type = ""; 1.223 + if (member instanceof MethodDoc) { 1.224 + type = ((MethodDoc)member).returnType().toString(); 1.225 + } else if (member instanceof FieldDoc) { 1.226 + type = ((FieldDoc)member).type().toString(); 1.227 + } 1.228 + return type; 1.229 + } 1.230 + 1.231 + /** 1.232 + * Add the modifier for the member. 1.233 + * 1.234 + * @param member the member for which teh modifier will be added. 1.235 + * @param htmltree the content tree to which the modifier information will be added. 1.236 + */ 1.237 + protected void addModifiers(MemberDoc member, Content htmltree) { 1.238 + String mod = modifierString(member); 1.239 + // According to JLS, we should not be showing public modifier for 1.240 + // interface methods. 1.241 + if ((member.isField() || member.isMethod()) && 1.242 + writer instanceof ClassWriterImpl && 1.243 + ((ClassWriterImpl) writer).getClassDoc().isInterface()) { 1.244 + // This check for isDefault() and the default modifier needs to be 1.245 + // added for it to appear on the method details section. Once the 1.246 + // default modifier is added to the Modifier list on DocEnv and once 1.247 + // it is updated to use the javax.lang.model.element.Modifier, we 1.248 + // will need to remove this. 1.249 + mod = (member.isMethod() && ((MethodDoc)member).isDefault()) ? 1.250 + Util.replaceText(mod, "public", "default").trim() : 1.251 + Util.replaceText(mod, "public", "").trim(); 1.252 + } 1.253 + if(mod.length() > 0) { 1.254 + htmltree.addContent(mod); 1.255 + htmltree.addContent(writer.getSpace()); 1.256 + } 1.257 + } 1.258 + 1.259 + protected String makeSpace(int len) { 1.260 + if (len <= 0) { 1.261 + return ""; 1.262 + } 1.263 + StringBuilder sb = new StringBuilder(len); 1.264 + for (int i = 0; i < len; i++) { 1.265 + sb.append(' '); 1.266 + } 1.267 + return sb.toString(); 1.268 + } 1.269 + 1.270 + /** 1.271 + * Add the modifier and type for the member in the member summary. 1.272 + * 1.273 + * @param member the member to add the type for 1.274 + * @param type the type to add 1.275 + * @param tdSummaryType the content tree to which the modified and type will be added 1.276 + */ 1.277 + protected void addModifierAndType(ProgramElementDoc member, Type type, 1.278 + Content tdSummaryType) { 1.279 + HtmlTree code = new HtmlTree(HtmlTag.CODE); 1.280 + addModifier(member, code); 1.281 + if (type == null) { 1.282 + if (member.isClass()) { 1.283 + code.addContent("class"); 1.284 + } else { 1.285 + code.addContent("interface"); 1.286 + } 1.287 + code.addContent(writer.getSpace()); 1.288 + } else { 1.289 + if (member instanceof ExecutableMemberDoc && 1.290 + ((ExecutableMemberDoc) member).typeParameters().length > 0) { 1.291 + Content typeParameters = ((AbstractExecutableMemberWriter) this).getTypeParameters( 1.292 + (ExecutableMemberDoc) member); 1.293 + code.addContent(typeParameters); 1.294 + //Code to avoid ugly wrapping in member summary table. 1.295 + if (typeParameters.charCount() > 10) { 1.296 + code.addContent(new HtmlTree(HtmlTag.BR)); 1.297 + } else { 1.298 + code.addContent(writer.getSpace()); 1.299 + } 1.300 + code.addContent( 1.301 + writer.getLink(new LinkInfoImpl(configuration, 1.302 + LinkInfoImpl.Kind.SUMMARY_RETURN_TYPE, type))); 1.303 + } else { 1.304 + code.addContent( 1.305 + writer.getLink(new LinkInfoImpl(configuration, 1.306 + LinkInfoImpl.Kind.SUMMARY_RETURN_TYPE, type))); 1.307 + } 1.308 + 1.309 + } 1.310 + tdSummaryType.addContent(code); 1.311 + } 1.312 + 1.313 + /** 1.314 + * Add the modifier for the member. 1.315 + * 1.316 + * @param member the member to add the type for 1.317 + * @param code the content tree to which the modified will be added 1.318 + */ 1.319 + private void addModifier(ProgramElementDoc member, Content code) { 1.320 + if (member.isProtected()) { 1.321 + code.addContent("protected "); 1.322 + } else if (member.isPrivate()) { 1.323 + code.addContent("private "); 1.324 + } else if (!member.isPublic()) { // Package private 1.325 + code.addContent(configuration.getText("doclet.Package_private")); 1.326 + code.addContent(" "); 1.327 + } 1.328 + if (member.isMethod()) { 1.329 + if (!(member.containingClass().isInterface()) && 1.330 + ((MethodDoc)member).isAbstract()) { 1.331 + code.addContent("abstract "); 1.332 + } 1.333 + // This check for isDefault() and the default modifier needs to be 1.334 + // added for it to appear on the "Modifier and Type" column in the 1.335 + // method summary section. Once the default modifier is added 1.336 + // to the Modifier list on DocEnv and once it is updated to use the 1.337 + // javax.lang.model.element.Modifier, we will need to remove this. 1.338 + if (((MethodDoc)member).isDefault()) { 1.339 + code.addContent("default "); 1.340 + } 1.341 + } 1.342 + if (member.isStatic()) { 1.343 + code.addContent("static "); 1.344 + } 1.345 + } 1.346 + 1.347 + /** 1.348 + * Add the deprecated information for the given member. 1.349 + * 1.350 + * @param member the member being documented. 1.351 + * @param contentTree the content tree to which the deprecated information will be added. 1.352 + */ 1.353 + protected void addDeprecatedInfo(ProgramElementDoc member, Content contentTree) { 1.354 + Content output = (new DeprecatedTaglet()).getTagletOutput(member, 1.355 + writer.getTagletWriterInstance(false)); 1.356 + if (!output.isEmpty()) { 1.357 + Content deprecatedContent = output; 1.358 + Content div = HtmlTree.DIV(HtmlStyle.block, deprecatedContent); 1.359 + contentTree.addContent(div); 1.360 + } 1.361 + } 1.362 + 1.363 + /** 1.364 + * Add the comment for the given member. 1.365 + * 1.366 + * @param member the member being documented. 1.367 + * @param htmltree the content tree to which the comment will be added. 1.368 + */ 1.369 + protected void addComment(ProgramElementDoc member, Content htmltree) { 1.370 + if (member.inlineTags().length > 0) { 1.371 + writer.addInlineComment(member, htmltree); 1.372 + } 1.373 + } 1.374 + 1.375 + protected String name(ProgramElementDoc member) { 1.376 + return member.name(); 1.377 + } 1.378 + 1.379 + /** 1.380 + * Get the header for the section. 1.381 + * 1.382 + * @param member the member being documented. 1.383 + * @return a header content for the section. 1.384 + */ 1.385 + protected Content getHead(MemberDoc member) { 1.386 + Content memberContent = new StringContent(member.name()); 1.387 + Content heading = HtmlTree.HEADING(HtmlConstants.MEMBER_HEADING, memberContent); 1.388 + return heading; 1.389 + } 1.390 + 1.391 + /** 1.392 + * Return true if the given <code>ProgramElement</code> is inherited 1.393 + * by the class that is being documented. 1.394 + * 1.395 + * @param ped The <code>ProgramElement</code> being checked. 1.396 + * return true if the <code>ProgramElement</code> is being inherited and 1.397 + * false otherwise. 1.398 + */ 1.399 + protected boolean isInherited(ProgramElementDoc ped){ 1.400 + if(ped.isPrivate() || (ped.isPackagePrivate() && 1.401 + ! ped.containingPackage().equals(classdoc.containingPackage()))){ 1.402 + return false; 1.403 + } 1.404 + return true; 1.405 + } 1.406 + 1.407 + /** 1.408 + * Add deprecated information to the documentation tree 1.409 + * 1.410 + * @param deprmembers list of deprecated members 1.411 + * @param headingKey the caption for the deprecated members table 1.412 + * @param tableSummary the summary for the deprecated members table 1.413 + * @param tableHeader table headers for the deprecated members table 1.414 + * @param contentTree the content tree to which the deprecated members table will be added 1.415 + */ 1.416 + protected void addDeprecatedAPI(List<Doc> deprmembers, String headingKey, 1.417 + String tableSummary, String[] tableHeader, Content contentTree) { 1.418 + if (deprmembers.size() > 0) { 1.419 + Content table = HtmlTree.TABLE(HtmlStyle.deprecatedSummary, 0, 3, 0, tableSummary, 1.420 + writer.getTableCaption(configuration.getResource(headingKey))); 1.421 + table.addContent(writer.getSummaryTableHeader(tableHeader, "col")); 1.422 + Content tbody = new HtmlTree(HtmlTag.TBODY); 1.423 + for (int i = 0; i < deprmembers.size(); i++) { 1.424 + ProgramElementDoc member =(ProgramElementDoc)deprmembers.get(i); 1.425 + HtmlTree td = HtmlTree.TD(HtmlStyle.colOne, getDeprecatedLink(member)); 1.426 + if (member.tags("deprecated").length > 0) 1.427 + writer.addInlineDeprecatedComment(member, 1.428 + member.tags("deprecated")[0], td); 1.429 + HtmlTree tr = HtmlTree.TR(td); 1.430 + if (i%2 == 0) 1.431 + tr.addStyle(HtmlStyle.altColor); 1.432 + else 1.433 + tr.addStyle(HtmlStyle.rowColor); 1.434 + tbody.addContent(tr); 1.435 + } 1.436 + table.addContent(tbody); 1.437 + Content li = HtmlTree.LI(HtmlStyle.blockList, table); 1.438 + Content ul = HtmlTree.UL(HtmlStyle.blockList, li); 1.439 + contentTree.addContent(ul); 1.440 + } 1.441 + } 1.442 + 1.443 + /** 1.444 + * Add use information to the documentation tree. 1.445 + * 1.446 + * @param mems list of program elements for which the use information will be added 1.447 + * @param heading the section heading 1.448 + * @param tableSummary the summary for the use table 1.449 + * @param contentTree the content tree to which the use information will be added 1.450 + */ 1.451 + protected void addUseInfo(List<? extends ProgramElementDoc> mems, 1.452 + Content heading, String tableSummary, Content contentTree) { 1.453 + if (mems == null) { 1.454 + return; 1.455 + } 1.456 + List<? extends ProgramElementDoc> members = mems; 1.457 + boolean printedUseTableHeader = false; 1.458 + if (members.size() > 0) { 1.459 + Content table = HtmlTree.TABLE(HtmlStyle.useSummary, 0, 3, 0, tableSummary, 1.460 + writer.getTableCaption(heading)); 1.461 + Content tbody = new HtmlTree(HtmlTag.TBODY); 1.462 + Iterator<? extends ProgramElementDoc> it = members.iterator(); 1.463 + for (int i = 0; it.hasNext(); i++) { 1.464 + ProgramElementDoc pgmdoc = it.next(); 1.465 + ClassDoc cd = pgmdoc.containingClass(); 1.466 + if (!printedUseTableHeader) { 1.467 + table.addContent(writer.getSummaryTableHeader( 1.468 + this.getSummaryTableHeader(pgmdoc), "col")); 1.469 + printedUseTableHeader = true; 1.470 + } 1.471 + HtmlTree tr = new HtmlTree(HtmlTag.TR); 1.472 + if (i % 2 == 0) { 1.473 + tr.addStyle(HtmlStyle.altColor); 1.474 + } else { 1.475 + tr.addStyle(HtmlStyle.rowColor); 1.476 + } 1.477 + HtmlTree tdFirst = new HtmlTree(HtmlTag.TD); 1.478 + tdFirst.addStyle(HtmlStyle.colFirst); 1.479 + writer.addSummaryType(this, pgmdoc, tdFirst); 1.480 + tr.addContent(tdFirst); 1.481 + HtmlTree tdLast = new HtmlTree(HtmlTag.TD); 1.482 + tdLast.addStyle(HtmlStyle.colLast); 1.483 + if (cd != null && !(pgmdoc instanceof ConstructorDoc) 1.484 + && !(pgmdoc instanceof ClassDoc)) { 1.485 + HtmlTree name = new HtmlTree(HtmlTag.SPAN); 1.486 + name.addStyle(HtmlStyle.typeNameLabel); 1.487 + name.addContent(cd.name() + "."); 1.488 + tdLast.addContent(name); 1.489 + } 1.490 + addSummaryLink(pgmdoc instanceof ClassDoc ? 1.491 + LinkInfoImpl.Kind.CLASS_USE : LinkInfoImpl.Kind.MEMBER, 1.492 + cd, pgmdoc, tdLast); 1.493 + writer.addSummaryLinkComment(this, pgmdoc, tdLast); 1.494 + tr.addContent(tdLast); 1.495 + tbody.addContent(tr); 1.496 + } 1.497 + table.addContent(tbody); 1.498 + contentTree.addContent(table); 1.499 + } 1.500 + } 1.501 + 1.502 + /** 1.503 + * Add the navigation detail link. 1.504 + * 1.505 + * @param members the members to be linked 1.506 + * @param liNav the content tree to which the navigation detail link will be added 1.507 + */ 1.508 + protected void addNavDetailLink(List<?> members, Content liNav) { 1.509 + addNavDetailLink(members.size() > 0 ? true : false, liNav); 1.510 + } 1.511 + 1.512 + /** 1.513 + * Add the navigation summary link. 1.514 + * 1.515 + * @param members members to be linked 1.516 + * @param visibleMemberMap the visible inherited members map 1.517 + * @param liNav the content tree to which the navigation summary link will be added 1.518 + */ 1.519 + protected void addNavSummaryLink(List<?> members, 1.520 + VisibleMemberMap visibleMemberMap, Content liNav) { 1.521 + if (members.size() > 0) { 1.522 + liNav.addContent(getNavSummaryLink(null, true)); 1.523 + return; 1.524 + } 1.525 + ClassDoc icd = classdoc.superclass(); 1.526 + while (icd != null) { 1.527 + List<?> inhmembers = visibleMemberMap.getMembersFor(icd); 1.528 + if (inhmembers.size() > 0) { 1.529 + liNav.addContent(getNavSummaryLink(icd, true)); 1.530 + return; 1.531 + } 1.532 + icd = icd.superclass(); 1.533 + } 1.534 + liNav.addContent(getNavSummaryLink(null, false)); 1.535 + } 1.536 + 1.537 + protected void serialWarning(SourcePosition pos, String key, String a1, String a2) { 1.538 + if (configuration.serialwarn) { 1.539 + configuration.getDocletSpecificMsg().warning(pos, key, a1, a2); 1.540 + } 1.541 + } 1.542 + 1.543 + public ProgramElementDoc[] eligibleMembers(ProgramElementDoc[] members) { 1.544 + return nodepr? Util.excludeDeprecatedMembers(members): members; 1.545 + } 1.546 + 1.547 + /** 1.548 + * Add the member summary for the given class. 1.549 + * 1.550 + * @param classDoc the class that is being documented 1.551 + * @param member the member being documented 1.552 + * @param firstSentenceTags the first sentence tags to be added to the summary 1.553 + * @param tableContents the list of contents to which the documentation will be added 1.554 + * @param counter the counter for determining id and style for the table row 1.555 + */ 1.556 + public void addMemberSummary(ClassDoc classDoc, ProgramElementDoc member, 1.557 + Tag[] firstSentenceTags, List<Content> tableContents, int counter) { 1.558 + HtmlTree tdSummaryType = new HtmlTree(HtmlTag.TD); 1.559 + tdSummaryType.addStyle(HtmlStyle.colFirst); 1.560 + writer.addSummaryType(this, member, tdSummaryType); 1.561 + HtmlTree tdSummary = new HtmlTree(HtmlTag.TD); 1.562 + setSummaryColumnStyle(tdSummary); 1.563 + addSummaryLink(classDoc, member, tdSummary); 1.564 + writer.addSummaryLinkComment(this, member, firstSentenceTags, tdSummary); 1.565 + HtmlTree tr = HtmlTree.TR(tdSummaryType); 1.566 + tr.addContent(tdSummary); 1.567 + if (member instanceof MethodDoc && !member.isAnnotationTypeElement()) { 1.568 + int methodType = (member.isStatic()) ? MethodTypes.STATIC.value() : 1.569 + MethodTypes.INSTANCE.value(); 1.570 + if (member.containingClass().isInterface()) { 1.571 + methodType = (((MethodDoc) member).isAbstract()) 1.572 + ? methodType | MethodTypes.ABSTRACT.value() 1.573 + : methodType | MethodTypes.DEFAULT.value(); 1.574 + } else { 1.575 + methodType = (((MethodDoc) member).isAbstract()) 1.576 + ? methodType | MethodTypes.ABSTRACT.value() 1.577 + : methodType | MethodTypes.CONCRETE.value(); 1.578 + } 1.579 + if (Util.isDeprecated(member) || Util.isDeprecated(classdoc)) { 1.580 + methodType = methodType | MethodTypes.DEPRECATED.value(); 1.581 + } 1.582 + methodTypesOr = methodTypesOr | methodType; 1.583 + String tableId = "i" + counter; 1.584 + typeMap.put(tableId, methodType); 1.585 + tr.addAttr(HtmlAttr.ID, tableId); 1.586 + } 1.587 + if (counter%2 == 0) 1.588 + tr.addStyle(HtmlStyle.altColor); 1.589 + else 1.590 + tr.addStyle(HtmlStyle.rowColor); 1.591 + tableContents.add(tr); 1.592 + } 1.593 + 1.594 + /** 1.595 + * Generate the method types set and return true if the method summary table 1.596 + * needs to show tabs. 1.597 + * 1.598 + * @return true if the table should show tabs 1.599 + */ 1.600 + public boolean showTabs() { 1.601 + int value; 1.602 + for (MethodTypes type : EnumSet.allOf(MethodTypes.class)) { 1.603 + value = type.value(); 1.604 + if ((value & methodTypesOr) == value) { 1.605 + methodTypes.add(type); 1.606 + } 1.607 + } 1.608 + boolean showTabs = methodTypes.size() > 1; 1.609 + if (showTabs) { 1.610 + methodTypes.add(MethodTypes.ALL); 1.611 + } 1.612 + return showTabs; 1.613 + } 1.614 + 1.615 + /** 1.616 + * Set the style for the summary column. 1.617 + * 1.618 + * @param tdTree the column for which the style will be set 1.619 + */ 1.620 + public void setSummaryColumnStyle(HtmlTree tdTree) { 1.621 + tdTree.addStyle(HtmlStyle.colLast); 1.622 + } 1.623 + 1.624 + /** 1.625 + * Add inherited member summary for the given class and member. 1.626 + * 1.627 + * @param classDoc the class the inherited member belongs to 1.628 + * @param nestedClass the inherited member that is summarized 1.629 + * @param isFirst true if this is the first member in the list 1.630 + * @param isLast true if this is the last member in the list 1.631 + * @param linksTree the content tree to which the summary will be added 1.632 + */ 1.633 + public void addInheritedMemberSummary(ClassDoc classDoc, 1.634 + ProgramElementDoc nestedClass, boolean isFirst, boolean isLast, 1.635 + Content linksTree) { 1.636 + writer.addInheritedMemberSummary(this, classDoc, nestedClass, isFirst, 1.637 + linksTree); 1.638 + } 1.639 + 1.640 + /** 1.641 + * Get the inherited summary header for the given class. 1.642 + * 1.643 + * @param classDoc the class the inherited member belongs to 1.644 + * @return a content tree for the inherited summary header 1.645 + */ 1.646 + public Content getInheritedSummaryHeader(ClassDoc classDoc) { 1.647 + Content inheritedTree = writer.getMemberTreeHeader(); 1.648 + writer.addInheritedSummaryHeader(this, classDoc, inheritedTree); 1.649 + return inheritedTree; 1.650 + } 1.651 + 1.652 + /** 1.653 + * Get the inherited summary links tree. 1.654 + * 1.655 + * @return a content tree for the inherited summary links 1.656 + */ 1.657 + public Content getInheritedSummaryLinksTree() { 1.658 + return new HtmlTree(HtmlTag.CODE); 1.659 + } 1.660 + 1.661 + /** 1.662 + * Get the summary table tree for the given class. 1.663 + * 1.664 + * @param classDoc the class for which the summary table is generated 1.665 + * @param tableContents list of contents to be displayed in the summary table 1.666 + * @return a content tree for the summary table 1.667 + */ 1.668 + public Content getSummaryTableTree(ClassDoc classDoc, List<Content> tableContents) { 1.669 + return writer.getSummaryTableTree(this, classDoc, tableContents, showTabs()); 1.670 + } 1.671 + 1.672 + /** 1.673 + * Get the member tree to be documented. 1.674 + * 1.675 + * @param memberTree the content tree of member to be documented 1.676 + * @return a content tree that will be added to the class documentation 1.677 + */ 1.678 + public Content getMemberTree(Content memberTree) { 1.679 + return writer.getMemberTree(memberTree); 1.680 + } 1.681 + 1.682 + /** 1.683 + * Get the member tree to be documented. 1.684 + * 1.685 + * @param memberTree the content tree of member to be documented 1.686 + * @param isLastContent true if the content to be added is the last content 1.687 + * @return a content tree that will be added to the class documentation 1.688 + */ 1.689 + public Content getMemberTree(Content memberTree, boolean isLastContent) { 1.690 + if (isLastContent) 1.691 + return HtmlTree.UL(HtmlStyle.blockListLast, memberTree); 1.692 + else 1.693 + return HtmlTree.UL(HtmlStyle.blockList, memberTree); 1.694 + } 1.695 +}