Tue, 14 May 2013 10:14:54 -0700
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
Reviewed-by: darcy
duke@1 | 1 | /* |
bpatel@1568 | 2 | * Copyright (c) 1998, 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 | |
duke@1 | 28 | import java.io.*; |
duke@1 | 29 | import java.util.*; |
jjg@1372 | 30 | |
bpatel@766 | 31 | import com.sun.javadoc.*; |
bpatel@766 | 32 | import com.sun.tools.doclets.formats.html.markup.*; |
bpatel@766 | 33 | import com.sun.tools.doclets.internal.toolkit.*; |
jjg@1372 | 34 | import com.sun.tools.doclets.internal.toolkit.util.DocPath; |
duke@1 | 35 | |
duke@1 | 36 | /** |
duke@1 | 37 | * Abstract class to generate the overview files in |
duke@1 | 38 | * Frame and Non-Frame format. This will be sub-classed by to |
duke@1 | 39 | * generate overview-frame.html as well as overview-summary.html. |
duke@1 | 40 | * |
jjg@1359 | 41 | * <p><b>This is NOT part of any supported API. |
jjg@1359 | 42 | * If you write code that depends on this, you do so at your own risk. |
jjg@1359 | 43 | * This code and its internal interfaces are subject to change or |
jjg@1359 | 44 | * deletion without notice.</b> |
jjg@1359 | 45 | * |
duke@1 | 46 | * @author Atul M Dambalkar |
bpatel@243 | 47 | * @author Bhavesh Patel (Modified) |
duke@1 | 48 | */ |
duke@1 | 49 | public abstract class AbstractPackageIndexWriter extends HtmlDocletWriter { |
duke@1 | 50 | |
duke@1 | 51 | /** |
duke@1 | 52 | * Array of Packages to be documented. |
duke@1 | 53 | */ |
duke@1 | 54 | protected PackageDoc[] packages; |
duke@1 | 55 | |
duke@1 | 56 | /** |
jjg@1372 | 57 | * Constructor. Also initializes the packages variable. |
duke@1 | 58 | * |
jjg@1372 | 59 | * @param configuration The current configuration |
duke@1 | 60 | * @param filename Name of the package index file to be generated. |
duke@1 | 61 | */ |
duke@1 | 62 | public AbstractPackageIndexWriter(ConfigurationImpl configuration, |
jjg@1372 | 63 | DocPath filename) throws IOException { |
duke@1 | 64 | super(configuration, filename); |
duke@1 | 65 | packages = configuration.packages; |
duke@1 | 66 | } |
duke@1 | 67 | |
bpatel@766 | 68 | /** |
bpatel@766 | 69 | * Adds the navigation bar header to the documentation tree. |
bpatel@766 | 70 | * |
bpatel@766 | 71 | * @param body the document tree to which the navigation bar header will be added |
bpatel@766 | 72 | */ |
bpatel@766 | 73 | protected abstract void addNavigationBarHeader(Content body); |
duke@1 | 74 | |
duke@1 | 75 | /** |
bpatel@766 | 76 | * Adds the navigation bar footer to the documentation tree. |
bpatel@766 | 77 | * |
bpatel@766 | 78 | * @param body the document tree to which the navigation bar footer will be added |
bpatel@766 | 79 | */ |
bpatel@766 | 80 | protected abstract void addNavigationBarFooter(Content body); |
bpatel@766 | 81 | |
bpatel@766 | 82 | /** |
bpatel@766 | 83 | * Adds the overview header to the documentation tree. |
bpatel@766 | 84 | * |
bpatel@766 | 85 | * @param body the document tree to which the overview header will be added |
bpatel@766 | 86 | */ |
bpatel@766 | 87 | protected abstract void addOverviewHeader(Content body); |
bpatel@766 | 88 | |
bpatel@766 | 89 | /** |
bpatel@766 | 90 | * Adds the packages list to the documentation tree. |
bpatel@766 | 91 | * |
bpatel@766 | 92 | * @param packages an array of packagedoc objects |
bpatel@766 | 93 | * @param text caption for the table |
bpatel@766 | 94 | * @param tableSummary summary for the table |
bpatel@766 | 95 | * @param body the document tree to which the packages list will be added |
bpatel@766 | 96 | */ |
bpatel@766 | 97 | protected abstract void addPackagesList(PackageDoc[] packages, String text, |
bpatel@766 | 98 | String tableSummary, Content body); |
bpatel@766 | 99 | |
bpatel@766 | 100 | /** |
bpatel@766 | 101 | * Generate and prints the contents in the package index file. Call appropriate |
duke@1 | 102 | * methods from the sub-class in order to generate Frame or Non |
duke@1 | 103 | * Frame format. |
bpatel@766 | 104 | * |
duke@1 | 105 | * @param title the title of the window. |
duke@1 | 106 | * @param includeScript boolean set true if windowtitle script is to be included |
duke@1 | 107 | */ |
bpatel@766 | 108 | protected void buildPackageIndexFile(String title, boolean includeScript) throws IOException { |
duke@1 | 109 | String windowOverview = configuration.getText(title); |
bpatel@766 | 110 | Content body = getBody(includeScript, getWindowTitle(windowOverview)); |
bpatel@766 | 111 | addNavigationBarHeader(body); |
bpatel@766 | 112 | addOverviewHeader(body); |
bpatel@766 | 113 | addIndex(body); |
bpatel@766 | 114 | addOverview(body); |
bpatel@766 | 115 | addNavigationBarFooter(body); |
bpatel@766 | 116 | printHtmlDocument(configuration.metakeywords.getOverviewMetaKeywords(title, |
bpatel@766 | 117 | configuration.doctitle), includeScript, body); |
duke@1 | 118 | } |
duke@1 | 119 | |
duke@1 | 120 | /** |
bpatel@766 | 121 | * Default to no overview, override to add overview. |
bpatel@766 | 122 | * |
bpatel@766 | 123 | * @param body the document tree to which the overview will be added |
duke@1 | 124 | */ |
bpatel@766 | 125 | protected void addOverview(Content body) throws IOException { |
duke@1 | 126 | } |
duke@1 | 127 | |
duke@1 | 128 | /** |
bpatel@766 | 129 | * Adds the frame or non-frame package index to the documentation tree. |
bpatel@766 | 130 | * |
bpatel@766 | 131 | * @param body the document tree to which the index will be added |
duke@1 | 132 | */ |
bpatel@766 | 133 | protected void addIndex(Content body) { |
bpatel@766 | 134 | addIndexContents(packages, "doclet.Package_Summary", |
bpatel@243 | 135 | configuration.getText("doclet.Member_Table_Summary", |
bpatel@243 | 136 | configuration.getText("doclet.Package_Summary"), |
bpatel@766 | 137 | configuration.getText("doclet.packages")), body); |
duke@1 | 138 | } |
duke@1 | 139 | |
duke@1 | 140 | /** |
bpatel@766 | 141 | * Adds package index contents. Call appropriate methods from |
bpatel@766 | 142 | * the sub-classes. Adds it to the body HtmlTree |
duke@1 | 143 | * |
bpatel@766 | 144 | * @param packages array of packages to be documented |
bpatel@766 | 145 | * @param text string which will be used as the heading |
bpatel@766 | 146 | * @param tableSummary summary for the table |
bpatel@766 | 147 | * @param body the document tree to which the index contents will be added |
duke@1 | 148 | */ |
bpatel@766 | 149 | protected void addIndexContents(PackageDoc[] packages, String text, |
bpatel@766 | 150 | String tableSummary, Content body) { |
duke@1 | 151 | if (packages.length > 0) { |
duke@1 | 152 | Arrays.sort(packages); |
bpatel@1568 | 153 | HtmlTree div = new HtmlTree(HtmlTag.DIV); |
bpatel@1568 | 154 | div.addStyle(HtmlStyle.indexHeader); |
bpatel@1568 | 155 | addAllClassesLink(div); |
bpatel@1568 | 156 | if (configuration.showProfiles) { |
bpatel@1568 | 157 | addAllProfilesLink(div); |
bpatel@1568 | 158 | } |
bpatel@1568 | 159 | body.addContent(div); |
bpatel@1568 | 160 | if (configuration.showProfiles) { |
bpatel@1568 | 161 | String profileSummary = configuration.getText("doclet.Profiles"); |
bpatel@1568 | 162 | String profilesTableSummary = configuration.getText("doclet.Member_Table_Summary", |
bpatel@1568 | 163 | configuration.getText("doclet.Profile_Summary"), |
bpatel@1568 | 164 | configuration.getText("doclet.profiles")); |
bpatel@1568 | 165 | addProfilesList(profileSummary, profilesTableSummary, body); |
bpatel@1568 | 166 | } |
bpatel@766 | 167 | addPackagesList(packages, text, tableSummary, body); |
duke@1 | 168 | } |
duke@1 | 169 | } |
duke@1 | 170 | |
duke@1 | 171 | /** |
bpatel@766 | 172 | * Adds the doctitle to the documentation tree, if it is specified on the command line. |
bpatel@766 | 173 | * |
bpatel@766 | 174 | * @param body the document tree to which the title will be added |
duke@1 | 175 | */ |
bpatel@766 | 176 | protected void addConfigurationTitle(Content body) { |
duke@1 | 177 | if (configuration.doctitle.length() > 0) { |
bpatel@766 | 178 | Content title = new RawHtml(configuration.doctitle); |
bpatel@766 | 179 | Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, |
bpatel@766 | 180 | HtmlStyle.title, title); |
bpatel@766 | 181 | Content div = HtmlTree.DIV(HtmlStyle.header, heading); |
bpatel@766 | 182 | body.addContent(div); |
duke@1 | 183 | } |
duke@1 | 184 | } |
duke@1 | 185 | |
duke@1 | 186 | /** |
bpatel@766 | 187 | * Returns highlighted "Overview", in the navigation bar as this is the |
bpatel@766 | 188 | * overview page. |
bpatel@766 | 189 | * |
bpatel@766 | 190 | * @return a Content object to be added to the documentation tree |
duke@1 | 191 | */ |
bpatel@766 | 192 | protected Content getNavLinkContents() { |
bpatel@766 | 193 | Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, overviewLabel); |
bpatel@766 | 194 | return li; |
duke@1 | 195 | } |
duke@1 | 196 | |
duke@1 | 197 | /** |
bpatel@1568 | 198 | * Do nothing. This will be overridden. |
bpatel@766 | 199 | * |
bpatel@1568 | 200 | * @param div the document tree to which the all classes link will be added |
duke@1 | 201 | */ |
bpatel@1568 | 202 | protected void addAllClassesLink(Content div) { |
bpatel@1568 | 203 | } |
bpatel@1568 | 204 | |
bpatel@1568 | 205 | /** |
bpatel@1568 | 206 | * Do nothing. This will be overridden. |
bpatel@1568 | 207 | * |
bpatel@1568 | 208 | * @param div the document tree to which the all profiles link will be added |
bpatel@1568 | 209 | */ |
bpatel@1568 | 210 | protected void addAllProfilesLink(Content div) { |
bpatel@1568 | 211 | } |
bpatel@1568 | 212 | |
bpatel@1568 | 213 | /** |
bpatel@1568 | 214 | * Do nothing. This will be overridden. |
bpatel@1568 | 215 | * |
bpatel@1568 | 216 | * @param profileSummary the profile summary heading |
bpatel@1568 | 217 | * @param profilesTableSummary the profiles table summary information |
bpatel@1568 | 218 | * @param body the content tree to which the profiles list will be added |
bpatel@1568 | 219 | */ |
bpatel@1568 | 220 | protected void addProfilesList(String profileSummary, String profilesTableSummary, |
bpatel@1568 | 221 | Content body) { |
duke@1 | 222 | } |
duke@1 | 223 | } |