src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java

Wed, 06 Jul 2016 20:07:09 -0700

author
bpatel
date
Wed, 06 Jul 2016 20:07:09 -0700
changeset 3258
fd9b6417c521
parent 2800
f6923d26b0fb
child 3295
859dc787b52b
child 3315
6f0746b6de9f
permissions
-rw-r--r--

8151921: Improved page resolution
Reviewed-by: jjg, ksrini

duke@1 1 /*
bpatel@1568 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.markup;
duke@1 27
bpatel@233 28 import java.io.*;
bpatel@1417 29 import java.util.*;
jjg@1740 30 import java.util.regex.Matcher;
jjg@1740 31 import java.util.regex.Pattern;
bpatel@233 32
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 * Class for the Html format code generation.
jjg@1365 38 * Initializes PrintWriter with FileWriter, to enable print
duke@1 39 * related methods to generate the code to the named File through FileWriter.
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 * @since 1.2
duke@1 47 * @author Atul M Dambalkar
bpatel@243 48 * @author Bhavesh Patel (Modified)
duke@1 49 */
jjg@1365 50 public class HtmlWriter {
duke@1 51
duke@1 52 /**
duke@1 53 * The window title of this file
duke@1 54 */
duke@1 55 protected String winTitle;
duke@1 56
duke@1 57 /**
duke@1 58 * The configuration
duke@1 59 */
duke@1 60 protected Configuration configuration;
duke@1 61
duke@1 62 /**
bpatel@233 63 * The flag to indicate whether a member details list is printed or not.
bpatel@233 64 */
bpatel@233 65 protected boolean memberDetailsListPrinted;
bpatel@233 66
bpatel@233 67 /**
bpatel@1568 68 * Header for table displaying profiles and description..
bpatel@1568 69 */
bpatel@1568 70 protected final String[] profileTableHeader;
bpatel@1568 71
bpatel@1568 72 /**
bpatel@243 73 * Header for tables displaying packages and description..
bpatel@243 74 */
bpatel@243 75 protected final String[] packageTableHeader;
bpatel@243 76
bpatel@243 77 /**
bpatel@243 78 * Summary for use tables displaying class and package use.
bpatel@243 79 */
bpatel@243 80 protected final String useTableSummary;
bpatel@243 81
bpatel@243 82 /**
bpatel@243 83 * Column header for class docs displaying Modifier and Type header.
bpatel@243 84 */
bpatel@243 85 protected final String modifierTypeHeader;
bpatel@243 86
bpatel@766 87 public final Content overviewLabel;
bpatel@766 88
bpatel@766 89 public final Content defaultPackageLabel;
bpatel@766 90
bpatel@766 91 public final Content packageLabel;
bpatel@766 92
bpatel@1568 93 public final Content profileLabel;
bpatel@1568 94
bpatel@766 95 public final Content useLabel;
bpatel@766 96
bpatel@766 97 public final Content prevLabel;
bpatel@766 98
bpatel@766 99 public final Content nextLabel;
bpatel@766 100
bpatel@766 101 public final Content prevclassLabel;
bpatel@766 102
bpatel@766 103 public final Content nextclassLabel;
bpatel@766 104
bpatel@766 105 public final Content summaryLabel;
bpatel@766 106
bpatel@766 107 public final Content detailLabel;
bpatel@766 108
bpatel@766 109 public final Content framesLabel;
bpatel@766 110
bpatel@766 111 public final Content noframesLabel;
bpatel@766 112
bpatel@766 113 public final Content treeLabel;
bpatel@766 114
bpatel@766 115 public final Content classLabel;
bpatel@766 116
bpatel@766 117 public final Content deprecatedLabel;
bpatel@766 118
bpatel@766 119 public final Content deprecatedPhrase;
bpatel@766 120
bpatel@766 121 public final Content allclassesLabel;
bpatel@766 122
bpatel@1568 123 public final Content allpackagesLabel;
bpatel@1568 124
bpatel@1568 125 public final Content allprofilesLabel;
bpatel@1568 126
bpatel@766 127 public final Content indexLabel;
bpatel@766 128
bpatel@766 129 public final Content helpLabel;
bpatel@766 130
bpatel@766 131 public final Content seeLabel;
bpatel@766 132
bpatel@766 133 public final Content descriptionLabel;
bpatel@766 134
bpatel@766 135 public final Content prevpackageLabel;
bpatel@766 136
bpatel@766 137 public final Content nextpackageLabel;
bpatel@766 138
bpatel@1568 139 public final Content prevprofileLabel;
bpatel@1568 140
bpatel@1568 141 public final Content nextprofileLabel;
bpatel@1568 142
bpatel@766 143 public final Content packagesLabel;
bpatel@766 144
bpatel@1568 145 public final Content profilesLabel;
bpatel@1568 146
bpatel@766 147 public final Content methodDetailsLabel;
bpatel@766 148
bpatel@766 149 public final Content annotationTypeDetailsLabel;
bpatel@766 150
bpatel@766 151 public final Content fieldDetailsLabel;
bpatel@766 152
jjg@1606 153 public final Content propertyDetailsLabel;
jjg@1606 154
bpatel@766 155 public final Content constructorDetailsLabel;
bpatel@766 156
bpatel@766 157 public final Content enumConstantsDetailsLabel;
bpatel@766 158
bpatel@766 159 public final Content specifiedByLabel;
bpatel@766 160
bpatel@766 161 public final Content overridesLabel;
bpatel@766 162
bpatel@766 163 public final Content descfrmClassLabel;
bpatel@766 164
bpatel@766 165 public final Content descfrmInterfaceLabel;
bpatel@766 166
jjg@1365 167 private final Writer writer;
jjg@1365 168
bpatel@1417 169 private Content script;
bpatel@1417 170
bpatel@243 171 /**
duke@1 172 * Constructor.
duke@1 173 *
duke@1 174 * @param path The directory path to be created for this file
duke@1 175 * or null if none to be created.
duke@1 176 * @exception IOException Exception raised by the FileWriter is passed on
duke@1 177 * to next level.
jjg@1358 178 * @exception UnsupportedEncodingException Exception raised by the
duke@1 179 * OutputStreamWriter is passed on to next level.
duke@1 180 */
jjg@1381 181 public HtmlWriter(Configuration configuration, DocPath path)
jjg@1372 182 throws IOException, UnsupportedEncodingException {
jjg@1383 183 writer = DocFile.createFileForOutput(configuration, path).openWriter();
duke@1 184 this.configuration = configuration;
bpatel@233 185 this.memberDetailsListPrinted = false;
bpatel@1568 186 profileTableHeader = new String[] {
bpatel@1568 187 configuration.getText("doclet.Profile"),
bpatel@1568 188 configuration.getText("doclet.Description")
bpatel@1568 189 };
bpatel@243 190 packageTableHeader = new String[] {
bpatel@243 191 configuration.getText("doclet.Package"),
bpatel@243 192 configuration.getText("doclet.Description")
bpatel@243 193 };
bpatel@243 194 useTableSummary = configuration.getText("doclet.Use_Table_Summary",
bpatel@243 195 configuration.getText("doclet.packages"));
bpatel@243 196 modifierTypeHeader = configuration.getText("doclet.0_and_1",
bpatel@243 197 configuration.getText("doclet.Modifier"),
bpatel@243 198 configuration.getText("doclet.Type"));
bpatel@766 199 overviewLabel = getResource("doclet.Overview");
jjg@1746 200 defaultPackageLabel = new StringContent(DocletConstants.DEFAULT_PACKAGE_NAME);
bpatel@766 201 packageLabel = getResource("doclet.Package");
bpatel@1568 202 profileLabel = getResource("doclet.Profile");
bpatel@766 203 useLabel = getResource("doclet.navClassUse");
bpatel@766 204 prevLabel = getResource("doclet.Prev");
bpatel@766 205 nextLabel = getResource("doclet.Next");
jjg@1993 206 prevclassLabel = getNonBreakResource("doclet.Prev_Class");
jjg@1993 207 nextclassLabel = getNonBreakResource("doclet.Next_Class");
bpatel@766 208 summaryLabel = getResource("doclet.Summary");
bpatel@766 209 detailLabel = getResource("doclet.Detail");
bpatel@942 210 framesLabel = getResource("doclet.Frames");
jjg@1993 211 noframesLabel = getNonBreakResource("doclet.No_Frames");
bpatel@766 212 treeLabel = getResource("doclet.Tree");
bpatel@766 213 classLabel = getResource("doclet.Class");
bpatel@766 214 deprecatedLabel = getResource("doclet.navDeprecated");
bpatel@766 215 deprecatedPhrase = getResource("doclet.Deprecated");
jjg@1993 216 allclassesLabel = getNonBreakResource("doclet.All_Classes");
jjg@1993 217 allpackagesLabel = getNonBreakResource("doclet.All_Packages");
jjg@1993 218 allprofilesLabel = getNonBreakResource("doclet.All_Profiles");
bpatel@766 219 indexLabel = getResource("doclet.Index");
bpatel@766 220 helpLabel = getResource("doclet.Help");
bpatel@766 221 seeLabel = getResource("doclet.See");
bpatel@766 222 descriptionLabel = getResource("doclet.Description");
jjg@1993 223 prevpackageLabel = getNonBreakResource("doclet.Prev_Package");
jjg@1993 224 nextpackageLabel = getNonBreakResource("doclet.Next_Package");
jjg@1993 225 prevprofileLabel = getNonBreakResource("doclet.Prev_Profile");
jjg@1993 226 nextprofileLabel = getNonBreakResource("doclet.Next_Profile");
bpatel@766 227 packagesLabel = getResource("doclet.Packages");
bpatel@1568 228 profilesLabel = getResource("doclet.Profiles");
bpatel@766 229 methodDetailsLabel = getResource("doclet.Method_Detail");
bpatel@766 230 annotationTypeDetailsLabel = getResource("doclet.Annotation_Type_Member_Detail");
bpatel@766 231 fieldDetailsLabel = getResource("doclet.Field_Detail");
jjg@1606 232 propertyDetailsLabel = getResource("doclet.Property_Detail");
bpatel@766 233 constructorDetailsLabel = getResource("doclet.Constructor_Detail");
bpatel@766 234 enumConstantsDetailsLabel = getResource("doclet.Enum_Constant_Detail");
bpatel@766 235 specifiedByLabel = getResource("doclet.Specified_By");
bpatel@766 236 overridesLabel = getResource("doclet.Overrides");
bpatel@766 237 descfrmClassLabel = getResource("doclet.Description_From_Class");
bpatel@766 238 descfrmInterfaceLabel = getResource("doclet.Description_From_Interface");
bpatel@766 239 }
bpatel@766 240
jjg@1365 241 public void write(Content c) throws IOException {
jjg@1365 242 c.write(writer, true);
jjg@1365 243 }
jjg@1365 244
jjg@1365 245 public void close() throws IOException {
jjg@1365 246 writer.close();
jjg@1365 247 }
jjg@1365 248
bpatel@766 249 /**
bpatel@766 250 * Get the configuration string as a content.
bpatel@766 251 *
bpatel@766 252 * @param key the key to look for in the configuration file
bpatel@766 253 * @return a content tree for the text
bpatel@766 254 */
bpatel@766 255 public Content getResource(String key) {
jjg@1740 256 return configuration.getResource(key);
bpatel@766 257 }
bpatel@766 258
bpatel@766 259 /**
jjg@1993 260 * Get the configuration string as a content, replacing spaces
jjg@1993 261 * with non-breaking spaces.
jjg@1993 262 *
jjg@1993 263 * @param key the key to look for in the configuration file
jjg@1993 264 * @return a content tree for the text
jjg@1993 265 */
jjg@1993 266 public Content getNonBreakResource(String key) {
jjg@1993 267 String text = configuration.getText(key);
jjg@1993 268 Content c = configuration.newContent();
jjg@1993 269 int start = 0;
jjg@1993 270 int p;
jjg@1993 271 while ((p = text.indexOf(" ", start)) != -1) {
jjg@1993 272 c.addContent(text.substring(start, p));
jjg@1993 273 c.addContent(RawHtml.nbsp);
jjg@1993 274 start = p + 1;
jjg@1993 275 }
jjg@1993 276 c.addContent(text.substring(start));
jjg@1993 277 return c;
jjg@1993 278 }
jjg@1993 279
jjg@1993 280 /**
bpatel@766 281 * Get the configuration string as a content.
bpatel@766 282 *
bpatel@766 283 * @param key the key to look for in the configuration file
jjg@1740 284 * @param o string or content argument added to configuration text
bpatel@766 285 * @return a content tree for the text
bpatel@766 286 */
jjg@1740 287 public Content getResource(String key, Object o) {
jjg@1740 288 return configuration.getResource(key, o);
bpatel@766 289 }
bpatel@766 290
bpatel@766 291 /**
bpatel@766 292 * Get the configuration string as a content.
bpatel@766 293 *
bpatel@766 294 * @param key the key to look for in the configuration file
jjg@1740 295 * @param o1 string or content argument added to configuration text
jjg@1740 296 * @param o2 string or content argument added to configuration text
bpatel@766 297 * @return a content tree for the text
bpatel@766 298 */
jjg@1740 299 public Content getResource(String key, Object o0, Object o1) {
jjg@1740 300 return configuration.getResource(key, o0, o1);
duke@1 301 }
duke@1 302
duke@1 303 /**
bpatel@766 304 * Returns an HtmlTree for the SCRIPT tag.
bpatel@766 305 *
bpatel@766 306 * @return an HtmlTree for the SCRIPT tag
bpatel@766 307 */
bpatel@766 308 protected HtmlTree getWinTitleScript(){
bpatel@766 309 HtmlTree script = new HtmlTree(HtmlTag.SCRIPT);
bpatel@766 310 if(winTitle != null && winTitle.length() > 0) {
bpatel@766 311 script.addAttr(HtmlAttr.TYPE, "text/javascript");
bpatel@793 312 String scriptCode = "<!--" + DocletConstants.NL +
bpatel@2085 313 " try {" + DocletConstants.NL +
bpatel@2085 314 " if (location.href.indexOf('is-external=true') == -1) {" + DocletConstants.NL +
chegar@2129 315 " parent.document.title=\"" + escapeJavaScriptChars(winTitle) + "\";" + DocletConstants.NL +
bpatel@2085 316 " }" + DocletConstants.NL +
bpatel@2085 317 " }" + DocletConstants.NL +
bpatel@2085 318 " catch(err) {" + DocletConstants.NL +
bpatel@793 319 " }" + DocletConstants.NL +
bpatel@793 320 "//-->" + DocletConstants.NL;
bpatel@766 321 RawHtml scriptContent = new RawHtml(scriptCode);
bpatel@766 322 script.addContent(scriptContent);
bpatel@766 323 }
bpatel@766 324 return script;
bpatel@766 325 }
bpatel@766 326
bpatel@766 327 /**
bpatel@2119 328 * Returns a String with escaped special JavaScript characters.
bpatel@2119 329 *
bpatel@2119 330 * @param s String that needs to be escaped
bpatel@2119 331 * @return a valid escaped JavaScript string
bpatel@2119 332 */
bpatel@2119 333 private static String escapeJavaScriptChars(String s) {
bpatel@2119 334 StringBuilder sb = new StringBuilder();
bpatel@2119 335 for (int i = 0; i < s.length(); i++) {
bpatel@2119 336 char ch = s.charAt(i);
bpatel@2119 337 switch (ch) {
bpatel@2119 338 case '\b':
bpatel@2119 339 sb.append("\\b");
bpatel@2119 340 break;
bpatel@2119 341 case '\t':
bpatel@2119 342 sb.append("\\t");
bpatel@2119 343 break;
bpatel@2119 344 case '\n':
bpatel@2119 345 sb.append("\\n");
bpatel@2119 346 break;
bpatel@2119 347 case '\f':
bpatel@2119 348 sb.append("\\f");
bpatel@2119 349 break;
bpatel@2119 350 case '\r':
bpatel@2119 351 sb.append("\\r");
bpatel@2119 352 break;
bpatel@2119 353 case '"':
bpatel@2119 354 sb.append("\\\"");
bpatel@2119 355 break;
bpatel@2119 356 case '\'':
bpatel@2119 357 sb.append("\\\'");
bpatel@2119 358 break;
bpatel@2119 359 case '\\':
bpatel@2119 360 sb.append("\\\\");
bpatel@2119 361 break;
bpatel@2119 362 default:
bpatel@2119 363 if (ch < 32 || ch >= 127) {
bpatel@2119 364 sb.append(String.format("\\u%04X", (int)ch));
bpatel@2119 365 } else {
bpatel@2119 366 sb.append(ch);
bpatel@2119 367 }
bpatel@2119 368 break;
bpatel@2119 369 }
bpatel@2119 370 }
bpatel@2119 371 return sb.toString();
bpatel@2119 372 }
bpatel@2119 373
bpatel@2119 374 /**
bpatel@766 375 * Returns a content tree for the SCRIPT tag for the main page(index.html).
bpatel@766 376 *
bpatel@766 377 * @return a content for the SCRIPT tag
bpatel@766 378 */
jjg@1737 379 protected Content getFramesetJavaScript() {
bpatel@766 380 HtmlTree script = new HtmlTree(HtmlTag.SCRIPT);
bpatel@766 381 script.addAttr(HtmlAttr.TYPE, "text/javascript");
jjg@1737 382 String scriptCode = DocletConstants.NL +
bpatel@3258 383 " tmpTargetPage = \"\" + window.location.search;" + DocletConstants.NL +
bpatel@3258 384 " if (tmpTargetPage != \"\" && tmpTargetPage != \"undefined\")" + DocletConstants.NL +
bpatel@3258 385 " tmpTargetPage = tmpTargetPage.substring(1);" + DocletConstants.NL +
bpatel@3258 386 " if (tmpTargetPage.indexOf(\":\") != -1 || (tmpTargetPage != \"\" && !validURL(tmpTargetPage)))" + DocletConstants.NL +
bpatel@3258 387 " tmpTargetPage = \"undefined\";" + DocletConstants.NL +
bpatel@3258 388 " targetPage = tmpTargetPage;" + DocletConstants.NL +
bpatel@1829 389 " function validURL(url) {" + DocletConstants.NL +
bpatel@2055 390 " try {" + DocletConstants.NL +
bpatel@2055 391 " url = decodeURIComponent(url);" + DocletConstants.NL +
bpatel@2055 392 " }" + DocletConstants.NL +
bpatel@2055 393 " catch (error) {" + DocletConstants.NL +
bpatel@2055 394 " return false;" + DocletConstants.NL +
bpatel@2055 395 " }" + DocletConstants.NL +
bpatel@1835 396 " var pos = url.indexOf(\".html\");" + DocletConstants.NL +
bpatel@1835 397 " if (pos == -1 || pos != url.length - 5)" + DocletConstants.NL +
bpatel@1829 398 " return false;" + DocletConstants.NL +
bpatel@1829 399 " var allowNumber = false;" + DocletConstants.NL +
bpatel@1829 400 " var allowSep = false;" + DocletConstants.NL +
bpatel@1829 401 " var seenDot = false;" + DocletConstants.NL +
bpatel@1829 402 " for (var i = 0; i < url.length - 5; i++) {" + DocletConstants.NL +
bpatel@1829 403 " var ch = url.charAt(i);" + DocletConstants.NL +
bpatel@1829 404 " if ('a' <= ch && ch <= 'z' ||" + DocletConstants.NL +
bpatel@1829 405 " 'A' <= ch && ch <= 'Z' ||" + DocletConstants.NL +
bpatel@1829 406 " ch == '$' ||" + DocletConstants.NL +
bpatel@2055 407 " ch == '_' ||" + DocletConstants.NL +
bpatel@2055 408 " ch.charCodeAt(0) > 127) {" + DocletConstants.NL +
bpatel@1829 409 " allowNumber = true;" + DocletConstants.NL +
bpatel@1829 410 " allowSep = true;" + DocletConstants.NL +
bpatel@1829 411 " } else if ('0' <= ch && ch <= '9'" + DocletConstants.NL +
bpatel@1829 412 " || ch == '-') {" + DocletConstants.NL +
bpatel@1829 413 " if (!allowNumber)" + DocletConstants.NL +
bpatel@1829 414 " return false;" + DocletConstants.NL +
bpatel@1829 415 " } else if (ch == '/' || ch == '.') {" + DocletConstants.NL +
bpatel@1829 416 " if (!allowSep)" + DocletConstants.NL +
bpatel@1829 417 " return false;" + DocletConstants.NL +
bpatel@1829 418 " allowNumber = false;" + DocletConstants.NL +
bpatel@1829 419 " allowSep = false;" + DocletConstants.NL +
bpatel@1829 420 " if (ch == '.')" + DocletConstants.NL +
bpatel@1829 421 " seenDot = true;" + DocletConstants.NL +
bpatel@1829 422 " if (ch == '/' && seenDot)" + DocletConstants.NL +
bpatel@1829 423 " return false;" + DocletConstants.NL +
bpatel@1829 424 " } else {" + DocletConstants.NL +
bpatel@1829 425 " return false;"+ DocletConstants.NL +
bpatel@1829 426 " }" + DocletConstants.NL +
bpatel@1829 427 " }" + DocletConstants.NL +
bpatel@1829 428 " return true;" + DocletConstants.NL +
bpatel@1829 429 " }" + DocletConstants.NL +
bpatel@793 430 " function loadFrames() {" + DocletConstants.NL +
bpatel@793 431 " if (targetPage != \"\" && targetPage != \"undefined\")" + DocletConstants.NL +
bpatel@793 432 " top.classFrame.location = top.targetPage;" + DocletConstants.NL +
bpatel@793 433 " }" + DocletConstants.NL;
bpatel@766 434 RawHtml scriptContent = new RawHtml(scriptCode);
bpatel@766 435 script.addContent(scriptContent);
bpatel@766 436 return script;
bpatel@766 437 }
bpatel@766 438
bpatel@766 439 /**
bpatel@766 440 * Returns an HtmlTree for the BODY tag.
bpatel@766 441 *
bpatel@766 442 * @param includeScript set true if printing windowtitle script
bpatel@766 443 * @param title title for the window
bpatel@766 444 * @return an HtmlTree for the BODY tag
bpatel@766 445 */
bpatel@766 446 public HtmlTree getBody(boolean includeScript, String title) {
bpatel@766 447 HtmlTree body = new HtmlTree(HtmlTag.BODY);
bpatel@766 448 // Set window title string which is later printed
bpatel@766 449 this.winTitle = title;
bpatel@766 450 // Don't print windowtitle script for overview-frame, allclasses-frame
bpatel@766 451 // and package-frame
bpatel@766 452 if (includeScript) {
bpatel@1417 453 this.script = getWinTitleScript();
bpatel@1417 454 body.addContent(script);
bpatel@766 455 Content noScript = HtmlTree.NOSCRIPT(
bpatel@766 456 HtmlTree.DIV(getResource("doclet.No_Script_Message")));
bpatel@766 457 body.addContent(noScript);
bpatel@766 458 }
bpatel@766 459 return body;
bpatel@766 460 }
bpatel@766 461
bpatel@766 462 /**
bpatel@1417 463 * Generated javascript variables for the document.
bpatel@1417 464 *
bpatel@1417 465 * @param typeMap map comprising of method and type relationship
bpatel@1417 466 * @param methodTypes set comprising of all methods types for this class
bpatel@1417 467 */
bpatel@1417 468 public void generateMethodTypesScript(Map<String,Integer> typeMap,
bpatel@1417 469 Set<MethodTypes> methodTypes) {
bpatel@1417 470 String sep = "";
bpatel@1417 471 StringBuilder vars = new StringBuilder("var methods = {");
bpatel@1417 472 for (Map.Entry<String,Integer> entry : typeMap.entrySet()) {
bpatel@1417 473 vars.append(sep);
bpatel@1417 474 sep = ",";
bpatel@2800 475 vars.append("\"")
bpatel@2800 476 .append(entry.getKey())
bpatel@2800 477 .append("\":")
bpatel@2800 478 .append(entry.getValue());
bpatel@1417 479 }
bpatel@1417 480 vars.append("};").append(DocletConstants.NL);
bpatel@1417 481 sep = "";
bpatel@1417 482 vars.append("var tabs = {");
bpatel@1417 483 for (MethodTypes entry : methodTypes) {
bpatel@1417 484 vars.append(sep);
bpatel@1417 485 sep = ",";
bpatel@2800 486 vars.append(entry.value())
bpatel@2800 487 .append(":")
bpatel@2800 488 .append("[")
bpatel@2800 489 .append("\"")
bpatel@2800 490 .append(entry.tabId())
bpatel@2800 491 .append("\"")
bpatel@2800 492 .append(sep)
bpatel@2800 493 .append("\"")
bpatel@2800 494 .append(configuration.getText(entry.resourceKey()))
bpatel@2800 495 .append("\"]");
bpatel@1417 496 }
bpatel@2800 497 vars.append("};")
bpatel@2800 498 .append(DocletConstants.NL);
bpatel@1417 499 addStyles(HtmlStyle.altColor, vars);
bpatel@1417 500 addStyles(HtmlStyle.rowColor, vars);
bpatel@1417 501 addStyles(HtmlStyle.tableTab, vars);
bpatel@1417 502 addStyles(HtmlStyle.activeTableTab, vars);
bpatel@1417 503 script.addContent(new RawHtml(vars.toString()));
bpatel@1417 504 }
bpatel@1417 505
bpatel@1417 506 /**
bpatel@1417 507 * Adds javascript style variables to the document.
bpatel@1417 508 *
bpatel@1417 509 * @param style style to be added as a javascript variable
bpatel@1417 510 * @param vars variable string to which the style variable will be added
bpatel@1417 511 */
bpatel@1417 512 public void addStyles(HtmlStyle style, StringBuilder vars) {
bpatel@1417 513 vars.append("var ").append(style).append(" = \"").append(style)
bpatel@1417 514 .append("\";").append(DocletConstants.NL);
bpatel@1417 515 }
bpatel@1417 516
bpatel@1417 517 /**
bpatel@766 518 * Returns an HtmlTree for the TITLE tag.
bpatel@766 519 *
bpatel@766 520 * @return an HtmlTree for the TITLE tag
bpatel@766 521 */
bpatel@766 522 public HtmlTree getTitle() {
bpatel@766 523 HtmlTree title = HtmlTree.TITLE(new StringContent(winTitle));
bpatel@766 524 return title;
bpatel@766 525 }
duke@1 526
duke@1 527 public String codeText(String text) {
bpatel@766 528 return "<code>" + text + "</code>";
duke@1 529 }
duke@1 530
duke@1 531 /**
bpatel@766 532 * Return "&#38;nbsp;", non-breaking space.
bpatel@766 533 */
bpatel@766 534 public Content getSpace() {
bpatel@766 535 return RawHtml.nbsp;
bpatel@766 536 }
bpatel@766 537
bpatel@243 538 /*
bpatel@243 539 * Returns a header for Modifier and Type column of a table.
bpatel@243 540 */
bpatel@243 541 public String getModifierTypeHeader() {
bpatel@243 542 return modifierTypeHeader;
bpatel@243 543 }
duke@1 544 }

mercurial