Tue, 14 May 2013 10:14:54 -0700
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
Reviewed-by: darcy
duke@1 | 1 | /* |
jjg@1735 | 2 | * Copyright (c) 1997, 2013, 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@233 | 29 | |
bpatel@233 | 30 | import com.sun.javadoc.*; |
bpatel@766 | 31 | import com.sun.tools.doclets.formats.html.markup.*; |
duke@1 | 32 | import com.sun.tools.doclets.internal.toolkit.*; |
duke@1 | 33 | import com.sun.tools.doclets.internal.toolkit.util.*; |
duke@1 | 34 | |
duke@1 | 35 | /** |
duke@1 | 36 | * Writes nested class documentation in HTML format. |
duke@1 | 37 | * |
jjg@1359 | 38 | * <p><b>This is NOT part of any supported API. |
jjg@1359 | 39 | * If you write code that depends on this, you do so at your own risk. |
jjg@1359 | 40 | * This code and its internal interfaces are subject to change or |
jjg@1359 | 41 | * deletion without notice.</b> |
jjg@1359 | 42 | * |
duke@1 | 43 | * @author Robert Field |
duke@1 | 44 | * @author Atul M Dambalkar |
duke@1 | 45 | * @author Jamie Ho (rewrite) |
bpatel@243 | 46 | * @author Bhavesh Patel (Modified) |
duke@1 | 47 | */ |
duke@1 | 48 | public class NestedClassWriterImpl extends AbstractMemberWriter |
duke@1 | 49 | implements MemberSummaryWriter { |
duke@1 | 50 | |
duke@1 | 51 | public NestedClassWriterImpl(SubWriterHolderWriter writer, |
duke@1 | 52 | ClassDoc classdoc) { |
duke@1 | 53 | super(writer, classdoc); |
duke@1 | 54 | } |
duke@1 | 55 | |
duke@1 | 56 | public NestedClassWriterImpl(SubWriterHolderWriter writer) { |
duke@1 | 57 | super(writer); |
duke@1 | 58 | } |
duke@1 | 59 | |
duke@1 | 60 | /** |
duke@1 | 61 | * {@inheritDoc} |
duke@1 | 62 | */ |
bpatel@766 | 63 | public Content getMemberSummaryHeader(ClassDoc classDoc, |
bpatel@766 | 64 | Content memberSummaryTree) { |
bpatel@766 | 65 | memberSummaryTree.addContent(HtmlConstants.START_OF_NESTED_CLASS_SUMMARY); |
bpatel@766 | 66 | Content memberTree = writer.getMemberTreeHeader(); |
bpatel@766 | 67 | writer.addSummaryHeader(this, classDoc, memberTree); |
bpatel@766 | 68 | return memberTree; |
duke@1 | 69 | } |
duke@1 | 70 | |
duke@1 | 71 | /** |
duke@1 | 72 | * Close the writer. |
duke@1 | 73 | */ |
duke@1 | 74 | public void close() throws IOException { |
duke@1 | 75 | writer.close(); |
duke@1 | 76 | } |
duke@1 | 77 | |
duke@1 | 78 | public int getMemberKind() { |
duke@1 | 79 | return VisibleMemberMap.INNERCLASSES; |
duke@1 | 80 | } |
duke@1 | 81 | |
bpatel@766 | 82 | /** |
bpatel@766 | 83 | * {@inheritDoc} |
bpatel@766 | 84 | */ |
bpatel@766 | 85 | public void addSummaryLabel(Content memberTree) { |
bpatel@766 | 86 | Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING, |
bpatel@766 | 87 | writer.getResource("doclet.Nested_Class_Summary")); |
bpatel@766 | 88 | memberTree.addContent(label); |
bpatel@243 | 89 | } |
bpatel@243 | 90 | |
bpatel@766 | 91 | /** |
bpatel@766 | 92 | * {@inheritDoc} |
bpatel@766 | 93 | */ |
bpatel@766 | 94 | public String getTableSummary() { |
jjg@1410 | 95 | return configuration.getText("doclet.Member_Table_Summary", |
jjg@1410 | 96 | configuration.getText("doclet.Nested_Class_Summary"), |
jjg@1410 | 97 | configuration.getText("doclet.nested_classes")); |
bpatel@243 | 98 | } |
bpatel@243 | 99 | |
bpatel@766 | 100 | /** |
bpatel@766 | 101 | * {@inheritDoc} |
bpatel@766 | 102 | */ |
bpatel@766 | 103 | public String getCaption() { |
jjg@1410 | 104 | return configuration.getText("doclet.Nested_Classes"); |
bpatel@766 | 105 | } |
bpatel@766 | 106 | |
bpatel@766 | 107 | /** |
bpatel@766 | 108 | * {@inheritDoc} |
bpatel@766 | 109 | */ |
bpatel@766 | 110 | public String[] getSummaryTableHeader(ProgramElementDoc member) { |
bpatel@243 | 111 | String[] header; |
bpatel@243 | 112 | if (member.isInterface()) { |
bpatel@243 | 113 | header = new String[] { |
bpatel@243 | 114 | writer.getModifierTypeHeader(), |
jjg@1410 | 115 | configuration.getText("doclet.0_and_1", |
jjg@1410 | 116 | configuration.getText("doclet.Interface"), |
jjg@1410 | 117 | configuration.getText("doclet.Description")) |
bpatel@243 | 118 | }; |
bpatel@243 | 119 | } |
bpatel@243 | 120 | else { |
bpatel@243 | 121 | header = new String[] { |
bpatel@243 | 122 | writer.getModifierTypeHeader(), |
jjg@1410 | 123 | configuration.getText("doclet.0_and_1", |
jjg@1410 | 124 | configuration.getText("doclet.Class"), |
jjg@1410 | 125 | configuration.getText("doclet.Description")) |
bpatel@243 | 126 | }; |
bpatel@243 | 127 | } |
bpatel@766 | 128 | return header; |
duke@1 | 129 | } |
duke@1 | 130 | |
bpatel@766 | 131 | /** |
bpatel@766 | 132 | * {@inheritDoc} |
bpatel@766 | 133 | */ |
bpatel@766 | 134 | public void addSummaryAnchor(ClassDoc cd, Content memberTree) { |
bpatel@766 | 135 | memberTree.addContent(writer.getMarkerAnchor("nested_class_summary")); |
duke@1 | 136 | } |
duke@1 | 137 | |
bpatel@766 | 138 | /** |
bpatel@766 | 139 | * {@inheritDoc} |
bpatel@766 | 140 | */ |
bpatel@766 | 141 | public void addInheritedSummaryAnchor(ClassDoc cd, Content inheritedTree) { |
bpatel@766 | 142 | inheritedTree.addContent(writer.getMarkerAnchor( |
bpatel@766 | 143 | "nested_classes_inherited_from_class_" + cd.qualifiedName())); |
duke@1 | 144 | } |
duke@1 | 145 | |
bpatel@766 | 146 | /** |
bpatel@766 | 147 | * {@inheritDoc} |
bpatel@766 | 148 | */ |
bpatel@766 | 149 | public void addInheritedSummaryLabel(ClassDoc cd, Content inheritedTree) { |
jjg@1737 | 150 | Content classLink = writer.getPreQualifiedClassLink( |
jjg@1737 | 151 | LinkInfoImpl.Kind.MEMBER, cd, false); |
bpatel@766 | 152 | Content label = new StringContent(cd.isInterface() ? |
jjg@1410 | 153 | configuration.getText("doclet.Nested_Classes_Interface_Inherited_From_Interface") : |
jjg@1410 | 154 | configuration.getText("doclet.Nested_Classes_Interfaces_Inherited_From_Class")); |
bpatel@766 | 155 | Content labelHeading = HtmlTree.HEADING(HtmlConstants.INHERITED_SUMMARY_HEADING, |
bpatel@766 | 156 | label); |
bpatel@766 | 157 | labelHeading.addContent(writer.getSpace()); |
bpatel@766 | 158 | labelHeading.addContent(classLink); |
bpatel@766 | 159 | inheritedTree.addContent(labelHeading); |
duke@1 | 160 | } |
duke@1 | 161 | |
bpatel@766 | 162 | /** |
bpatel@766 | 163 | * {@inheritDoc} |
bpatel@766 | 164 | */ |
jjg@1735 | 165 | protected void addSummaryLink(LinkInfoImpl.Kind context, ClassDoc cd, ProgramElementDoc member, |
bpatel@766 | 166 | Content tdSummary) { |
jjg@1736 | 167 | Content strong = HtmlTree.STRONG( |
jjg@1738 | 168 | writer.getLink(new LinkInfoImpl(configuration, context, (ClassDoc)member))); |
bpatel@766 | 169 | Content code = HtmlTree.CODE(strong); |
bpatel@766 | 170 | tdSummary.addContent(code); |
duke@1 | 171 | } |
duke@1 | 172 | |
bpatel@766 | 173 | /** |
bpatel@766 | 174 | * {@inheritDoc} |
bpatel@766 | 175 | */ |
bpatel@766 | 176 | protected void addInheritedSummaryLink(ClassDoc cd, |
bpatel@766 | 177 | ProgramElementDoc member, Content linksTree) { |
jjg@1736 | 178 | linksTree.addContent( |
jjg@1735 | 179 | writer.getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.MEMBER, |
jjg@1738 | 180 | (ClassDoc)member))); |
duke@1 | 181 | } |
duke@1 | 182 | |
bpatel@766 | 183 | /** |
bpatel@766 | 184 | * {@inheritDoc} |
bpatel@766 | 185 | */ |
bpatel@766 | 186 | protected void addSummaryType(ProgramElementDoc member, |
bpatel@766 | 187 | Content tdSummaryType) { |
duke@1 | 188 | ClassDoc cd = (ClassDoc)member; |
bpatel@766 | 189 | addModifierAndType(cd, null, tdSummaryType); |
duke@1 | 190 | } |
duke@1 | 191 | |
bpatel@766 | 192 | /** |
bpatel@766 | 193 | * {@inheritDoc} |
bpatel@766 | 194 | */ |
bpatel@766 | 195 | protected Content getDeprecatedLink(ProgramElementDoc member) { |
jjg@1735 | 196 | return writer.getQualifiedClassLink(LinkInfoImpl.Kind.MEMBER, |
bpatel@766 | 197 | (ClassDoc)member); |
duke@1 | 198 | } |
duke@1 | 199 | |
bpatel@766 | 200 | /** |
bpatel@766 | 201 | * {@inheritDoc} |
bpatel@766 | 202 | */ |
bpatel@766 | 203 | protected Content getNavSummaryLink(ClassDoc cd, boolean link) { |
duke@1 | 204 | if (link) { |
jjg@1372 | 205 | return writer.getHyperLink((cd == null) ? "nested_class_summary": |
jjg@1372 | 206 | "nested_classes_inherited_from_class_" + cd.qualifiedName(), |
bpatel@766 | 207 | writer.getResource("doclet.navNested")); |
duke@1 | 208 | } else { |
bpatel@766 | 209 | return writer.getResource("doclet.navNested"); |
duke@1 | 210 | } |
duke@1 | 211 | } |
duke@1 | 212 | |
bpatel@766 | 213 | /** |
bpatel@766 | 214 | * {@inheritDoc} |
bpatel@766 | 215 | */ |
bpatel@766 | 216 | protected void addNavDetailLink(boolean link, Content liNav) { |
duke@1 | 217 | } |
duke@1 | 218 | } |