Thu, 13 Jan 2011 21:28:38 -0800
7010528: javadoc performance regression
Reviewed-by: jjg
duke@1 | 1 | /* |
ohair@798 | 2 | * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. |
duke@1 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@1 | 4 | * |
duke@1 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@1 | 6 | * under the terms of the GNU General Public License version 2 only, as |
ohair@554 | 7 | * published by the Free Software Foundation. Oracle designates this |
duke@1 | 8 | * particular file as subject to the "Classpath" exception as provided |
ohair@554 | 9 | * by Oracle in the LICENSE file that accompanied this code. |
duke@1 | 10 | * |
duke@1 | 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@1 | 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@1 | 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@1 | 14 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@1 | 15 | * accompanied this code). |
duke@1 | 16 | * |
duke@1 | 17 | * You should have received a copy of the GNU General Public License version |
duke@1 | 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@1 | 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@1 | 20 | * |
ohair@554 | 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ohair@554 | 22 | * or visit www.oracle.com if you need additional information or have any |
ohair@554 | 23 | * questions. |
duke@1 | 24 | */ |
duke@1 | 25 | |
duke@1 | 26 | package com.sun.tools.doclets.formats.html; |
duke@1 | 27 | |
bpatel@233 | 28 | import java.io.*; |
bpatel@766 | 29 | import java.util.*; |
bpatel@233 | 30 | |
bpatel@233 | 31 | import com.sun.javadoc.*; |
bpatel@766 | 32 | import com.sun.tools.doclets.formats.html.markup.*; |
duke@1 | 33 | import com.sun.tools.doclets.internal.toolkit.*; |
duke@1 | 34 | import com.sun.tools.doclets.internal.toolkit.util.*; |
duke@1 | 35 | |
duke@1 | 36 | /** |
duke@1 | 37 | * Writes nested class documentation in HTML format. |
duke@1 | 38 | * |
duke@1 | 39 | * @author Robert Field |
duke@1 | 40 | * @author Atul M Dambalkar |
duke@1 | 41 | * @author Jamie Ho (rewrite) |
bpatel@243 | 42 | * @author Bhavesh Patel (Modified) |
duke@1 | 43 | */ |
duke@1 | 44 | public class NestedClassWriterImpl extends AbstractMemberWriter |
duke@1 | 45 | implements MemberSummaryWriter { |
duke@1 | 46 | |
duke@1 | 47 | public NestedClassWriterImpl(SubWriterHolderWriter writer, |
duke@1 | 48 | ClassDoc classdoc) { |
duke@1 | 49 | super(writer, classdoc); |
duke@1 | 50 | } |
duke@1 | 51 | |
duke@1 | 52 | public NestedClassWriterImpl(SubWriterHolderWriter writer) { |
duke@1 | 53 | super(writer); |
duke@1 | 54 | } |
duke@1 | 55 | |
duke@1 | 56 | /** |
duke@1 | 57 | * {@inheritDoc} |
duke@1 | 58 | */ |
bpatel@766 | 59 | public Content getMemberSummaryHeader(ClassDoc classDoc, |
bpatel@766 | 60 | Content memberSummaryTree) { |
bpatel@766 | 61 | memberSummaryTree.addContent(HtmlConstants.START_OF_NESTED_CLASS_SUMMARY); |
bpatel@766 | 62 | Content memberTree = writer.getMemberTreeHeader(); |
bpatel@766 | 63 | writer.addSummaryHeader(this, classDoc, memberTree); |
bpatel@766 | 64 | return memberTree; |
duke@1 | 65 | } |
duke@1 | 66 | |
duke@1 | 67 | /** |
duke@1 | 68 | * Close the writer. |
duke@1 | 69 | */ |
duke@1 | 70 | public void close() throws IOException { |
duke@1 | 71 | writer.close(); |
duke@1 | 72 | } |
duke@1 | 73 | |
duke@1 | 74 | public int getMemberKind() { |
duke@1 | 75 | return VisibleMemberMap.INNERCLASSES; |
duke@1 | 76 | } |
duke@1 | 77 | |
bpatel@766 | 78 | /** |
bpatel@766 | 79 | * {@inheritDoc} |
bpatel@766 | 80 | */ |
bpatel@766 | 81 | public void addSummaryLabel(Content memberTree) { |
bpatel@766 | 82 | Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING, |
bpatel@766 | 83 | writer.getResource("doclet.Nested_Class_Summary")); |
bpatel@766 | 84 | memberTree.addContent(label); |
bpatel@243 | 85 | } |
bpatel@243 | 86 | |
bpatel@766 | 87 | /** |
bpatel@766 | 88 | * {@inheritDoc} |
bpatel@766 | 89 | */ |
bpatel@766 | 90 | public String getTableSummary() { |
bpatel@766 | 91 | return configuration().getText("doclet.Member_Table_Summary", |
bpatel@243 | 92 | configuration().getText("doclet.Nested_Class_Summary"), |
bpatel@766 | 93 | configuration().getText("doclet.nested_classes")); |
bpatel@243 | 94 | } |
bpatel@243 | 95 | |
bpatel@766 | 96 | /** |
bpatel@766 | 97 | * {@inheritDoc} |
bpatel@766 | 98 | */ |
bpatel@766 | 99 | public String getCaption() { |
bpatel@766 | 100 | return configuration().getText("doclet.Nested_Classes"); |
bpatel@766 | 101 | } |
bpatel@766 | 102 | |
bpatel@766 | 103 | /** |
bpatel@766 | 104 | * {@inheritDoc} |
bpatel@766 | 105 | */ |
bpatel@766 | 106 | public String[] getSummaryTableHeader(ProgramElementDoc member) { |
bpatel@243 | 107 | String[] header; |
bpatel@243 | 108 | if (member.isInterface()) { |
bpatel@243 | 109 | header = new String[] { |
bpatel@243 | 110 | writer.getModifierTypeHeader(), |
bpatel@243 | 111 | configuration().getText("doclet.0_and_1", |
bpatel@243 | 112 | configuration().getText("doclet.Interface"), |
bpatel@243 | 113 | configuration().getText("doclet.Description")) |
bpatel@243 | 114 | }; |
bpatel@243 | 115 | } |
bpatel@243 | 116 | else { |
bpatel@243 | 117 | header = new String[] { |
bpatel@243 | 118 | writer.getModifierTypeHeader(), |
bpatel@243 | 119 | configuration().getText("doclet.0_and_1", |
bpatel@243 | 120 | configuration().getText("doclet.Class"), |
bpatel@243 | 121 | configuration().getText("doclet.Description")) |
bpatel@243 | 122 | }; |
bpatel@243 | 123 | } |
bpatel@766 | 124 | return header; |
duke@1 | 125 | } |
duke@1 | 126 | |
bpatel@766 | 127 | /** |
bpatel@766 | 128 | * {@inheritDoc} |
bpatel@766 | 129 | */ |
bpatel@766 | 130 | public void addSummaryAnchor(ClassDoc cd, Content memberTree) { |
bpatel@766 | 131 | memberTree.addContent(writer.getMarkerAnchor("nested_class_summary")); |
duke@1 | 132 | } |
duke@1 | 133 | |
bpatel@766 | 134 | /** |
bpatel@766 | 135 | * {@inheritDoc} |
bpatel@766 | 136 | */ |
bpatel@766 | 137 | public void addInheritedSummaryAnchor(ClassDoc cd, Content inheritedTree) { |
bpatel@766 | 138 | inheritedTree.addContent(writer.getMarkerAnchor( |
bpatel@766 | 139 | "nested_classes_inherited_from_class_" + cd.qualifiedName())); |
duke@1 | 140 | } |
duke@1 | 141 | |
bpatel@766 | 142 | /** |
bpatel@766 | 143 | * {@inheritDoc} |
bpatel@766 | 144 | */ |
bpatel@766 | 145 | public void addInheritedSummaryLabel(ClassDoc cd, Content inheritedTree) { |
bpatel@766 | 146 | Content classLink = new RawHtml(writer.getPreQualifiedClassLink( |
bpatel@766 | 147 | LinkInfoImpl.CONTEXT_MEMBER, cd, false)); |
bpatel@766 | 148 | Content label = new StringContent(cd.isInterface() ? |
bpatel@766 | 149 | configuration().getText("doclet.Nested_Classes_Interface_Inherited_From_Interface") : |
bpatel@766 | 150 | configuration().getText("doclet.Nested_Classes_Interfaces_Inherited_From_Class")); |
bpatel@766 | 151 | Content labelHeading = HtmlTree.HEADING(HtmlConstants.INHERITED_SUMMARY_HEADING, |
bpatel@766 | 152 | label); |
bpatel@766 | 153 | labelHeading.addContent(writer.getSpace()); |
bpatel@766 | 154 | labelHeading.addContent(classLink); |
bpatel@766 | 155 | inheritedTree.addContent(labelHeading); |
duke@1 | 156 | } |
duke@1 | 157 | |
bpatel@766 | 158 | /** |
bpatel@766 | 159 | * {@inheritDoc} |
bpatel@766 | 160 | */ |
bpatel@766 | 161 | protected void addSummaryLink(int context, ClassDoc cd, ProgramElementDoc member, |
bpatel@766 | 162 | Content tdSummary) { |
bpatel@766 | 163 | Content strong = HtmlTree.STRONG(new RawHtml( |
bpatel@766 | 164 | writer.getLink(new LinkInfoImpl(context, (ClassDoc)member, false)))); |
bpatel@766 | 165 | Content code = HtmlTree.CODE(strong); |
bpatel@766 | 166 | tdSummary.addContent(code); |
duke@1 | 167 | } |
duke@1 | 168 | |
bpatel@766 | 169 | /** |
bpatel@766 | 170 | * {@inheritDoc} |
bpatel@766 | 171 | */ |
bpatel@766 | 172 | protected void addInheritedSummaryLink(ClassDoc cd, |
bpatel@766 | 173 | ProgramElementDoc member, Content linksTree) { |
bpatel@766 | 174 | linksTree.addContent(new RawHtml( |
bpatel@766 | 175 | writer.getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER, |
bpatel@766 | 176 | (ClassDoc)member, false)))); |
duke@1 | 177 | } |
duke@1 | 178 | |
bpatel@766 | 179 | /** |
bpatel@766 | 180 | * {@inheritDoc} |
bpatel@766 | 181 | */ |
bpatel@766 | 182 | protected void addSummaryType(ProgramElementDoc member, |
bpatel@766 | 183 | Content tdSummaryType) { |
duke@1 | 184 | ClassDoc cd = (ClassDoc)member; |
bpatel@766 | 185 | addModifierAndType(cd, null, tdSummaryType); |
duke@1 | 186 | } |
duke@1 | 187 | |
bpatel@766 | 188 | /** |
bpatel@766 | 189 | * {@inheritDoc} |
bpatel@766 | 190 | */ |
bpatel@766 | 191 | protected Content getDeprecatedLink(ProgramElementDoc member) { |
bpatel@766 | 192 | return writer.getQualifiedClassLink(LinkInfoImpl.CONTEXT_MEMBER, |
bpatel@766 | 193 | (ClassDoc)member); |
duke@1 | 194 | } |
duke@1 | 195 | |
bpatel@766 | 196 | /** |
bpatel@766 | 197 | * {@inheritDoc} |
bpatel@766 | 198 | */ |
bpatel@766 | 199 | protected Content getNavSummaryLink(ClassDoc cd, boolean link) { |
duke@1 | 200 | if (link) { |
bpatel@766 | 201 | return writer.getHyperLink("", (cd == null) ? "nested_class_summary": |
bpatel@766 | 202 | "nested_classes_inherited_from_class_" + |
duke@1 | 203 | cd.qualifiedName(), |
bpatel@766 | 204 | writer.getResource("doclet.navNested")); |
duke@1 | 205 | } else { |
bpatel@766 | 206 | return writer.getResource("doclet.navNested"); |
duke@1 | 207 | } |
duke@1 | 208 | } |
duke@1 | 209 | |
bpatel@766 | 210 | /** |
bpatel@766 | 211 | * {@inheritDoc} |
bpatel@766 | 212 | */ |
bpatel@766 | 213 | protected void addNavDetailLink(boolean link, Content liNav) { |
duke@1 | 214 | } |
duke@1 | 215 | } |