Fri, 05 Oct 2012 14:16:32 -0700
7068595: html files in class-use dir do not get loaded correctly when Frames link is clicked
Reviewed-by: jjg
duke@1 | 1 | /* |
jjg@1326 | 2 | * Copyright (c) 1998, 2012, 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.text.SimpleDateFormat; |
duke@1 | 30 | import java.util.*; |
duke@1 | 31 | |
bpatel@233 | 32 | import com.sun.javadoc.*; |
bpatel@233 | 33 | import com.sun.tools.doclets.formats.html.markup.*; |
bpatel@233 | 34 | import com.sun.tools.doclets.internal.toolkit.*; |
bpatel@233 | 35 | import com.sun.tools.doclets.internal.toolkit.util.*; |
bpatel@233 | 36 | import com.sun.tools.doclets.internal.toolkit.taglets.*; |
duke@1 | 37 | |
duke@1 | 38 | /** |
duke@1 | 39 | * Class for the Html Format Code Generation specific to JavaDoc. |
duke@1 | 40 | * This Class contains methods related to the Html Code Generation which |
duke@1 | 41 | * are used extensively while generating the entire documentation. |
duke@1 | 42 | * |
duke@1 | 43 | * @since 1.2 |
duke@1 | 44 | * @author Atul M Dambalkar |
duke@1 | 45 | * @author Robert Field |
bpatel@233 | 46 | * @author Bhavesh Patel (Modified) |
duke@1 | 47 | */ |
duke@1 | 48 | public class HtmlDocletWriter extends HtmlDocWriter { |
duke@1 | 49 | |
duke@1 | 50 | /** |
duke@1 | 51 | * Relative path from the file getting generated to the destination |
duke@1 | 52 | * directory. For example, if the file getting generated is |
duke@1 | 53 | * "java/lang/Object.html", then the relative path string is "../../". |
duke@1 | 54 | * This string can be empty if the file getting generated is in |
duke@1 | 55 | * the destination directory. |
duke@1 | 56 | */ |
duke@1 | 57 | public String relativePath = ""; |
duke@1 | 58 | |
duke@1 | 59 | /** |
duke@1 | 60 | * Same as relativepath, but normalized to never be empty or |
duke@1 | 61 | * end with a slash. |
duke@1 | 62 | */ |
duke@1 | 63 | public String relativepathNoSlash = ""; |
duke@1 | 64 | |
duke@1 | 65 | /** |
duke@1 | 66 | * Platform-dependent directory path from the current or the |
duke@1 | 67 | * destination directory to the file getting generated. |
duke@1 | 68 | * Used when creating the file. |
duke@1 | 69 | * For example, if the file getting generated is |
duke@1 | 70 | * "java/lang/Object.html", then the path string is "java/lang". |
duke@1 | 71 | */ |
duke@1 | 72 | public String path = ""; |
duke@1 | 73 | |
duke@1 | 74 | /** |
duke@1 | 75 | * Name of the file getting generated. If the file getting generated is |
duke@1 | 76 | * "java/lang/Object.html", then the filename is "Object.html". |
duke@1 | 77 | */ |
duke@1 | 78 | public String filename = ""; |
duke@1 | 79 | |
duke@1 | 80 | /** |
duke@1 | 81 | * The display length used for indentation while generating the class page. |
duke@1 | 82 | */ |
duke@1 | 83 | public int displayLength = 0; |
duke@1 | 84 | |
duke@1 | 85 | /** |
duke@1 | 86 | * The global configuration information for this run. |
duke@1 | 87 | */ |
duke@1 | 88 | public ConfigurationImpl configuration; |
duke@1 | 89 | |
duke@1 | 90 | /** |
bpatel@766 | 91 | * To check whether annotation heading is printed or not. |
bpatel@766 | 92 | */ |
bpatel@766 | 93 | protected boolean printedAnnotationHeading = false; |
bpatel@766 | 94 | |
bpatel@766 | 95 | /** |
duke@1 | 96 | * Constructor to construct the HtmlStandardWriter object. |
duke@1 | 97 | * |
duke@1 | 98 | * @param filename File to be generated. |
duke@1 | 99 | */ |
duke@1 | 100 | public HtmlDocletWriter(ConfigurationImpl configuration, |
duke@1 | 101 | String filename) throws IOException { |
duke@1 | 102 | super(configuration, filename); |
duke@1 | 103 | this.configuration = configuration; |
duke@1 | 104 | this.filename = filename; |
duke@1 | 105 | } |
duke@1 | 106 | |
duke@1 | 107 | /** |
duke@1 | 108 | * Constructor to construct the HtmlStandardWriter object. |
duke@1 | 109 | * |
duke@1 | 110 | * @param path Platform-dependent {@link #path} used when |
duke@1 | 111 | * creating file. |
duke@1 | 112 | * @param filename Name of file to be generated. |
duke@1 | 113 | * @param relativePath Value for the variable {@link #relativePath}. |
duke@1 | 114 | */ |
duke@1 | 115 | public HtmlDocletWriter(ConfigurationImpl configuration, |
duke@1 | 116 | String path, String filename, |
duke@1 | 117 | String relativePath) throws IOException { |
duke@1 | 118 | super(configuration, path, filename); |
duke@1 | 119 | this.configuration = configuration; |
duke@1 | 120 | this.path = path; |
duke@1 | 121 | this.relativePath = relativePath; |
duke@1 | 122 | this.relativepathNoSlash = |
duke@1 | 123 | DirectoryManager.getPathNoTrailingSlash(this.relativePath); |
duke@1 | 124 | this.filename = filename; |
duke@1 | 125 | } |
duke@1 | 126 | |
duke@1 | 127 | /** |
duke@1 | 128 | * Replace {@docRoot} tag used in options that accept HTML text, such |
duke@1 | 129 | * as -header, -footer, -top and -bottom, and when converting a relative |
duke@1 | 130 | * HREF where commentTagsToString inserts a {@docRoot} where one was |
duke@1 | 131 | * missing. (Also see DocRootTaglet for {@docRoot} tags in doc |
duke@1 | 132 | * comments.) |
duke@1 | 133 | * <p> |
duke@1 | 134 | * Replace {@docRoot} tag in htmlstr with the relative path to the |
duke@1 | 135 | * destination directory from the directory where the file is being |
duke@1 | 136 | * written, looping to handle all such tags in htmlstr. |
duke@1 | 137 | * <p> |
duke@1 | 138 | * For example, for "-d docs" and -header containing {@docRoot}, when |
duke@1 | 139 | * the HTML page for source file p/C1.java is being generated, the |
duke@1 | 140 | * {@docRoot} tag would be inserted into the header as "../", |
duke@1 | 141 | * the relative path from docs/p/ to docs/ (the document root). |
duke@1 | 142 | * <p> |
duke@1 | 143 | * Note: This doc comment was written with '&#064;' representing '@' |
duke@1 | 144 | * to prevent the inline tag from being interpreted. |
duke@1 | 145 | */ |
duke@1 | 146 | public String replaceDocRootDir(String htmlstr) { |
duke@1 | 147 | // Return if no inline tags exist |
duke@1 | 148 | int index = htmlstr.indexOf("{@"); |
duke@1 | 149 | if (index < 0) { |
duke@1 | 150 | return htmlstr; |
duke@1 | 151 | } |
duke@1 | 152 | String lowerHtml = htmlstr.toLowerCase(); |
duke@1 | 153 | // Return index of first occurrence of {@docroot} |
duke@1 | 154 | // Note: {@docRoot} is not case sensitive when passed in w/command line option |
duke@1 | 155 | index = lowerHtml.indexOf("{@docroot}", index); |
duke@1 | 156 | if (index < 0) { |
duke@1 | 157 | return htmlstr; |
duke@1 | 158 | } |
jjg@910 | 159 | StringBuilder buf = new StringBuilder(); |
duke@1 | 160 | int previndex = 0; |
duke@1 | 161 | while (true) { |
bpatel@997 | 162 | if (configuration.docrootparent.length() > 0) { |
bpatel@997 | 163 | // Search for lowercase version of {@docRoot}/.. |
bpatel@997 | 164 | index = lowerHtml.indexOf("{@docroot}/..", previndex); |
bpatel@997 | 165 | // If next {@docRoot}/.. pattern not found, append rest of htmlstr and exit loop |
bpatel@997 | 166 | if (index < 0) { |
bpatel@997 | 167 | buf.append(htmlstr.substring(previndex)); |
bpatel@997 | 168 | break; |
bpatel@997 | 169 | } |
bpatel@997 | 170 | // If next {@docroot}/.. pattern found, append htmlstr up to start of tag |
bpatel@997 | 171 | buf.append(htmlstr.substring(previndex, index)); |
bpatel@997 | 172 | previndex = index + 13; // length for {@docroot}/.. string |
bpatel@997 | 173 | // Insert docrootparent absolute path where {@docRoot}/.. was located |
bpatel@997 | 174 | |
bpatel@997 | 175 | buf.append(configuration.docrootparent); |
bpatel@997 | 176 | // Append slash if next character is not a slash |
bpatel@997 | 177 | if (previndex < htmlstr.length() && htmlstr.charAt(previndex) != '/') { |
bpatel@997 | 178 | buf.append(DirectoryManager.URL_FILE_SEPARATOR); |
bpatel@997 | 179 | } |
bpatel@997 | 180 | } else { |
bpatel@997 | 181 | // Search for lowercase version of {@docRoot} |
bpatel@997 | 182 | index = lowerHtml.indexOf("{@docroot}", previndex); |
bpatel@997 | 183 | // If next {@docRoot} tag not found, append rest of htmlstr and exit loop |
bpatel@997 | 184 | if (index < 0) { |
bpatel@997 | 185 | buf.append(htmlstr.substring(previndex)); |
bpatel@997 | 186 | break; |
bpatel@997 | 187 | } |
bpatel@997 | 188 | // If next {@docroot} tag found, append htmlstr up to start of tag |
bpatel@997 | 189 | buf.append(htmlstr.substring(previndex, index)); |
bpatel@997 | 190 | previndex = index + 10; // length for {@docroot} string |
bpatel@997 | 191 | // Insert relative path where {@docRoot} was located |
bpatel@997 | 192 | buf.append(relativepathNoSlash); |
bpatel@997 | 193 | // Append slash if next character is not a slash |
bpatel@997 | 194 | if (relativepathNoSlash.length() > 0 && previndex < htmlstr.length() && |
bpatel@997 | 195 | htmlstr.charAt(previndex) != '/') { |
bpatel@997 | 196 | buf.append(DirectoryManager.URL_FILE_SEPARATOR); |
bpatel@997 | 197 | } |
duke@1 | 198 | } |
duke@1 | 199 | } |
duke@1 | 200 | return buf.toString(); |
duke@1 | 201 | } |
duke@1 | 202 | |
duke@1 | 203 | /** |
duke@1 | 204 | * Print Html Hyper Link, with target frame. This |
duke@1 | 205 | * link will only appear if page is not in a frame. |
duke@1 | 206 | * |
duke@1 | 207 | * @param link String name of the file. |
duke@1 | 208 | * @param where Position in the file |
duke@1 | 209 | * @param target Name of the target frame. |
duke@1 | 210 | * @param label Tag for the link. |
bpatel@182 | 211 | * @param strong Whether the label should be strong or not? |
duke@1 | 212 | */ |
duke@1 | 213 | public void printNoFramesTargetHyperLink(String link, String where, |
duke@1 | 214 | String target, String label, |
bpatel@182 | 215 | boolean strong) { |
duke@1 | 216 | script(); |
duke@1 | 217 | println(" <!--"); |
duke@1 | 218 | println(" if(window==top) {"); |
duke@1 | 219 | println(" document.writeln('" |
bpatel@766 | 220 | + getHyperLinkString(link, where, label, strong, "", "", target) + "');"); |
duke@1 | 221 | println(" }"); |
duke@1 | 222 | println(" //-->"); |
duke@1 | 223 | scriptEnd(); |
duke@1 | 224 | noScript(); |
bpatel@766 | 225 | println(" " + getHyperLinkString(link, where, label, strong, "", "", target)); |
duke@1 | 226 | noScriptEnd(); |
duke@1 | 227 | println(DocletConstants.NL); |
duke@1 | 228 | } |
duke@1 | 229 | |
bpatel@766 | 230 | /** |
bpatel@766 | 231 | * Get the script to show or hide the All classes link. |
bpatel@766 | 232 | * |
bpatel@766 | 233 | * @param id id of the element to show or hide |
bpatel@766 | 234 | * @return a content tree for the script |
bpatel@766 | 235 | */ |
bpatel@766 | 236 | public Content getAllClassesLinkScript(String id) { |
bpatel@766 | 237 | HtmlTree script = new HtmlTree(HtmlTag.SCRIPT); |
bpatel@766 | 238 | script.addAttr(HtmlAttr.TYPE, "text/javascript"); |
bpatel@793 | 239 | String scriptCode = "<!--" + DocletConstants.NL + |
bpatel@793 | 240 | " allClassesLink = document.getElementById(\"" + id + "\");" + DocletConstants.NL + |
bpatel@793 | 241 | " if(window==top) {" + DocletConstants.NL + |
bpatel@793 | 242 | " allClassesLink.style.display = \"block\";" + DocletConstants.NL + |
bpatel@793 | 243 | " }" + DocletConstants.NL + |
bpatel@793 | 244 | " else {" + DocletConstants.NL + |
bpatel@793 | 245 | " allClassesLink.style.display = \"none\";" + DocletConstants.NL + |
bpatel@793 | 246 | " }" + DocletConstants.NL + |
bpatel@793 | 247 | " //-->" + DocletConstants.NL; |
bpatel@766 | 248 | Content scriptContent = new RawHtml(scriptCode); |
bpatel@766 | 249 | script.addContent(scriptContent); |
bpatel@766 | 250 | Content div = HtmlTree.DIV(script); |
bpatel@766 | 251 | return div; |
bpatel@766 | 252 | } |
bpatel@766 | 253 | |
bpatel@766 | 254 | /** |
bpatel@766 | 255 | * Add method information. |
bpatel@766 | 256 | * |
bpatel@766 | 257 | * @param method the method to be documented |
bpatel@766 | 258 | * @param dl the content tree to which the method information will be added |
bpatel@766 | 259 | */ |
bpatel@766 | 260 | private void addMethodInfo(MethodDoc method, Content dl) { |
duke@1 | 261 | ClassDoc[] intfacs = method.containingClass().interfaces(); |
duke@1 | 262 | MethodDoc overriddenMethod = method.overriddenMethod(); |
bpatel@233 | 263 | // Check whether there is any implementation or overridden info to be |
bpatel@233 | 264 | // printed. If no overridden or implementation info needs to be |
bpatel@233 | 265 | // printed, do not print this section. |
bpatel@233 | 266 | if ((intfacs.length > 0 && |
bpatel@233 | 267 | new ImplementedMethods(method, this.configuration).build().length > 0) || |
bpatel@233 | 268 | overriddenMethod != null) { |
bpatel@766 | 269 | MethodWriterImpl.addImplementsInfo(this, method, dl); |
duke@1 | 270 | if (overriddenMethod != null) { |
bpatel@766 | 271 | MethodWriterImpl.addOverridden(this, |
bpatel@766 | 272 | method.overriddenType(), overriddenMethod, dl); |
duke@1 | 273 | } |
duke@1 | 274 | } |
duke@1 | 275 | } |
duke@1 | 276 | |
bpatel@766 | 277 | /** |
bpatel@766 | 278 | * Adds the tags information. |
bpatel@766 | 279 | * |
bpatel@766 | 280 | * @param doc the doc for which the tags will be generated |
bpatel@766 | 281 | * @param htmltree the documentation tree to which the tags will be added |
bpatel@766 | 282 | */ |
bpatel@766 | 283 | protected void addTagsInfo(Doc doc, Content htmltree) { |
bpatel@766 | 284 | if (configuration.nocomment) { |
duke@1 | 285 | return; |
duke@1 | 286 | } |
bpatel@766 | 287 | Content dl = new HtmlTree(HtmlTag.DL); |
duke@1 | 288 | if (doc instanceof MethodDoc) { |
bpatel@766 | 289 | addMethodInfo((MethodDoc) doc, dl); |
duke@1 | 290 | } |
duke@1 | 291 | TagletOutputImpl output = new TagletOutputImpl(""); |
duke@1 | 292 | TagletWriter.genTagOuput(configuration.tagletManager, doc, |
duke@1 | 293 | configuration.tagletManager.getCustomTags(doc), |
duke@1 | 294 | getTagletWriterInstance(false), output); |
bpatel@233 | 295 | String outputString = output.toString().trim(); |
bpatel@233 | 296 | if (!outputString.isEmpty()) { |
bpatel@766 | 297 | Content resultString = new RawHtml(outputString); |
bpatel@766 | 298 | dl.addContent(resultString); |
duke@1 | 299 | } |
bpatel@766 | 300 | htmltree.addContent(dl); |
duke@1 | 301 | } |
duke@1 | 302 | |
duke@1 | 303 | /** |
bpatel@233 | 304 | * Check whether there are any tags for Serialization Overview |
bpatel@233 | 305 | * section to be printed. |
bpatel@222 | 306 | * |
bpatel@233 | 307 | * @param field the FieldDoc object to check for tags. |
bpatel@222 | 308 | * @return true if there are tags to be printed else return false. |
bpatel@222 | 309 | */ |
bpatel@233 | 310 | protected boolean hasSerializationOverviewTags(FieldDoc field) { |
bpatel@222 | 311 | TagletOutputImpl output = new TagletOutputImpl(""); |
bpatel@233 | 312 | TagletWriter.genTagOuput(configuration.tagletManager, field, |
bpatel@233 | 313 | configuration.tagletManager.getCustomTags(field), |
bpatel@222 | 314 | getTagletWriterInstance(false), output); |
bpatel@233 | 315 | return (!output.toString().trim().isEmpty()); |
bpatel@222 | 316 | } |
bpatel@222 | 317 | |
bpatel@222 | 318 | /** |
duke@1 | 319 | * Returns a TagletWriter that knows how to write HTML. |
duke@1 | 320 | * |
duke@1 | 321 | * @return a TagletWriter that knows how to write HTML. |
duke@1 | 322 | */ |
duke@1 | 323 | public TagletWriter getTagletWriterInstance(boolean isFirstSentence) { |
duke@1 | 324 | return new TagletWriterImpl(this, isFirstSentence); |
duke@1 | 325 | } |
duke@1 | 326 | |
duke@1 | 327 | protected void printTagsInfoHeader() { |
duke@1 | 328 | dl(); |
duke@1 | 329 | } |
duke@1 | 330 | |
duke@1 | 331 | protected void printTagsInfoFooter() { |
duke@1 | 332 | dlEnd(); |
duke@1 | 333 | } |
duke@1 | 334 | |
duke@1 | 335 | /** |
bpatel@766 | 336 | * Get Package link, with target frame. |
duke@1 | 337 | * |
bpatel@766 | 338 | * @param pd The link will be to the "package-summary.html" page for this package |
bpatel@766 | 339 | * @param target name of the target frame |
bpatel@766 | 340 | * @param label tag for the link |
bpatel@766 | 341 | * @return a content for the target package link |
duke@1 | 342 | */ |
bpatel@766 | 343 | public Content getTargetPackageLink(PackageDoc pd, String target, |
bpatel@766 | 344 | Content label) { |
bpatel@766 | 345 | return getHyperLink(pathString(pd, "package-summary.html"), "", label, "", target); |
duke@1 | 346 | } |
duke@1 | 347 | |
duke@1 | 348 | /** |
duke@1 | 349 | * Print the html file header. Also print Html page title and stylesheet |
duke@1 | 350 | * default properties. |
duke@1 | 351 | * |
duke@1 | 352 | * @param title String window title to go in the <TITLE> tag |
duke@1 | 353 | * @param metakeywords Array of String keywords for META tag. Each element |
duke@1 | 354 | * of the array is assigned to a separate META tag. |
duke@1 | 355 | * Pass in null for no array. |
duke@1 | 356 | * @param includeScript boolean true if printing windowtitle script. |
duke@1 | 357 | * False for files that appear in the left-hand frames. |
duke@1 | 358 | */ |
duke@1 | 359 | public void printHtmlHeader(String title, String[] metakeywords, |
duke@1 | 360 | boolean includeScript) { |
duke@1 | 361 | println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 " + |
duke@1 | 362 | "Transitional//EN\" " + |
duke@1 | 363 | "\"http://www.w3.org/TR/html4/loose.dtd\">"); |
duke@1 | 364 | println("<!--NewPage-->"); |
duke@1 | 365 | html(); |
duke@1 | 366 | head(); |
duke@1 | 367 | if (! configuration.notimestamp) { |
duke@1 | 368 | print("<!-- Generated by javadoc (build " + ConfigurationImpl.BUILD_DATE + ") on "); |
duke@1 | 369 | print(today()); |
duke@1 | 370 | println(" -->"); |
duke@1 | 371 | } |
duke@1 | 372 | if (configuration.charset.length() > 0) { |
duke@1 | 373 | println("<META http-equiv=\"Content-Type\" content=\"text/html; " |
duke@1 | 374 | + "charset=" + configuration.charset + "\">"); |
duke@1 | 375 | } |
duke@1 | 376 | if ( configuration.windowtitle.length() > 0 ) { |
duke@1 | 377 | title += " (" + configuration.windowtitle + ")"; |
duke@1 | 378 | } |
duke@1 | 379 | title(title); |
duke@1 | 380 | println(title); |
duke@1 | 381 | titleEnd(); |
duke@1 | 382 | println(""); |
duke@1 | 383 | if (! configuration.notimestamp) { |
duke@1 | 384 | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); |
duke@1 | 385 | println("<META NAME=\"date\" " |
duke@1 | 386 | + "CONTENT=\"" + dateFormat.format(new Date()) + "\">"); |
duke@1 | 387 | } |
duke@1 | 388 | if ( metakeywords != null ) { |
duke@1 | 389 | for ( int i=0; i < metakeywords.length; i++ ) { |
duke@1 | 390 | println("<META NAME=\"keywords\" " |
duke@1 | 391 | + "CONTENT=\"" + metakeywords[i] + "\">"); |
duke@1 | 392 | } |
duke@1 | 393 | } |
duke@1 | 394 | println(""); |
duke@1 | 395 | printStyleSheetProperties(); |
duke@1 | 396 | println(""); |
duke@1 | 397 | // Don't print windowtitle script for overview-frame, allclasses-frame |
duke@1 | 398 | // and package-frame |
duke@1 | 399 | if (includeScript) { |
duke@1 | 400 | printWinTitleScript(title); |
duke@1 | 401 | } |
duke@1 | 402 | println(""); |
duke@1 | 403 | headEnd(); |
duke@1 | 404 | println(""); |
duke@1 | 405 | body("white", includeScript); |
duke@1 | 406 | } |
duke@1 | 407 | |
duke@1 | 408 | /** |
bpatel@766 | 409 | * Generates the HTML document tree and prints it out. |
bpatel@766 | 410 | * |
bpatel@766 | 411 | * @param metakeywords Array of String keywords for META tag. Each element |
bpatel@766 | 412 | * of the array is assigned to a separate META tag. |
bpatel@766 | 413 | * Pass in null for no array |
bpatel@766 | 414 | * @param includeScript true if printing windowtitle script |
bpatel@766 | 415 | * false for files that appear in the left-hand frames |
bpatel@766 | 416 | * @param body the body htmltree to be included in the document |
bpatel@766 | 417 | */ |
bpatel@766 | 418 | public void printHtmlDocument(String[] metakeywords, boolean includeScript, |
bpatel@766 | 419 | Content body) { |
bpatel@766 | 420 | Content htmlDocType = DocType.Transitional(); |
bpatel@766 | 421 | Content htmlComment = new Comment(configuration.getText("doclet.New_Page")); |
bpatel@766 | 422 | Content head = new HtmlTree(HtmlTag.HEAD); |
bpatel@766 | 423 | if (!configuration.notimestamp) { |
bpatel@766 | 424 | Content headComment = new Comment("Generated by javadoc (version " + |
bpatel@766 | 425 | ConfigurationImpl.BUILD_DATE + ") on " + today()); |
bpatel@766 | 426 | head.addContent(headComment); |
bpatel@766 | 427 | } |
bpatel@766 | 428 | if (configuration.charset.length() > 0) { |
bpatel@766 | 429 | Content meta = HtmlTree.META("Content-Type", "text/html", |
bpatel@766 | 430 | configuration.charset); |
bpatel@766 | 431 | head.addContent(meta); |
bpatel@766 | 432 | } |
bpatel@766 | 433 | head.addContent(getTitle()); |
bpatel@766 | 434 | if (!configuration.notimestamp) { |
bpatel@766 | 435 | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); |
bpatel@766 | 436 | Content meta = HtmlTree.META("date", dateFormat.format(new Date())); |
bpatel@766 | 437 | head.addContent(meta); |
bpatel@766 | 438 | } |
bpatel@766 | 439 | if (metakeywords != null) { |
bpatel@766 | 440 | for (int i=0; i < metakeywords.length; i++) { |
bpatel@766 | 441 | Content meta = HtmlTree.META("keywords", metakeywords[i]); |
bpatel@766 | 442 | head.addContent(meta); |
bpatel@766 | 443 | } |
bpatel@766 | 444 | } |
bpatel@766 | 445 | head.addContent(getStyleSheetProperties()); |
bpatel@766 | 446 | Content htmlTree = HtmlTree.HTML(configuration.getLocale().getLanguage(), |
bpatel@766 | 447 | head, body); |
bpatel@766 | 448 | Content htmlDocument = new HtmlDocument(htmlDocType, |
bpatel@766 | 449 | htmlComment, htmlTree); |
bpatel@766 | 450 | print(htmlDocument.toString()); |
bpatel@766 | 451 | } |
bpatel@766 | 452 | |
bpatel@766 | 453 | /** |
bpatel@766 | 454 | * Get the window title. |
bpatel@766 | 455 | * |
bpatel@766 | 456 | * @param title the title string to construct the complete window title |
bpatel@766 | 457 | * @return the window title string |
bpatel@766 | 458 | */ |
bpatel@766 | 459 | public String getWindowTitle(String title) { |
bpatel@766 | 460 | if (configuration.windowtitle.length() > 0) { |
bpatel@766 | 461 | title += " (" + configuration.windowtitle + ")"; |
bpatel@766 | 462 | } |
bpatel@766 | 463 | return title; |
bpatel@766 | 464 | } |
bpatel@766 | 465 | |
bpatel@766 | 466 | /** |
duke@1 | 467 | * Print user specified header and the footer. |
duke@1 | 468 | * |
duke@1 | 469 | * @param header if true print the user provided header else print the |
duke@1 | 470 | * user provided footer. |
duke@1 | 471 | */ |
duke@1 | 472 | public void printUserHeaderFooter(boolean header) { |
duke@1 | 473 | em(); |
duke@1 | 474 | if (header) { |
duke@1 | 475 | print(replaceDocRootDir(configuration.header)); |
duke@1 | 476 | } else { |
duke@1 | 477 | if (configuration.footer.length() != 0) { |
duke@1 | 478 | print(replaceDocRootDir(configuration.footer)); |
duke@1 | 479 | } else { |
duke@1 | 480 | print(replaceDocRootDir(configuration.header)); |
duke@1 | 481 | } |
duke@1 | 482 | } |
duke@1 | 483 | emEnd(); |
duke@1 | 484 | } |
duke@1 | 485 | |
duke@1 | 486 | /** |
bpatel@766 | 487 | * Get user specified header and the footer. |
bpatel@766 | 488 | * |
bpatel@766 | 489 | * @param header if true print the user provided header else print the |
bpatel@766 | 490 | * user provided footer. |
bpatel@766 | 491 | */ |
bpatel@766 | 492 | public Content getUserHeaderFooter(boolean header) { |
bpatel@766 | 493 | String content; |
bpatel@766 | 494 | if (header) { |
bpatel@766 | 495 | content = replaceDocRootDir(configuration.header); |
bpatel@766 | 496 | } else { |
bpatel@766 | 497 | if (configuration.footer.length() != 0) { |
bpatel@766 | 498 | content = replaceDocRootDir(configuration.footer); |
bpatel@766 | 499 | } else { |
bpatel@766 | 500 | content = replaceDocRootDir(configuration.header); |
bpatel@766 | 501 | } |
bpatel@766 | 502 | } |
bpatel@766 | 503 | Content rawContent = new RawHtml(content); |
bpatel@766 | 504 | Content em = HtmlTree.EM(rawContent); |
bpatel@766 | 505 | return em; |
bpatel@766 | 506 | } |
bpatel@766 | 507 | |
bpatel@766 | 508 | /** |
duke@1 | 509 | * Print the user specified top. |
duke@1 | 510 | */ |
duke@1 | 511 | public void printTop() { |
duke@1 | 512 | print(replaceDocRootDir(configuration.top)); |
duke@1 | 513 | hr(); |
duke@1 | 514 | } |
duke@1 | 515 | |
duke@1 | 516 | /** |
bpatel@766 | 517 | * Adds the user specified top. |
bpatel@766 | 518 | * |
bpatel@766 | 519 | * @param body the content tree to which user specified top will be added |
bpatel@766 | 520 | */ |
bpatel@766 | 521 | public void addTop(Content body) { |
bpatel@766 | 522 | Content top = new RawHtml(replaceDocRootDir(configuration.top)); |
bpatel@766 | 523 | body.addContent(top); |
bpatel@766 | 524 | } |
bpatel@766 | 525 | |
bpatel@766 | 526 | /** |
duke@1 | 527 | * Print the user specified bottom. |
duke@1 | 528 | */ |
duke@1 | 529 | public void printBottom() { |
duke@1 | 530 | hr(); |
duke@1 | 531 | print(replaceDocRootDir(configuration.bottom)); |
duke@1 | 532 | } |
duke@1 | 533 | |
duke@1 | 534 | /** |
bpatel@766 | 535 | * Adds the user specified bottom. |
bpatel@766 | 536 | * |
bpatel@766 | 537 | * @param body the content tree to which user specified bottom will be added |
bpatel@766 | 538 | */ |
bpatel@766 | 539 | public void addBottom(Content body) { |
bpatel@766 | 540 | Content bottom = new RawHtml(replaceDocRootDir(configuration.bottom)); |
bpatel@766 | 541 | Content small = HtmlTree.SMALL(bottom); |
bpatel@766 | 542 | Content p = HtmlTree.P(HtmlStyle.legalCopy, small); |
bpatel@766 | 543 | body.addContent(p); |
bpatel@766 | 544 | } |
bpatel@766 | 545 | |
bpatel@766 | 546 | /** |
duke@1 | 547 | * Print the navigation bar for the Html page at the top and and the bottom. |
duke@1 | 548 | * |
duke@1 | 549 | * @param header If true print navigation bar at the top of the page else |
duke@1 | 550 | * print the nevigation bar at the bottom. |
duke@1 | 551 | */ |
duke@1 | 552 | protected void navLinks(boolean header) { |
duke@1 | 553 | println(""); |
duke@1 | 554 | if (!configuration.nonavbar) { |
duke@1 | 555 | if (header) { |
duke@1 | 556 | println(DocletConstants.NL + "<!-- ========= START OF TOP NAVBAR ======= -->"); |
duke@1 | 557 | anchor("navbar_top"); |
duke@1 | 558 | println(); |
bpatel@766 | 559 | print(getHyperLinkString("", "skip-navbar_top", "", false, "", |
duke@1 | 560 | configuration.getText("doclet.Skip_navigation_links"), "")); |
duke@1 | 561 | } else { |
duke@1 | 562 | println(DocletConstants.NL + "<!-- ======= START OF BOTTOM NAVBAR ====== -->"); |
duke@1 | 563 | anchor("navbar_bottom"); |
duke@1 | 564 | println(); |
bpatel@766 | 565 | print(getHyperLinkString("", "skip-navbar_bottom", "", false, "", |
duke@1 | 566 | configuration.getText("doclet.Skip_navigation_links"), "")); |
duke@1 | 567 | } |
duke@1 | 568 | table(0, "100%", 1, 0); |
duke@1 | 569 | tr(); |
duke@1 | 570 | tdColspanBgcolorStyle(2, "#EEEEFF", "NavBarCell1"); |
duke@1 | 571 | println(""); |
duke@1 | 572 | if (header) { |
duke@1 | 573 | anchor("navbar_top_firstrow"); |
duke@1 | 574 | } else { |
duke@1 | 575 | anchor("navbar_bottom_firstrow"); |
duke@1 | 576 | } |
duke@1 | 577 | table(0, 0, 3); |
duke@1 | 578 | print(" "); |
duke@1 | 579 | trAlignVAlign("center", "top"); |
duke@1 | 580 | |
duke@1 | 581 | if (configuration.createoverview) { |
duke@1 | 582 | navLinkContents(); |
duke@1 | 583 | } |
duke@1 | 584 | |
duke@1 | 585 | if (configuration.packages.length == 1) { |
duke@1 | 586 | navLinkPackage(configuration.packages[0]); |
duke@1 | 587 | } else if (configuration.packages.length > 1) { |
duke@1 | 588 | navLinkPackage(); |
duke@1 | 589 | } |
duke@1 | 590 | |
duke@1 | 591 | navLinkClass(); |
duke@1 | 592 | |
duke@1 | 593 | if(configuration.classuse) { |
duke@1 | 594 | navLinkClassUse(); |
duke@1 | 595 | } |
duke@1 | 596 | if(configuration.createtree) { |
duke@1 | 597 | navLinkTree(); |
duke@1 | 598 | } |
duke@1 | 599 | if(!(configuration.nodeprecated || |
duke@1 | 600 | configuration.nodeprecatedlist)) { |
duke@1 | 601 | navLinkDeprecated(); |
duke@1 | 602 | } |
duke@1 | 603 | if(configuration.createindex) { |
duke@1 | 604 | navLinkIndex(); |
duke@1 | 605 | } |
duke@1 | 606 | if (!configuration.nohelp) { |
duke@1 | 607 | navLinkHelp(); |
duke@1 | 608 | } |
duke@1 | 609 | print(" "); |
duke@1 | 610 | trEnd(); |
duke@1 | 611 | tableEnd(); |
duke@1 | 612 | tdEnd(); |
duke@1 | 613 | |
duke@1 | 614 | tdAlignVAlignRowspan("right", "top", 3); |
duke@1 | 615 | |
duke@1 | 616 | printUserHeaderFooter(header); |
duke@1 | 617 | tdEnd(); |
duke@1 | 618 | trEnd(); |
duke@1 | 619 | println(""); |
duke@1 | 620 | |
duke@1 | 621 | tr(); |
duke@1 | 622 | tdBgcolorStyle("white", "NavBarCell2"); |
duke@1 | 623 | font("-2"); |
duke@1 | 624 | space(); |
duke@1 | 625 | navLinkPrevious(); |
duke@1 | 626 | space(); |
duke@1 | 627 | println(""); |
duke@1 | 628 | space(); |
duke@1 | 629 | navLinkNext(); |
duke@1 | 630 | fontEnd(); |
duke@1 | 631 | tdEnd(); |
duke@1 | 632 | |
duke@1 | 633 | tdBgcolorStyle("white", "NavBarCell2"); |
duke@1 | 634 | font("-2"); |
duke@1 | 635 | print(" "); |
duke@1 | 636 | navShowLists(); |
duke@1 | 637 | print(" "); |
duke@1 | 638 | space(); |
duke@1 | 639 | println(""); |
duke@1 | 640 | space(); |
duke@1 | 641 | navHideLists(filename); |
duke@1 | 642 | print(" "); |
duke@1 | 643 | space(); |
duke@1 | 644 | println(""); |
duke@1 | 645 | space(); |
duke@1 | 646 | navLinkClassIndex(); |
duke@1 | 647 | fontEnd(); |
duke@1 | 648 | tdEnd(); |
duke@1 | 649 | |
duke@1 | 650 | trEnd(); |
duke@1 | 651 | |
duke@1 | 652 | printSummaryDetailLinks(); |
duke@1 | 653 | |
duke@1 | 654 | tableEnd(); |
duke@1 | 655 | if (header) { |
duke@1 | 656 | aName("skip-navbar_top"); |
duke@1 | 657 | aEnd(); |
duke@1 | 658 | println(DocletConstants.NL + "<!-- ========= END OF TOP NAVBAR ========= -->"); |
duke@1 | 659 | } else { |
duke@1 | 660 | aName("skip-navbar_bottom"); |
duke@1 | 661 | aEnd(); |
duke@1 | 662 | println(DocletConstants.NL + "<!-- ======== END OF BOTTOM NAVBAR ======= -->"); |
duke@1 | 663 | } |
duke@1 | 664 | println(""); |
duke@1 | 665 | } |
duke@1 | 666 | } |
duke@1 | 667 | |
duke@1 | 668 | /** |
bpatel@766 | 669 | * Adds the navigation bar for the Html page at the top and and the bottom. |
bpatel@766 | 670 | * |
bpatel@766 | 671 | * @param header If true print navigation bar at the top of the page else |
bpatel@766 | 672 | * @param body the HtmlTree to which the nav links will be added |
bpatel@766 | 673 | */ |
bpatel@766 | 674 | protected void addNavLinks(boolean header, Content body) { |
bpatel@766 | 675 | if (!configuration.nonavbar) { |
bpatel@766 | 676 | String allClassesId = "allclasses_"; |
bpatel@766 | 677 | HtmlTree navDiv = new HtmlTree(HtmlTag.DIV); |
bpatel@766 | 678 | if (header) { |
bpatel@766 | 679 | body.addContent(HtmlConstants.START_OF_TOP_NAVBAR); |
bpatel@766 | 680 | navDiv.addStyle(HtmlStyle.topNav); |
bpatel@766 | 681 | allClassesId += "navbar_top"; |
bpatel@766 | 682 | Content a = getMarkerAnchor("navbar_top"); |
bpatel@766 | 683 | navDiv.addContent(a); |
bpatel@766 | 684 | Content skipLinkContent = getHyperLink("", |
bpatel@766 | 685 | "skip-navbar_top", HtmlTree.EMPTY, configuration.getText( |
bpatel@766 | 686 | "doclet.Skip_navigation_links"), ""); |
bpatel@766 | 687 | navDiv.addContent(skipLinkContent); |
bpatel@766 | 688 | } else { |
bpatel@766 | 689 | body.addContent(HtmlConstants.START_OF_BOTTOM_NAVBAR); |
bpatel@766 | 690 | navDiv.addStyle(HtmlStyle.bottomNav); |
bpatel@766 | 691 | allClassesId += "navbar_bottom"; |
bpatel@766 | 692 | Content a = getMarkerAnchor("navbar_bottom"); |
bpatel@766 | 693 | navDiv.addContent(a); |
bpatel@766 | 694 | Content skipLinkContent = getHyperLink("", |
bpatel@766 | 695 | "skip-navbar_bottom", HtmlTree.EMPTY, configuration.getText( |
bpatel@766 | 696 | "doclet.Skip_navigation_links"), ""); |
bpatel@766 | 697 | navDiv.addContent(skipLinkContent); |
bpatel@766 | 698 | } |
bpatel@766 | 699 | if (header) { |
bpatel@766 | 700 | navDiv.addContent(getMarkerAnchor("navbar_top_firstrow")); |
bpatel@766 | 701 | } else { |
bpatel@766 | 702 | navDiv.addContent(getMarkerAnchor("navbar_bottom_firstrow")); |
bpatel@766 | 703 | } |
bpatel@766 | 704 | HtmlTree navList = new HtmlTree(HtmlTag.UL); |
bpatel@766 | 705 | navList.addStyle(HtmlStyle.navList); |
bpatel@766 | 706 | navList.addAttr(HtmlAttr.TITLE, "Navigation"); |
bpatel@766 | 707 | if (configuration.createoverview) { |
bpatel@766 | 708 | navList.addContent(getNavLinkContents()); |
bpatel@766 | 709 | } |
bpatel@766 | 710 | if (configuration.packages.length == 1) { |
bpatel@766 | 711 | navList.addContent(getNavLinkPackage(configuration.packages[0])); |
bpatel@766 | 712 | } else if (configuration.packages.length > 1) { |
bpatel@766 | 713 | navList.addContent(getNavLinkPackage()); |
bpatel@766 | 714 | } |
bpatel@766 | 715 | navList.addContent(getNavLinkClass()); |
bpatel@766 | 716 | if(configuration.classuse) { |
bpatel@766 | 717 | navList.addContent(getNavLinkClassUse()); |
bpatel@766 | 718 | } |
bpatel@766 | 719 | if(configuration.createtree) { |
bpatel@766 | 720 | navList.addContent(getNavLinkTree()); |
bpatel@766 | 721 | } |
bpatel@766 | 722 | if(!(configuration.nodeprecated || |
bpatel@766 | 723 | configuration.nodeprecatedlist)) { |
bpatel@766 | 724 | navList.addContent(getNavLinkDeprecated()); |
bpatel@766 | 725 | } |
bpatel@766 | 726 | if(configuration.createindex) { |
bpatel@766 | 727 | navList.addContent(getNavLinkIndex()); |
bpatel@766 | 728 | } |
bpatel@766 | 729 | if (!configuration.nohelp) { |
bpatel@766 | 730 | navList.addContent(getNavLinkHelp()); |
bpatel@766 | 731 | } |
bpatel@766 | 732 | navDiv.addContent(navList); |
bpatel@766 | 733 | Content aboutDiv = HtmlTree.DIV(HtmlStyle.aboutLanguage, getUserHeaderFooter(header)); |
bpatel@766 | 734 | navDiv.addContent(aboutDiv); |
bpatel@766 | 735 | body.addContent(navDiv); |
bpatel@766 | 736 | Content ulNav = HtmlTree.UL(HtmlStyle.navList, getNavLinkPrevious()); |
bpatel@766 | 737 | ulNav.addContent(getNavLinkNext()); |
bpatel@766 | 738 | Content subDiv = HtmlTree.DIV(HtmlStyle.subNav, ulNav); |
bpatel@766 | 739 | Content ulFrames = HtmlTree.UL(HtmlStyle.navList, getNavShowLists()); |
bpatel@766 | 740 | ulFrames.addContent(getNavHideLists(filename)); |
bpatel@766 | 741 | subDiv.addContent(ulFrames); |
bpatel@766 | 742 | HtmlTree ulAllClasses = HtmlTree.UL(HtmlStyle.navList, getNavLinkClassIndex()); |
bpatel@766 | 743 | ulAllClasses.addAttr(HtmlAttr.ID, allClassesId.toString()); |
bpatel@766 | 744 | subDiv.addContent(ulAllClasses); |
bpatel@766 | 745 | subDiv.addContent(getAllClassesLinkScript(allClassesId.toString())); |
bpatel@766 | 746 | addSummaryDetailLinks(subDiv); |
bpatel@766 | 747 | if (header) { |
bpatel@766 | 748 | subDiv.addContent(getMarkerAnchor("skip-navbar_top")); |
bpatel@766 | 749 | body.addContent(subDiv); |
bpatel@766 | 750 | body.addContent(HtmlConstants.END_OF_TOP_NAVBAR); |
bpatel@766 | 751 | } else { |
bpatel@766 | 752 | subDiv.addContent(getMarkerAnchor("skip-navbar_bottom")); |
bpatel@766 | 753 | body.addContent(subDiv); |
bpatel@766 | 754 | body.addContent(HtmlConstants.END_OF_BOTTOM_NAVBAR); |
bpatel@766 | 755 | } |
bpatel@766 | 756 | } |
bpatel@766 | 757 | } |
bpatel@766 | 758 | |
bpatel@766 | 759 | /** |
duke@1 | 760 | * Print the word "NEXT" to indicate that no link is available. Override |
duke@1 | 761 | * this method to customize next link. |
duke@1 | 762 | */ |
duke@1 | 763 | protected void navLinkNext() { |
duke@1 | 764 | navLinkNext(null); |
duke@1 | 765 | } |
duke@1 | 766 | |
duke@1 | 767 | /** |
bpatel@766 | 768 | * Get the word "NEXT" to indicate that no link is available. Override |
bpatel@766 | 769 | * this method to customize next link. |
bpatel@766 | 770 | * |
bpatel@766 | 771 | * @return a content tree for the link |
bpatel@766 | 772 | */ |
bpatel@766 | 773 | protected Content getNavLinkNext() { |
bpatel@766 | 774 | return getNavLinkNext(null); |
bpatel@766 | 775 | } |
bpatel@766 | 776 | |
bpatel@766 | 777 | /** |
duke@1 | 778 | * Print the word "PREV" to indicate that no link is available. Override |
duke@1 | 779 | * this method to customize prev link. |
duke@1 | 780 | */ |
duke@1 | 781 | protected void navLinkPrevious() { |
duke@1 | 782 | navLinkPrevious(null); |
duke@1 | 783 | } |
duke@1 | 784 | |
duke@1 | 785 | /** |
bpatel@766 | 786 | * Get the word "PREV" to indicate that no link is available. Override |
bpatel@766 | 787 | * this method to customize prev link. |
bpatel@766 | 788 | * |
bpatel@766 | 789 | * @return a content tree for the link |
bpatel@766 | 790 | */ |
bpatel@766 | 791 | protected Content getNavLinkPrevious() { |
bpatel@766 | 792 | return getNavLinkPrevious(null); |
bpatel@766 | 793 | } |
bpatel@766 | 794 | |
bpatel@766 | 795 | /** |
duke@1 | 796 | * Do nothing. This is the default method. |
duke@1 | 797 | */ |
duke@1 | 798 | protected void printSummaryDetailLinks() { |
duke@1 | 799 | } |
duke@1 | 800 | |
duke@1 | 801 | /** |
bpatel@766 | 802 | * Do nothing. This is the default method. |
bpatel@766 | 803 | */ |
bpatel@766 | 804 | protected void addSummaryDetailLinks(Content navDiv) { |
bpatel@766 | 805 | } |
bpatel@766 | 806 | |
bpatel@766 | 807 | /** |
duke@1 | 808 | * Print link to the "overview-summary.html" page. |
duke@1 | 809 | */ |
duke@1 | 810 | protected void navLinkContents() { |
duke@1 | 811 | navCellStart(); |
duke@1 | 812 | printHyperLink(relativePath + "overview-summary.html", "", |
duke@1 | 813 | configuration.getText("doclet.Overview"), true, "NavBarFont1"); |
duke@1 | 814 | navCellEnd(); |
duke@1 | 815 | } |
duke@1 | 816 | |
duke@1 | 817 | /** |
bpatel@766 | 818 | * Get link to the "overview-summary.html" page. |
bpatel@766 | 819 | * |
bpatel@766 | 820 | * @return a content tree for the link |
bpatel@766 | 821 | */ |
bpatel@766 | 822 | protected Content getNavLinkContents() { |
bpatel@766 | 823 | Content linkContent = getHyperLink(relativePath + |
bpatel@766 | 824 | "overview-summary.html", "", overviewLabel, "", ""); |
bpatel@766 | 825 | Content li = HtmlTree.LI(linkContent); |
bpatel@766 | 826 | return li; |
bpatel@766 | 827 | } |
bpatel@766 | 828 | |
bpatel@766 | 829 | /** |
duke@1 | 830 | * Description for a cell in the navigation bar. |
duke@1 | 831 | */ |
duke@1 | 832 | protected void navCellStart() { |
duke@1 | 833 | print(" "); |
duke@1 | 834 | tdBgcolorStyle("#EEEEFF", "NavBarCell1"); |
duke@1 | 835 | print(" "); |
duke@1 | 836 | } |
duke@1 | 837 | |
duke@1 | 838 | /** |
duke@1 | 839 | * Description for a cell in the navigation bar, but with reverse |
duke@1 | 840 | * high-light effect. |
duke@1 | 841 | */ |
duke@1 | 842 | protected void navCellRevStart() { |
duke@1 | 843 | print(" "); |
duke@1 | 844 | tdBgcolorStyle("#FFFFFF", "NavBarCell1Rev"); |
duke@1 | 845 | print(" "); |
duke@1 | 846 | space(); |
duke@1 | 847 | } |
duke@1 | 848 | |
duke@1 | 849 | /** |
duke@1 | 850 | * Closing tag for navigation bar cell. |
duke@1 | 851 | */ |
duke@1 | 852 | protected void navCellEnd() { |
duke@1 | 853 | space(); |
duke@1 | 854 | tdEnd(); |
duke@1 | 855 | } |
duke@1 | 856 | |
duke@1 | 857 | /** |
duke@1 | 858 | * Print link to the "package-summary.html" page for the package passed. |
duke@1 | 859 | * |
duke@1 | 860 | * @param pkg Package to which link will be generated. |
duke@1 | 861 | */ |
duke@1 | 862 | protected void navLinkPackage(PackageDoc pkg) { |
duke@1 | 863 | navCellStart(); |
duke@1 | 864 | printPackageLink(pkg, configuration.getText("doclet.Package"), true, |
duke@1 | 865 | "NavBarFont1"); |
duke@1 | 866 | navCellEnd(); |
duke@1 | 867 | } |
duke@1 | 868 | |
duke@1 | 869 | /** |
bpatel@766 | 870 | * Get link to the "package-summary.html" page for the package passed. |
bpatel@766 | 871 | * |
bpatel@766 | 872 | * @param pkg Package to which link will be generated |
bpatel@766 | 873 | * @return a content tree for the link |
bpatel@766 | 874 | */ |
bpatel@766 | 875 | protected Content getNavLinkPackage(PackageDoc pkg) { |
bpatel@766 | 876 | Content linkContent = getPackageLink(pkg, |
bpatel@766 | 877 | packageLabel); |
bpatel@766 | 878 | Content li = HtmlTree.LI(linkContent); |
bpatel@766 | 879 | return li; |
bpatel@766 | 880 | } |
bpatel@766 | 881 | |
bpatel@766 | 882 | /** |
duke@1 | 883 | * Print the word "Package" in the navigation bar cell, to indicate that |
duke@1 | 884 | * link is not available here. |
duke@1 | 885 | */ |
duke@1 | 886 | protected void navLinkPackage() { |
duke@1 | 887 | navCellStart(); |
duke@1 | 888 | fontStyle("NavBarFont1"); |
duke@1 | 889 | printText("doclet.Package"); |
duke@1 | 890 | fontEnd(); |
duke@1 | 891 | navCellEnd(); |
duke@1 | 892 | } |
duke@1 | 893 | |
duke@1 | 894 | /** |
bpatel@766 | 895 | * Get the word "Package" , to indicate that link is not available here. |
bpatel@766 | 896 | * |
bpatel@766 | 897 | * @return a content tree for the link |
bpatel@766 | 898 | */ |
bpatel@766 | 899 | protected Content getNavLinkPackage() { |
bpatel@766 | 900 | Content li = HtmlTree.LI(packageLabel); |
bpatel@766 | 901 | return li; |
bpatel@766 | 902 | } |
bpatel@766 | 903 | |
bpatel@766 | 904 | /** |
duke@1 | 905 | * Print the word "Use" in the navigation bar cell, to indicate that link |
duke@1 | 906 | * is not available. |
duke@1 | 907 | */ |
duke@1 | 908 | protected void navLinkClassUse() { |
duke@1 | 909 | navCellStart(); |
duke@1 | 910 | fontStyle("NavBarFont1"); |
duke@1 | 911 | printText("doclet.navClassUse"); |
duke@1 | 912 | fontEnd(); |
duke@1 | 913 | navCellEnd(); |
duke@1 | 914 | } |
duke@1 | 915 | |
duke@1 | 916 | /** |
bpatel@766 | 917 | * Get the word "Use", to indicate that link is not available. |
bpatel@766 | 918 | * |
bpatel@766 | 919 | * @return a content tree for the link |
bpatel@766 | 920 | */ |
bpatel@766 | 921 | protected Content getNavLinkClassUse() { |
bpatel@766 | 922 | Content li = HtmlTree.LI(useLabel); |
bpatel@766 | 923 | return li; |
bpatel@766 | 924 | } |
bpatel@766 | 925 | |
bpatel@766 | 926 | /** |
duke@1 | 927 | * Print link for previous file. |
duke@1 | 928 | * |
duke@1 | 929 | * @param prev File name for the prev link. |
duke@1 | 930 | */ |
duke@1 | 931 | public void navLinkPrevious(String prev) { |
duke@1 | 932 | String tag = configuration.getText("doclet.Prev"); |
duke@1 | 933 | if (prev != null) { |
duke@1 | 934 | printHyperLink(prev, "", tag, true) ; |
duke@1 | 935 | } else { |
duke@1 | 936 | print(tag); |
duke@1 | 937 | } |
duke@1 | 938 | } |
duke@1 | 939 | |
duke@1 | 940 | /** |
bpatel@766 | 941 | * Get link for previous file. |
bpatel@766 | 942 | * |
bpatel@766 | 943 | * @param prev File name for the prev link |
bpatel@766 | 944 | * @return a content tree for the link |
bpatel@766 | 945 | */ |
bpatel@766 | 946 | public Content getNavLinkPrevious(String prev) { |
bpatel@766 | 947 | Content li; |
bpatel@766 | 948 | if (prev != null) { |
bpatel@766 | 949 | li = HtmlTree.LI(getHyperLink(prev, "", prevLabel, "", "")); |
bpatel@766 | 950 | } |
bpatel@766 | 951 | else |
bpatel@766 | 952 | li = HtmlTree.LI(prevLabel); |
bpatel@766 | 953 | return li; |
bpatel@766 | 954 | } |
bpatel@766 | 955 | |
bpatel@766 | 956 | /** |
duke@1 | 957 | * Print link for next file. If next is null, just print the label |
duke@1 | 958 | * without linking it anywhere. |
duke@1 | 959 | * |
duke@1 | 960 | * @param next File name for the next link. |
duke@1 | 961 | */ |
duke@1 | 962 | public void navLinkNext(String next) { |
duke@1 | 963 | String tag = configuration.getText("doclet.Next"); |
duke@1 | 964 | if (next != null) { |
duke@1 | 965 | printHyperLink(next, "", tag, true); |
duke@1 | 966 | } else { |
duke@1 | 967 | print(tag); |
duke@1 | 968 | } |
duke@1 | 969 | } |
duke@1 | 970 | |
duke@1 | 971 | /** |
bpatel@766 | 972 | * Get link for next file. If next is null, just print the label |
bpatel@766 | 973 | * without linking it anywhere. |
bpatel@766 | 974 | * |
bpatel@766 | 975 | * @param next File name for the next link |
bpatel@766 | 976 | * @return a content tree for the link |
bpatel@766 | 977 | */ |
bpatel@766 | 978 | public Content getNavLinkNext(String next) { |
bpatel@766 | 979 | Content li; |
bpatel@766 | 980 | if (next != null) { |
bpatel@766 | 981 | li = HtmlTree.LI(getHyperLink(next, "", nextLabel, "", "")); |
bpatel@766 | 982 | } |
bpatel@766 | 983 | else |
bpatel@766 | 984 | li = HtmlTree.LI(nextLabel); |
bpatel@766 | 985 | return li; |
bpatel@766 | 986 | } |
bpatel@766 | 987 | |
bpatel@766 | 988 | /** |
duke@1 | 989 | * Print "FRAMES" link, to switch to the frame version of the output. |
duke@1 | 990 | * |
duke@1 | 991 | * @param link File to be linked, "index.html". |
duke@1 | 992 | */ |
duke@1 | 993 | protected void navShowLists(String link) { |
bpatel@766 | 994 | print(getHyperLinkString(link + "?" + path + filename, "", |
duke@1 | 995 | configuration.getText("doclet.FRAMES"), true, "", "", "_top")); |
duke@1 | 996 | } |
duke@1 | 997 | |
duke@1 | 998 | /** |
bpatel@766 | 999 | * Get "FRAMES" link, to switch to the frame version of the output. |
bpatel@766 | 1000 | * |
bpatel@766 | 1001 | * @param link File to be linked, "index.html" |
bpatel@766 | 1002 | * @return a content tree for the link |
bpatel@766 | 1003 | */ |
bpatel@766 | 1004 | protected Content getNavShowLists(String link) { |
bpatel@766 | 1005 | Content framesContent = getHyperLink(link + "?" + path + |
bpatel@766 | 1006 | filename, "", framesLabel, "", "_top"); |
bpatel@766 | 1007 | Content li = HtmlTree.LI(framesContent); |
bpatel@766 | 1008 | return li; |
bpatel@766 | 1009 | } |
bpatel@766 | 1010 | |
bpatel@766 | 1011 | /** |
duke@1 | 1012 | * Print "FRAMES" link, to switch to the frame version of the output. |
duke@1 | 1013 | */ |
duke@1 | 1014 | protected void navShowLists() { |
duke@1 | 1015 | navShowLists(relativePath + "index.html"); |
duke@1 | 1016 | } |
duke@1 | 1017 | |
duke@1 | 1018 | /** |
bpatel@766 | 1019 | * Get "FRAMES" link, to switch to the frame version of the output. |
bpatel@766 | 1020 | * |
bpatel@766 | 1021 | * @return a content tree for the link |
bpatel@766 | 1022 | */ |
bpatel@766 | 1023 | protected Content getNavShowLists() { |
bpatel@766 | 1024 | return getNavShowLists(relativePath + "index.html"); |
bpatel@766 | 1025 | } |
bpatel@766 | 1026 | |
bpatel@766 | 1027 | /** |
duke@1 | 1028 | * Print "NO FRAMES" link, to switch to the non-frame version of the output. |
duke@1 | 1029 | * |
duke@1 | 1030 | * @param link File to be linked. |
duke@1 | 1031 | */ |
duke@1 | 1032 | protected void navHideLists(String link) { |
bpatel@766 | 1033 | print(getHyperLinkString(link, "", configuration.getText("doclet.NO_FRAMES"), |
duke@1 | 1034 | true, "", "", "_top")); |
duke@1 | 1035 | } |
duke@1 | 1036 | |
duke@1 | 1037 | /** |
bpatel@766 | 1038 | * Get "NO FRAMES" link, to switch to the non-frame version of the output. |
bpatel@766 | 1039 | * |
bpatel@766 | 1040 | * @param link File to be linked |
bpatel@766 | 1041 | * @return a content tree for the link |
bpatel@766 | 1042 | */ |
bpatel@766 | 1043 | protected Content getNavHideLists(String link) { |
bpatel@766 | 1044 | Content noFramesContent = getHyperLink(link, "", noframesLabel, "", "_top"); |
bpatel@766 | 1045 | Content li = HtmlTree.LI(noFramesContent); |
bpatel@766 | 1046 | return li; |
bpatel@766 | 1047 | } |
bpatel@766 | 1048 | |
bpatel@766 | 1049 | /** |
duke@1 | 1050 | * Print "Tree" link in the navigation bar. If there is only one package |
duke@1 | 1051 | * specified on the command line, then the "Tree" link will be to the |
duke@1 | 1052 | * only "package-tree.html" file otherwise it will be to the |
duke@1 | 1053 | * "overview-tree.html" file. |
duke@1 | 1054 | */ |
duke@1 | 1055 | protected void navLinkTree() { |
duke@1 | 1056 | navCellStart(); |
duke@1 | 1057 | PackageDoc[] packages = configuration.root.specifiedPackages(); |
duke@1 | 1058 | if (packages.length == 1 && configuration.root.specifiedClasses().length == 0) { |
duke@1 | 1059 | printHyperLink(pathString(packages[0], "package-tree.html"), "", |
duke@1 | 1060 | configuration.getText("doclet.Tree"), true, "NavBarFont1"); |
duke@1 | 1061 | } else { |
duke@1 | 1062 | printHyperLink(relativePath + "overview-tree.html", "", |
duke@1 | 1063 | configuration.getText("doclet.Tree"), true, "NavBarFont1"); |
duke@1 | 1064 | } |
duke@1 | 1065 | navCellEnd(); |
duke@1 | 1066 | } |
duke@1 | 1067 | |
duke@1 | 1068 | /** |
bpatel@766 | 1069 | * Get "Tree" link in the navigation bar. If there is only one package |
bpatel@766 | 1070 | * specified on the command line, then the "Tree" link will be to the |
bpatel@766 | 1071 | * only "package-tree.html" file otherwise it will be to the |
bpatel@766 | 1072 | * "overview-tree.html" file. |
bpatel@766 | 1073 | * |
bpatel@766 | 1074 | * @return a content tree for the link |
duke@1 | 1075 | */ |
bpatel@766 | 1076 | protected Content getNavLinkTree() { |
bpatel@766 | 1077 | Content treeLinkContent; |
bpatel@766 | 1078 | PackageDoc[] packages = configuration.root.specifiedPackages(); |
bpatel@766 | 1079 | if (packages.length == 1 && configuration.root.specifiedClasses().length == 0) { |
bpatel@766 | 1080 | treeLinkContent = getHyperLink(pathString(packages[0], |
bpatel@766 | 1081 | "package-tree.html"), "", treeLabel, |
bpatel@766 | 1082 | "", ""); |
bpatel@766 | 1083 | } else { |
bpatel@766 | 1084 | treeLinkContent = getHyperLink(relativePath + "overview-tree.html", |
bpatel@766 | 1085 | "", treeLabel, "", ""); |
bpatel@766 | 1086 | } |
bpatel@766 | 1087 | Content li = HtmlTree.LI(treeLinkContent); |
bpatel@766 | 1088 | return li; |
bpatel@766 | 1089 | } |
bpatel@766 | 1090 | |
bpatel@766 | 1091 | /** |
bpatel@766 | 1092 | * Get the overview tree link for the main tree. |
bpatel@766 | 1093 | * |
bpatel@766 | 1094 | * @param label the label for the link |
bpatel@766 | 1095 | * @return a content tree for the link |
bpatel@766 | 1096 | */ |
bpatel@766 | 1097 | protected Content getNavLinkMainTree(String label) { |
bpatel@766 | 1098 | Content mainTreeContent = getHyperLink(relativePath + "overview-tree.html", |
bpatel@766 | 1099 | new StringContent(label)); |
bpatel@766 | 1100 | Content li = HtmlTree.LI(mainTreeContent); |
bpatel@766 | 1101 | return li; |
duke@1 | 1102 | } |
duke@1 | 1103 | |
duke@1 | 1104 | /** |
duke@1 | 1105 | * Print the word "Class" in the navigation bar cell, to indicate that |
duke@1 | 1106 | * class link is not available. |
duke@1 | 1107 | */ |
duke@1 | 1108 | protected void navLinkClass() { |
duke@1 | 1109 | navCellStart(); |
duke@1 | 1110 | fontStyle("NavBarFont1"); |
duke@1 | 1111 | printText("doclet.Class"); |
duke@1 | 1112 | fontEnd(); |
duke@1 | 1113 | navCellEnd(); |
duke@1 | 1114 | } |
duke@1 | 1115 | |
duke@1 | 1116 | /** |
bpatel@766 | 1117 | * Get the word "Class", to indicate that class link is not available. |
bpatel@766 | 1118 | * |
bpatel@766 | 1119 | * @return a content tree for the link |
bpatel@766 | 1120 | */ |
bpatel@766 | 1121 | protected Content getNavLinkClass() { |
bpatel@766 | 1122 | Content li = HtmlTree.LI(classLabel); |
bpatel@766 | 1123 | return li; |
bpatel@766 | 1124 | } |
bpatel@766 | 1125 | |
bpatel@766 | 1126 | /** |
duke@1 | 1127 | * Print "Deprecated" API link in the navigation bar. |
duke@1 | 1128 | */ |
duke@1 | 1129 | protected void navLinkDeprecated() { |
duke@1 | 1130 | navCellStart(); |
duke@1 | 1131 | printHyperLink(relativePath + "deprecated-list.html", "", |
duke@1 | 1132 | configuration.getText("doclet.navDeprecated"), true, "NavBarFont1"); |
duke@1 | 1133 | navCellEnd(); |
duke@1 | 1134 | } |
duke@1 | 1135 | |
duke@1 | 1136 | /** |
bpatel@766 | 1137 | * Get "Deprecated" API link in the navigation bar. |
bpatel@766 | 1138 | * |
bpatel@766 | 1139 | * @return a content tree for the link |
bpatel@766 | 1140 | */ |
bpatel@766 | 1141 | protected Content getNavLinkDeprecated() { |
bpatel@766 | 1142 | Content linkContent = getHyperLink(relativePath + |
bpatel@766 | 1143 | "deprecated-list.html", "", deprecatedLabel, "", ""); |
bpatel@766 | 1144 | Content li = HtmlTree.LI(linkContent); |
bpatel@766 | 1145 | return li; |
bpatel@766 | 1146 | } |
bpatel@766 | 1147 | |
bpatel@766 | 1148 | /** |
duke@1 | 1149 | * Print link for generated index. If the user has used "-splitindex" |
duke@1 | 1150 | * command line option, then link to file "index-files/index-1.html" is |
duke@1 | 1151 | * generated otherwise link to file "index-all.html" is generated. |
duke@1 | 1152 | */ |
duke@1 | 1153 | protected void navLinkClassIndex() { |
duke@1 | 1154 | printNoFramesTargetHyperLink(relativePath + |
duke@1 | 1155 | AllClassesFrameWriter.OUTPUT_FILE_NAME_NOFRAMES, |
duke@1 | 1156 | "", "", configuration.getText("doclet.All_Classes"), true); |
duke@1 | 1157 | } |
bpatel@766 | 1158 | |
bpatel@766 | 1159 | /** |
bpatel@766 | 1160 | * Get link for generated index. If the user has used "-splitindex" |
bpatel@766 | 1161 | * command line option, then link to file "index-files/index-1.html" is |
bpatel@766 | 1162 | * generated otherwise link to file "index-all.html" is generated. |
bpatel@766 | 1163 | * |
bpatel@766 | 1164 | * @return a content tree for the link |
bpatel@766 | 1165 | */ |
bpatel@766 | 1166 | protected Content getNavLinkClassIndex() { |
bpatel@766 | 1167 | Content allClassesContent = getHyperLink(relativePath + |
bpatel@766 | 1168 | AllClassesFrameWriter.OUTPUT_FILE_NAME_NOFRAMES, "", |
bpatel@766 | 1169 | allclassesLabel, "", ""); |
bpatel@766 | 1170 | Content li = HtmlTree.LI(allClassesContent); |
bpatel@766 | 1171 | return li; |
bpatel@766 | 1172 | } |
duke@1 | 1173 | /** |
duke@1 | 1174 | * Print link for generated class index. |
duke@1 | 1175 | */ |
duke@1 | 1176 | protected void navLinkIndex() { |
duke@1 | 1177 | navCellStart(); |
duke@1 | 1178 | printHyperLink(relativePath + |
duke@1 | 1179 | (configuration.splitindex? |
duke@1 | 1180 | DirectoryManager.getPath("index-files") + |
duke@1 | 1181 | fileseparator: "") + |
duke@1 | 1182 | (configuration.splitindex? |
duke@1 | 1183 | "index-1.html" : "index-all.html"), "", |
duke@1 | 1184 | configuration.getText("doclet.Index"), true, "NavBarFont1"); |
duke@1 | 1185 | navCellEnd(); |
duke@1 | 1186 | } |
duke@1 | 1187 | |
duke@1 | 1188 | /** |
bpatel@766 | 1189 | * Get link for generated class index. |
bpatel@766 | 1190 | * |
bpatel@766 | 1191 | * @return a content tree for the link |
bpatel@766 | 1192 | */ |
bpatel@766 | 1193 | protected Content getNavLinkIndex() { |
bpatel@766 | 1194 | Content linkContent = getHyperLink(relativePath +(configuration.splitindex? |
bpatel@766 | 1195 | DirectoryManager.getPath("index-files") + fileseparator: "") + |
bpatel@766 | 1196 | (configuration.splitindex?"index-1.html" : "index-all.html"), "", |
bpatel@766 | 1197 | indexLabel, "", ""); |
bpatel@766 | 1198 | Content li = HtmlTree.LI(linkContent); |
bpatel@766 | 1199 | return li; |
bpatel@766 | 1200 | } |
bpatel@766 | 1201 | |
bpatel@766 | 1202 | /** |
duke@1 | 1203 | * Print help file link. If user has provided a help file, then generate a |
duke@1 | 1204 | * link to the user given file, which is already copied to current or |
duke@1 | 1205 | * destination directory. |
duke@1 | 1206 | */ |
duke@1 | 1207 | protected void navLinkHelp() { |
duke@1 | 1208 | String helpfilenm = configuration.helpfile; |
duke@1 | 1209 | if (helpfilenm.equals("")) { |
duke@1 | 1210 | helpfilenm = "help-doc.html"; |
duke@1 | 1211 | } else { |
duke@1 | 1212 | int lastsep; |
duke@1 | 1213 | if ((lastsep = helpfilenm.lastIndexOf(File.separatorChar)) != -1) { |
duke@1 | 1214 | helpfilenm = helpfilenm.substring(lastsep + 1); |
duke@1 | 1215 | } |
duke@1 | 1216 | } |
duke@1 | 1217 | navCellStart(); |
duke@1 | 1218 | printHyperLink(relativePath + helpfilenm, "", |
duke@1 | 1219 | configuration.getText("doclet.Help"), true, "NavBarFont1"); |
duke@1 | 1220 | navCellEnd(); |
duke@1 | 1221 | } |
duke@1 | 1222 | |
duke@1 | 1223 | /** |
bpatel@766 | 1224 | * Get help file link. If user has provided a help file, then generate a |
bpatel@766 | 1225 | * link to the user given file, which is already copied to current or |
bpatel@766 | 1226 | * destination directory. |
bpatel@766 | 1227 | * |
bpatel@766 | 1228 | * @return a content tree for the link |
bpatel@766 | 1229 | */ |
bpatel@766 | 1230 | protected Content getNavLinkHelp() { |
bpatel@766 | 1231 | String helpfilenm = configuration.helpfile; |
bpatel@766 | 1232 | if (helpfilenm.equals("")) { |
bpatel@766 | 1233 | helpfilenm = "help-doc.html"; |
bpatel@766 | 1234 | } else { |
bpatel@766 | 1235 | int lastsep; |
bpatel@766 | 1236 | if ((lastsep = helpfilenm.lastIndexOf(File.separatorChar)) != -1) { |
bpatel@766 | 1237 | helpfilenm = helpfilenm.substring(lastsep + 1); |
bpatel@766 | 1238 | } |
bpatel@766 | 1239 | } |
bpatel@766 | 1240 | Content linkContent = getHyperLink(relativePath + helpfilenm, "", |
bpatel@766 | 1241 | helpLabel, "", ""); |
bpatel@766 | 1242 | Content li = HtmlTree.LI(linkContent); |
bpatel@766 | 1243 | return li; |
bpatel@766 | 1244 | } |
bpatel@766 | 1245 | |
bpatel@766 | 1246 | /** |
duke@1 | 1247 | * Print the word "Detail" in the navigation bar. No link is available. |
duke@1 | 1248 | */ |
duke@1 | 1249 | protected void navDetail() { |
duke@1 | 1250 | printText("doclet.Detail"); |
duke@1 | 1251 | } |
duke@1 | 1252 | |
duke@1 | 1253 | /** |
duke@1 | 1254 | * Print the word "Summary" in the navigation bar. No link is available. |
duke@1 | 1255 | */ |
duke@1 | 1256 | protected void navSummary() { |
duke@1 | 1257 | printText("doclet.Summary"); |
duke@1 | 1258 | } |
duke@1 | 1259 | |
duke@1 | 1260 | /** |
duke@1 | 1261 | * Print the Html table tag for the index summary tables. The table tag |
duke@1 | 1262 | * printed is |
jjg@1326 | 1263 | * {@code <TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"> } |
duke@1 | 1264 | */ |
duke@1 | 1265 | public void tableIndexSummary() { |
duke@1 | 1266 | table(1, "100%", 3, 0); |
duke@1 | 1267 | } |
duke@1 | 1268 | |
duke@1 | 1269 | /** |
bpatel@243 | 1270 | * Print the Html table tag for the index summary tables. |
bpatel@243 | 1271 | * |
bpatel@243 | 1272 | * @param summary the summary for the table tag summary attribute. |
bpatel@243 | 1273 | */ |
bpatel@243 | 1274 | public void tableIndexSummary(String summary) { |
bpatel@243 | 1275 | table(1, "100%", 3, 0, summary); |
bpatel@243 | 1276 | } |
bpatel@243 | 1277 | |
bpatel@243 | 1278 | /** |
duke@1 | 1279 | * Same as {@link #tableIndexSummary()}. |
duke@1 | 1280 | */ |
duke@1 | 1281 | public void tableIndexDetail() { |
duke@1 | 1282 | table(1, "100%", 3, 0); |
duke@1 | 1283 | } |
duke@1 | 1284 | |
duke@1 | 1285 | /** |
duke@1 | 1286 | * Print Html tag for table elements. The tag printed is |
duke@1 | 1287 | * <TD ALIGN="right" VALIGN="top" WIDTH="1%">. |
duke@1 | 1288 | */ |
duke@1 | 1289 | public void tdIndex() { |
duke@1 | 1290 | print("<TD ALIGN=\"right\" VALIGN=\"top\" WIDTH=\"1%\">"); |
duke@1 | 1291 | } |
duke@1 | 1292 | |
duke@1 | 1293 | /** |
bpatel@243 | 1294 | * Print table caption. |
bpatel@243 | 1295 | */ |
bpatel@243 | 1296 | public void tableCaptionStart() { |
bpatel@243 | 1297 | captionStyle("TableCaption"); |
bpatel@243 | 1298 | } |
bpatel@243 | 1299 | |
bpatel@243 | 1300 | /** |
bpatel@243 | 1301 | * Print table sub-caption. |
bpatel@243 | 1302 | */ |
bpatel@243 | 1303 | public void tableSubCaptionStart() { |
bpatel@243 | 1304 | captionStyle("TableSubCaption"); |
bpatel@243 | 1305 | } |
bpatel@243 | 1306 | |
bpatel@243 | 1307 | /** |
bpatel@243 | 1308 | * Print table caption end tags. |
bpatel@243 | 1309 | */ |
bpatel@243 | 1310 | public void tableCaptionEnd() { |
bpatel@243 | 1311 | captionEnd(); |
bpatel@243 | 1312 | } |
bpatel@243 | 1313 | |
bpatel@243 | 1314 | /** |
bpatel@243 | 1315 | * Print summary table header. |
bpatel@243 | 1316 | */ |
bpatel@243 | 1317 | public void summaryTableHeader(String[] header, String scope) { |
bpatel@243 | 1318 | tr(); |
bpatel@243 | 1319 | for ( int i=0; i < header.length; i++ ) { |
bpatel@243 | 1320 | thScopeNoWrap("TableHeader", scope); |
bpatel@243 | 1321 | print(header[i]); |
bpatel@243 | 1322 | thEnd(); |
bpatel@243 | 1323 | } |
bpatel@243 | 1324 | trEnd(); |
bpatel@243 | 1325 | } |
bpatel@243 | 1326 | |
bpatel@243 | 1327 | /** |
bpatel@766 | 1328 | * Get summary table header. |
bpatel@766 | 1329 | * |
bpatel@766 | 1330 | * @param header the header for the table |
bpatel@766 | 1331 | * @param scope the scope of the headers |
bpatel@766 | 1332 | * @return a content tree for the header |
bpatel@766 | 1333 | */ |
bpatel@766 | 1334 | public Content getSummaryTableHeader(String[] header, String scope) { |
bpatel@766 | 1335 | Content tr = new HtmlTree(HtmlTag.TR); |
bpatel@766 | 1336 | int size = header.length; |
bpatel@766 | 1337 | Content tableHeader; |
bpatel@766 | 1338 | if (size == 1) { |
bpatel@766 | 1339 | tableHeader = new StringContent(header[0]); |
bpatel@766 | 1340 | tr.addContent(HtmlTree.TH(HtmlStyle.colOne, scope, tableHeader)); |
bpatel@766 | 1341 | return tr; |
bpatel@766 | 1342 | } |
bpatel@766 | 1343 | for (int i = 0; i < size; i++) { |
bpatel@766 | 1344 | tableHeader = new StringContent(header[i]); |
bpatel@766 | 1345 | if(i == 0) |
bpatel@766 | 1346 | tr.addContent(HtmlTree.TH(HtmlStyle.colFirst, scope, tableHeader)); |
bpatel@766 | 1347 | else if(i == (size - 1)) |
bpatel@766 | 1348 | tr.addContent(HtmlTree.TH(HtmlStyle.colLast, scope, tableHeader)); |
bpatel@766 | 1349 | else |
bpatel@766 | 1350 | tr.addContent(HtmlTree.TH(scope, tableHeader)); |
bpatel@766 | 1351 | } |
bpatel@766 | 1352 | return tr; |
bpatel@766 | 1353 | } |
bpatel@766 | 1354 | |
bpatel@766 | 1355 | /** |
bpatel@766 | 1356 | * Get table caption. |
bpatel@766 | 1357 | * |
bpatel@766 | 1358 | * @param rawText the caption for the table which could be raw Html |
bpatel@766 | 1359 | * @return a content tree for the caption |
bpatel@766 | 1360 | */ |
bpatel@766 | 1361 | public Content getTableCaption(String rawText) { |
bpatel@766 | 1362 | Content title = new RawHtml(rawText); |
bpatel@766 | 1363 | Content captionSpan = HtmlTree.SPAN(title); |
bpatel@766 | 1364 | Content space = getSpace(); |
bpatel@766 | 1365 | Content tabSpan = HtmlTree.SPAN(HtmlStyle.tabEnd, space); |
bpatel@766 | 1366 | Content caption = HtmlTree.CAPTION(captionSpan); |
bpatel@766 | 1367 | caption.addContent(tabSpan); |
bpatel@766 | 1368 | return caption; |
bpatel@766 | 1369 | } |
bpatel@766 | 1370 | |
bpatel@766 | 1371 | /** |
bpatel@766 | 1372 | * Get the marker anchor which will be added to the documentation tree. |
bpatel@766 | 1373 | * |
bpatel@766 | 1374 | * @param anchorName the anchor name attribute |
bpatel@766 | 1375 | * @return a content tree for the marker anchor |
bpatel@766 | 1376 | */ |
bpatel@766 | 1377 | public Content getMarkerAnchor(String anchorName) { |
bpatel@766 | 1378 | return getMarkerAnchor(anchorName, null); |
bpatel@766 | 1379 | } |
bpatel@766 | 1380 | |
bpatel@766 | 1381 | /** |
bpatel@766 | 1382 | * Get the marker anchor which will be added to the documentation tree. |
bpatel@766 | 1383 | * |
bpatel@766 | 1384 | * @param anchorName the anchor name attribute |
bpatel@766 | 1385 | * @param anchorContent the content that should be added to the anchor |
bpatel@766 | 1386 | * @return a content tree for the marker anchor |
bpatel@766 | 1387 | */ |
bpatel@766 | 1388 | public Content getMarkerAnchor(String anchorName, Content anchorContent) { |
bpatel@766 | 1389 | if (anchorContent == null) |
bpatel@766 | 1390 | anchorContent = new Comment(" "); |
bpatel@766 | 1391 | Content markerAnchor = HtmlTree.A_NAME(anchorName, anchorContent); |
bpatel@766 | 1392 | return markerAnchor; |
bpatel@766 | 1393 | } |
bpatel@766 | 1394 | |
bpatel@766 | 1395 | /** |
bpatel@766 | 1396 | * Returns a packagename content. |
bpatel@766 | 1397 | * |
bpatel@766 | 1398 | * @param packageDoc the package to check |
bpatel@766 | 1399 | * @return package name content |
bpatel@766 | 1400 | */ |
bpatel@766 | 1401 | public Content getPackageName(PackageDoc packageDoc) { |
bpatel@766 | 1402 | return packageDoc == null || packageDoc.name().length() == 0 ? |
bpatel@766 | 1403 | defaultPackageLabel : |
bpatel@766 | 1404 | getPackageLabel(packageDoc.name()); |
bpatel@766 | 1405 | } |
bpatel@766 | 1406 | |
bpatel@766 | 1407 | /** |
bpatel@766 | 1408 | * Returns a package name label. |
bpatel@766 | 1409 | * |
bpatel@766 | 1410 | * @param parsedName the package name |
bpatel@766 | 1411 | * @return the package name content |
bpatel@766 | 1412 | */ |
bpatel@766 | 1413 | public Content getPackageLabel(String packageName) { |
bpatel@766 | 1414 | return new StringContent(packageName); |
bpatel@766 | 1415 | } |
bpatel@766 | 1416 | |
bpatel@766 | 1417 | /** |
bpatel@995 | 1418 | * Add package deprecation information to the documentation tree |
bpatel@995 | 1419 | * |
bpatel@995 | 1420 | * @param deprPkgs list of deprecated packages |
bpatel@995 | 1421 | * @param headingKey the caption for the deprecated package table |
bpatel@995 | 1422 | * @param tableSummary the summary for the deprecated package table |
bpatel@995 | 1423 | * @param tableHeader table headers for the deprecated package table |
bpatel@995 | 1424 | * @param contentTree the content tree to which the deprecated package table will be added |
bpatel@995 | 1425 | */ |
bpatel@995 | 1426 | protected void addPackageDeprecatedAPI(List<Doc> deprPkgs, String headingKey, |
bpatel@995 | 1427 | String tableSummary, String[] tableHeader, Content contentTree) { |
bpatel@995 | 1428 | if (deprPkgs.size() > 0) { |
bpatel@995 | 1429 | Content table = HtmlTree.TABLE(0, 3, 0, tableSummary, |
bpatel@995 | 1430 | getTableCaption(configuration().getText(headingKey))); |
bpatel@995 | 1431 | table.addContent(getSummaryTableHeader(tableHeader, "col")); |
bpatel@995 | 1432 | Content tbody = new HtmlTree(HtmlTag.TBODY); |
bpatel@995 | 1433 | for (int i = 0; i < deprPkgs.size(); i++) { |
bpatel@995 | 1434 | PackageDoc pkg = (PackageDoc) deprPkgs.get(i); |
bpatel@995 | 1435 | HtmlTree td = HtmlTree.TD(HtmlStyle.colOne, |
bpatel@995 | 1436 | getPackageLink(pkg, getPackageName(pkg))); |
bpatel@995 | 1437 | if (pkg.tags("deprecated").length > 0) { |
bpatel@995 | 1438 | addInlineDeprecatedComment(pkg, pkg.tags("deprecated")[0], td); |
bpatel@995 | 1439 | } |
bpatel@995 | 1440 | HtmlTree tr = HtmlTree.TR(td); |
bpatel@995 | 1441 | if (i % 2 == 0) { |
bpatel@995 | 1442 | tr.addStyle(HtmlStyle.altColor); |
bpatel@995 | 1443 | } else { |
bpatel@995 | 1444 | tr.addStyle(HtmlStyle.rowColor); |
bpatel@995 | 1445 | } |
bpatel@995 | 1446 | tbody.addContent(tr); |
bpatel@995 | 1447 | } |
bpatel@995 | 1448 | table.addContent(tbody); |
bpatel@995 | 1449 | Content li = HtmlTree.LI(HtmlStyle.blockList, table); |
bpatel@995 | 1450 | Content ul = HtmlTree.UL(HtmlStyle.blockList, li); |
bpatel@995 | 1451 | contentTree.addContent(ul); |
bpatel@995 | 1452 | } |
bpatel@995 | 1453 | } |
bpatel@995 | 1454 | |
bpatel@995 | 1455 | /** |
duke@1 | 1456 | * Prine table header information about color, column span and the font. |
duke@1 | 1457 | * |
duke@1 | 1458 | * @param color Background color. |
duke@1 | 1459 | * @param span Column span. |
duke@1 | 1460 | */ |
duke@1 | 1461 | public void tableHeaderStart(String color, int span) { |
duke@1 | 1462 | trBgcolorStyle(color, "TableHeadingColor"); |
duke@1 | 1463 | thAlignColspan("left", span); |
duke@1 | 1464 | font("+2"); |
duke@1 | 1465 | } |
duke@1 | 1466 | |
duke@1 | 1467 | /** |
duke@1 | 1468 | * Print table header for the inherited members summary tables. Print the |
duke@1 | 1469 | * background color information. |
duke@1 | 1470 | * |
duke@1 | 1471 | * @param color Background color. |
duke@1 | 1472 | */ |
duke@1 | 1473 | public void tableInheritedHeaderStart(String color) { |
duke@1 | 1474 | trBgcolorStyle(color, "TableSubHeadingColor"); |
duke@1 | 1475 | thAlign("left"); |
duke@1 | 1476 | } |
duke@1 | 1477 | |
duke@1 | 1478 | /** |
duke@1 | 1479 | * Print "Use" table header. Print the background color and the column span. |
duke@1 | 1480 | * |
duke@1 | 1481 | * @param color Background color. |
duke@1 | 1482 | */ |
duke@1 | 1483 | public void tableUseInfoHeaderStart(String color) { |
duke@1 | 1484 | trBgcolorStyle(color, "TableSubHeadingColor"); |
duke@1 | 1485 | thAlignColspan("left", 2); |
duke@1 | 1486 | } |
duke@1 | 1487 | |
duke@1 | 1488 | /** |
duke@1 | 1489 | * Print table header with the background color with default column span 2. |
duke@1 | 1490 | * |
duke@1 | 1491 | * @param color Background color. |
duke@1 | 1492 | */ |
duke@1 | 1493 | public void tableHeaderStart(String color) { |
duke@1 | 1494 | tableHeaderStart(color, 2); |
duke@1 | 1495 | } |
duke@1 | 1496 | |
duke@1 | 1497 | /** |
duke@1 | 1498 | * Print table header with the column span, with the default color #CCCCFF. |
duke@1 | 1499 | * |
duke@1 | 1500 | * @param span Column span. |
duke@1 | 1501 | */ |
duke@1 | 1502 | public void tableHeaderStart(int span) { |
duke@1 | 1503 | tableHeaderStart("#CCCCFF", span); |
duke@1 | 1504 | } |
duke@1 | 1505 | |
duke@1 | 1506 | /** |
duke@1 | 1507 | * Print table header with default column span 2 and default color #CCCCFF. |
duke@1 | 1508 | */ |
duke@1 | 1509 | public void tableHeaderStart() { |
duke@1 | 1510 | tableHeaderStart(2); |
duke@1 | 1511 | } |
duke@1 | 1512 | |
duke@1 | 1513 | /** |
duke@1 | 1514 | * Print table header end tags for font, column and row. |
duke@1 | 1515 | */ |
duke@1 | 1516 | public void tableHeaderEnd() { |
duke@1 | 1517 | fontEnd(); |
duke@1 | 1518 | thEnd(); |
duke@1 | 1519 | trEnd(); |
duke@1 | 1520 | } |
duke@1 | 1521 | |
duke@1 | 1522 | /** |
duke@1 | 1523 | * Print table header end tags in inherited tables for column and row. |
duke@1 | 1524 | */ |
duke@1 | 1525 | public void tableInheritedHeaderEnd() { |
duke@1 | 1526 | thEnd(); |
duke@1 | 1527 | trEnd(); |
duke@1 | 1528 | } |
duke@1 | 1529 | |
duke@1 | 1530 | /** |
duke@1 | 1531 | * Print the summary table row cell attribute width. |
duke@1 | 1532 | * |
duke@1 | 1533 | * @param width Width of the table cell. |
duke@1 | 1534 | */ |
duke@1 | 1535 | public void summaryRow(int width) { |
duke@1 | 1536 | if (width != 0) { |
duke@1 | 1537 | tdWidth(width + "%"); |
duke@1 | 1538 | } else { |
duke@1 | 1539 | td(); |
duke@1 | 1540 | } |
duke@1 | 1541 | } |
duke@1 | 1542 | |
duke@1 | 1543 | /** |
duke@1 | 1544 | * Print the summary table row cell end tag. |
duke@1 | 1545 | */ |
duke@1 | 1546 | public void summaryRowEnd() { |
duke@1 | 1547 | tdEnd(); |
duke@1 | 1548 | } |
duke@1 | 1549 | |
duke@1 | 1550 | /** |
jjg@1326 | 1551 | * Print the heading in Html {@literal <H2>} format. |
duke@1 | 1552 | * |
duke@1 | 1553 | * @param str The Header string. |
duke@1 | 1554 | */ |
duke@1 | 1555 | public void printIndexHeading(String str) { |
duke@1 | 1556 | h2(); |
duke@1 | 1557 | print(str); |
duke@1 | 1558 | h2End(); |
duke@1 | 1559 | } |
duke@1 | 1560 | |
duke@1 | 1561 | /** |
duke@1 | 1562 | * Print Html tag <FRAMESET=arg>. |
duke@1 | 1563 | * |
duke@1 | 1564 | * @param arg Argument for the tag. |
duke@1 | 1565 | */ |
duke@1 | 1566 | public void frameSet(String arg) { |
duke@1 | 1567 | println("<FRAMESET " + arg + ">"); |
duke@1 | 1568 | } |
duke@1 | 1569 | |
duke@1 | 1570 | /** |
duke@1 | 1571 | * Print Html closing tag </FRAMESET>. |
duke@1 | 1572 | */ |
duke@1 | 1573 | public void frameSetEnd() { |
duke@1 | 1574 | println("</FRAMESET>"); |
duke@1 | 1575 | } |
duke@1 | 1576 | |
duke@1 | 1577 | /** |
duke@1 | 1578 | * Print Html tag <FRAME=arg>. |
duke@1 | 1579 | * |
duke@1 | 1580 | * @param arg Argument for the tag. |
duke@1 | 1581 | */ |
duke@1 | 1582 | public void frame(String arg) { |
duke@1 | 1583 | println("<FRAME " + arg + ">"); |
duke@1 | 1584 | } |
duke@1 | 1585 | |
duke@1 | 1586 | /** |
duke@1 | 1587 | * Print Html closing tag </FRAME>. |
duke@1 | 1588 | */ |
duke@1 | 1589 | public void frameEnd() { |
duke@1 | 1590 | println("</FRAME>"); |
duke@1 | 1591 | } |
duke@1 | 1592 | |
duke@1 | 1593 | /** |
duke@1 | 1594 | * Return path to the class page for a classdoc. For example, the class |
duke@1 | 1595 | * name is "java.lang.Object" and if the current file getting generated is |
duke@1 | 1596 | * "java/io/File.html", then the path string to the class, returned is |
duke@1 | 1597 | * "../../java/lang.Object.html". |
duke@1 | 1598 | * |
duke@1 | 1599 | * @param cd Class to which the path is requested. |
duke@1 | 1600 | */ |
duke@1 | 1601 | protected String pathToClass(ClassDoc cd) { |
duke@1 | 1602 | return pathString(cd.containingPackage(), cd.name() + ".html"); |
duke@1 | 1603 | } |
duke@1 | 1604 | |
duke@1 | 1605 | /** |
duke@1 | 1606 | * Return the path to the class page for a classdoc. Works same as |
duke@1 | 1607 | * {@link #pathToClass(ClassDoc)}. |
duke@1 | 1608 | * |
duke@1 | 1609 | * @param cd Class to which the path is requested. |
duke@1 | 1610 | * @param name Name of the file(doesn't include path). |
duke@1 | 1611 | */ |
duke@1 | 1612 | protected String pathString(ClassDoc cd, String name) { |
duke@1 | 1613 | return pathString(cd.containingPackage(), name); |
duke@1 | 1614 | } |
duke@1 | 1615 | |
duke@1 | 1616 | /** |
duke@1 | 1617 | * Return path to the given file name in the given package. So if the name |
duke@1 | 1618 | * passed is "Object.html" and the name of the package is "java.lang", and |
duke@1 | 1619 | * if the relative path is "../.." then returned string will be |
duke@1 | 1620 | * "../../java/lang/Object.html" |
duke@1 | 1621 | * |
duke@1 | 1622 | * @param pd Package in which the file name is assumed to be. |
duke@1 | 1623 | * @param name File name, to which path string is. |
duke@1 | 1624 | */ |
duke@1 | 1625 | protected String pathString(PackageDoc pd, String name) { |
duke@1 | 1626 | StringBuffer buf = new StringBuffer(relativePath); |
duke@1 | 1627 | buf.append(DirectoryManager.getPathToPackage(pd, name)); |
duke@1 | 1628 | return buf.toString(); |
duke@1 | 1629 | } |
duke@1 | 1630 | |
duke@1 | 1631 | /** |
duke@1 | 1632 | * Print the link to the given package. |
duke@1 | 1633 | * |
duke@1 | 1634 | * @param pkg the package to link to. |
duke@1 | 1635 | * @param label the label for the link. |
bpatel@182 | 1636 | * @param isStrong true if the label should be strong. |
duke@1 | 1637 | */ |
bpatel@182 | 1638 | public void printPackageLink(PackageDoc pkg, String label, boolean isStrong) { |
bpatel@766 | 1639 | print(getPackageLinkString(pkg, label, isStrong)); |
duke@1 | 1640 | } |
duke@1 | 1641 | |
duke@1 | 1642 | /** |
duke@1 | 1643 | * Print the link to the given package. |
duke@1 | 1644 | * |
duke@1 | 1645 | * @param pkg the package to link to. |
duke@1 | 1646 | * @param label the label for the link. |
bpatel@182 | 1647 | * @param isStrong true if the label should be strong. |
duke@1 | 1648 | * @param style the font of the package link label. |
duke@1 | 1649 | */ |
bpatel@182 | 1650 | public void printPackageLink(PackageDoc pkg, String label, boolean isStrong, |
duke@1 | 1651 | String style) { |
bpatel@766 | 1652 | print(getPackageLinkString(pkg, label, isStrong, style)); |
duke@1 | 1653 | } |
duke@1 | 1654 | |
duke@1 | 1655 | /** |
duke@1 | 1656 | * Return the link to the given package. |
duke@1 | 1657 | * |
duke@1 | 1658 | * @param pkg the package to link to. |
duke@1 | 1659 | * @param label the label for the link. |
bpatel@182 | 1660 | * @param isStrong true if the label should be strong. |
duke@1 | 1661 | * @return the link to the given package. |
duke@1 | 1662 | */ |
bpatel@766 | 1663 | public String getPackageLinkString(PackageDoc pkg, String label, |
bpatel@182 | 1664 | boolean isStrong) { |
bpatel@766 | 1665 | return getPackageLinkString(pkg, label, isStrong, ""); |
duke@1 | 1666 | } |
duke@1 | 1667 | |
duke@1 | 1668 | /** |
duke@1 | 1669 | * Return the link to the given package. |
duke@1 | 1670 | * |
duke@1 | 1671 | * @param pkg the package to link to. |
duke@1 | 1672 | * @param label the label for the link. |
bpatel@182 | 1673 | * @param isStrong true if the label should be strong. |
duke@1 | 1674 | * @param style the font of the package link label. |
duke@1 | 1675 | * @return the link to the given package. |
duke@1 | 1676 | */ |
bpatel@766 | 1677 | public String getPackageLinkString(PackageDoc pkg, String label, boolean isStrong, |
duke@1 | 1678 | String style) { |
duke@1 | 1679 | boolean included = pkg != null && pkg.isIncluded(); |
duke@1 | 1680 | if (! included) { |
duke@1 | 1681 | PackageDoc[] packages = configuration.packages; |
duke@1 | 1682 | for (int i = 0; i < packages.length; i++) { |
duke@1 | 1683 | if (packages[i].equals(pkg)) { |
duke@1 | 1684 | included = true; |
duke@1 | 1685 | break; |
duke@1 | 1686 | } |
duke@1 | 1687 | } |
duke@1 | 1688 | } |
duke@1 | 1689 | if (included || pkg == null) { |
bpatel@766 | 1690 | return getHyperLinkString(pathString(pkg, "package-summary.html"), |
bpatel@182 | 1691 | "", label, isStrong, style); |
duke@1 | 1692 | } else { |
duke@1 | 1693 | String crossPkgLink = getCrossPackageLink(Util.getPackageName(pkg)); |
duke@1 | 1694 | if (crossPkgLink != null) { |
bpatel@766 | 1695 | return getHyperLinkString(crossPkgLink, "", label, isStrong, style); |
bpatel@766 | 1696 | } else { |
bpatel@766 | 1697 | return label; |
bpatel@766 | 1698 | } |
bpatel@766 | 1699 | } |
bpatel@766 | 1700 | } |
bpatel@766 | 1701 | |
bpatel@766 | 1702 | /** |
bpatel@766 | 1703 | * Return the link to the given package. |
bpatel@766 | 1704 | * |
bpatel@766 | 1705 | * @param pkg the package to link to. |
bpatel@766 | 1706 | * @param label the label for the link. |
bpatel@766 | 1707 | * @return a content tree for the package link. |
bpatel@766 | 1708 | */ |
bpatel@766 | 1709 | public Content getPackageLink(PackageDoc pkg, Content label) { |
bpatel@766 | 1710 | boolean included = pkg != null && pkg.isIncluded(); |
bpatel@766 | 1711 | if (! included) { |
bpatel@766 | 1712 | PackageDoc[] packages = configuration.packages; |
bpatel@766 | 1713 | for (int i = 0; i < packages.length; i++) { |
bpatel@766 | 1714 | if (packages[i].equals(pkg)) { |
bpatel@766 | 1715 | included = true; |
bpatel@766 | 1716 | break; |
bpatel@766 | 1717 | } |
bpatel@766 | 1718 | } |
bpatel@766 | 1719 | } |
bpatel@766 | 1720 | if (included || pkg == null) { |
bpatel@766 | 1721 | return getHyperLink(pathString(pkg, "package-summary.html"), |
bpatel@766 | 1722 | "", label); |
bpatel@766 | 1723 | } else { |
bpatel@766 | 1724 | String crossPkgLink = getCrossPackageLink(Util.getPackageName(pkg)); |
bpatel@766 | 1725 | if (crossPkgLink != null) { |
bpatel@766 | 1726 | return getHyperLink(crossPkgLink, "", label); |
duke@1 | 1727 | } else { |
duke@1 | 1728 | return label; |
duke@1 | 1729 | } |
duke@1 | 1730 | } |
duke@1 | 1731 | } |
duke@1 | 1732 | |
duke@1 | 1733 | public String italicsClassName(ClassDoc cd, boolean qual) { |
duke@1 | 1734 | String name = (qual)? cd.qualifiedName(): cd.name(); |
duke@1 | 1735 | return (cd.isInterface())? italicsText(name): name; |
duke@1 | 1736 | } |
duke@1 | 1737 | |
duke@1 | 1738 | public void printSrcLink(ProgramElementDoc d, String label) { |
duke@1 | 1739 | if (d == null) { |
duke@1 | 1740 | return; |
duke@1 | 1741 | } |
duke@1 | 1742 | ClassDoc cd = d.containingClass(); |
duke@1 | 1743 | if (cd == null) { |
duke@1 | 1744 | //d must be a class doc since in has no containing class. |
duke@1 | 1745 | cd = (ClassDoc) d; |
duke@1 | 1746 | } |
duke@1 | 1747 | String href = relativePath + DocletConstants.SOURCE_OUTPUT_DIR_NAME |
duke@1 | 1748 | + DirectoryManager.getDirectoryPath(cd.containingPackage()) |
duke@1 | 1749 | + cd.name() + ".html#" + SourceToHTMLConverter.getAnchorName(d); |
duke@1 | 1750 | printHyperLink(href, "", label, true); |
duke@1 | 1751 | } |
duke@1 | 1752 | |
duke@1 | 1753 | /** |
bpatel@766 | 1754 | * Add the link to the content tree. |
bpatel@766 | 1755 | * |
bpatel@766 | 1756 | * @param doc program element doc for which the link will be added |
bpatel@766 | 1757 | * @param label label for the link |
bpatel@766 | 1758 | * @param htmltree the content tree to which the link will be added |
bpatel@766 | 1759 | */ |
bpatel@766 | 1760 | public void addSrcLink(ProgramElementDoc doc, Content label, Content htmltree) { |
bpatel@766 | 1761 | if (doc == null) { |
bpatel@766 | 1762 | return; |
bpatel@766 | 1763 | } |
bpatel@766 | 1764 | ClassDoc cd = doc.containingClass(); |
bpatel@766 | 1765 | if (cd == null) { |
bpatel@766 | 1766 | //d must be a class doc since in has no containing class. |
bpatel@766 | 1767 | cd = (ClassDoc) doc; |
bpatel@766 | 1768 | } |
bpatel@766 | 1769 | String href = relativePath + DocletConstants.SOURCE_OUTPUT_DIR_NAME |
bpatel@766 | 1770 | + DirectoryManager.getDirectoryPath(cd.containingPackage()) |
bpatel@766 | 1771 | + cd.name() + ".html#" + SourceToHTMLConverter.getAnchorName(doc); |
bpatel@766 | 1772 | Content linkContent = getHyperLink(href, "", label, "", ""); |
bpatel@766 | 1773 | htmltree.addContent(linkContent); |
bpatel@766 | 1774 | } |
bpatel@766 | 1775 | |
bpatel@766 | 1776 | /** |
duke@1 | 1777 | * Return the link to the given class. |
duke@1 | 1778 | * |
duke@1 | 1779 | * @param linkInfo the information about the link. |
duke@1 | 1780 | * |
duke@1 | 1781 | * @return the link for the given class. |
duke@1 | 1782 | */ |
duke@1 | 1783 | public String getLink(LinkInfoImpl linkInfo) { |
duke@1 | 1784 | LinkFactoryImpl factory = new LinkFactoryImpl(this); |
duke@1 | 1785 | String link = ((LinkOutputImpl) factory.getLinkOutput(linkInfo)).toString(); |
duke@1 | 1786 | displayLength += linkInfo.displayLength; |
duke@1 | 1787 | return link; |
duke@1 | 1788 | } |
duke@1 | 1789 | |
duke@1 | 1790 | /** |
duke@1 | 1791 | * Return the type parameters for the given class. |
duke@1 | 1792 | * |
duke@1 | 1793 | * @param linkInfo the information about the link. |
duke@1 | 1794 | * @return the type for the given class. |
duke@1 | 1795 | */ |
duke@1 | 1796 | public String getTypeParameterLinks(LinkInfoImpl linkInfo) { |
duke@1 | 1797 | LinkFactoryImpl factory = new LinkFactoryImpl(this); |
duke@1 | 1798 | return ((LinkOutputImpl) |
duke@1 | 1799 | factory.getTypeParameterLinks(linkInfo, false)).toString(); |
duke@1 | 1800 | } |
duke@1 | 1801 | |
duke@1 | 1802 | /** |
duke@1 | 1803 | * Print the link to the given class. |
duke@1 | 1804 | */ |
duke@1 | 1805 | public void printLink(LinkInfoImpl linkInfo) { |
duke@1 | 1806 | print(getLink(linkInfo)); |
duke@1 | 1807 | } |
duke@1 | 1808 | |
duke@1 | 1809 | /************************************************************* |
duke@1 | 1810 | * Return a class cross link to external class documentation. |
duke@1 | 1811 | * The name must be fully qualified to determine which package |
duke@1 | 1812 | * the class is in. The -link option does not allow users to |
duke@1 | 1813 | * link to external classes in the "default" package. |
duke@1 | 1814 | * |
duke@1 | 1815 | * @param qualifiedClassName the qualified name of the external class. |
duke@1 | 1816 | * @param refMemName the name of the member being referenced. This should |
duke@1 | 1817 | * be null or empty string if no member is being referenced. |
duke@1 | 1818 | * @param label the label for the external link. |
bpatel@182 | 1819 | * @param strong true if the link should be strong. |
duke@1 | 1820 | * @param style the style of the link. |
duke@1 | 1821 | * @param code true if the label should be code font. |
duke@1 | 1822 | */ |
duke@1 | 1823 | public String getCrossClassLink(String qualifiedClassName, String refMemName, |
bpatel@182 | 1824 | String label, boolean strong, String style, |
duke@1 | 1825 | boolean code) { |
duke@1 | 1826 | String className = "", |
duke@1 | 1827 | packageName = qualifiedClassName == null ? "" : qualifiedClassName; |
duke@1 | 1828 | int periodIndex; |
duke@1 | 1829 | while((periodIndex = packageName.lastIndexOf('.')) != -1) { |
duke@1 | 1830 | className = packageName.substring(periodIndex + 1, packageName.length()) + |
duke@1 | 1831 | (className.length() > 0 ? "." + className : ""); |
duke@1 | 1832 | String defaultLabel = code ? getCode() + className + getCodeEnd() : className; |
duke@1 | 1833 | packageName = packageName.substring(0, periodIndex); |
duke@1 | 1834 | if (getCrossPackageLink(packageName) != null) { |
duke@1 | 1835 | //The package exists in external documentation, so link to the external |
duke@1 | 1836 | //class (assuming that it exists). This is definitely a limitation of |
duke@1 | 1837 | //the -link option. There are ways to determine if an external package |
duke@1 | 1838 | //exists, but no way to determine if the external class exists. We just |
duke@1 | 1839 | //have to assume that it does. |
bpatel@766 | 1840 | return getHyperLinkString( |
duke@1 | 1841 | configuration.extern.getExternalLink(packageName, relativePath, |
duke@1 | 1842 | className + ".html?is-external=true"), |
duke@1 | 1843 | refMemName == null ? "" : refMemName, |
duke@1 | 1844 | label == null || label.length() == 0 ? defaultLabel : label, |
bpatel@182 | 1845 | strong, style, |
duke@1 | 1846 | configuration.getText("doclet.Href_Class_Or_Interface_Title", packageName), |
duke@1 | 1847 | ""); |
duke@1 | 1848 | } |
duke@1 | 1849 | } |
duke@1 | 1850 | return null; |
duke@1 | 1851 | } |
duke@1 | 1852 | |
duke@1 | 1853 | public boolean isClassLinkable(ClassDoc cd) { |
duke@1 | 1854 | if (cd.isIncluded()) { |
duke@1 | 1855 | return configuration.isGeneratedDoc(cd); |
duke@1 | 1856 | } |
duke@1 | 1857 | return configuration.extern.isExternal(cd); |
duke@1 | 1858 | } |
duke@1 | 1859 | |
duke@1 | 1860 | public String getCrossPackageLink(String pkgName) { |
duke@1 | 1861 | return configuration.extern.getExternalLink(pkgName, relativePath, |
duke@1 | 1862 | "package-summary.html?is-external=true"); |
duke@1 | 1863 | } |
duke@1 | 1864 | |
bpatel@766 | 1865 | /** |
bpatel@766 | 1866 | * Get the class link. |
bpatel@766 | 1867 | * |
bpatel@766 | 1868 | * @param context the id of the context where the link will be added |
bpatel@766 | 1869 | * @param cd the class doc to link to |
bpatel@766 | 1870 | * @return a content tree for the link |
bpatel@766 | 1871 | */ |
bpatel@766 | 1872 | public Content getQualifiedClassLink(int context, ClassDoc cd) { |
bpatel@766 | 1873 | return new RawHtml(getLink(new LinkInfoImpl(context, cd, |
bpatel@766 | 1874 | configuration.getClassName(cd), ""))); |
duke@1 | 1875 | } |
duke@1 | 1876 | |
duke@1 | 1877 | /** |
bpatel@766 | 1878 | * Add the class link. |
bpatel@766 | 1879 | * |
bpatel@766 | 1880 | * @param context the id of the context where the link will be added |
bpatel@766 | 1881 | * @param cd the class doc to link to |
bpatel@766 | 1882 | * @param contentTree the content tree to which the link will be added |
duke@1 | 1883 | */ |
bpatel@766 | 1884 | public void addPreQualifiedClassLink(int context, ClassDoc cd, Content contentTree) { |
bpatel@766 | 1885 | addPreQualifiedClassLink(context, cd, false, contentTree); |
duke@1 | 1886 | } |
duke@1 | 1887 | |
duke@1 | 1888 | /** |
duke@1 | 1889 | * Retrieve the class link with the package portion of the label in |
duke@1 | 1890 | * plain text. If the qualifier is excluded, it willnot be included in the |
duke@1 | 1891 | * link label. |
duke@1 | 1892 | * |
duke@1 | 1893 | * @param cd the class to link to. |
bpatel@182 | 1894 | * @param isStrong true if the link should be strong. |
duke@1 | 1895 | * @return the link with the package portion of the label in plain text. |
duke@1 | 1896 | */ |
duke@1 | 1897 | public String getPreQualifiedClassLink(int context, |
bpatel@182 | 1898 | ClassDoc cd, boolean isStrong) { |
duke@1 | 1899 | String classlink = ""; |
duke@1 | 1900 | PackageDoc pd = cd.containingPackage(); |
duke@1 | 1901 | if(pd != null && ! configuration.shouldExcludeQualifier(pd.name())) { |
duke@1 | 1902 | classlink = getPkgName(cd); |
duke@1 | 1903 | } |
bpatel@182 | 1904 | classlink += getLink(new LinkInfoImpl(context, cd, cd.name(), isStrong)); |
duke@1 | 1905 | return classlink; |
duke@1 | 1906 | } |
duke@1 | 1907 | |
bpatel@766 | 1908 | /** |
bpatel@766 | 1909 | * Add the class link with the package portion of the label in |
bpatel@766 | 1910 | * plain text. If the qualifier is excluded, it will not be included in the |
bpatel@766 | 1911 | * link label. |
bpatel@766 | 1912 | * |
bpatel@766 | 1913 | * @param context the id of the context where the link will be added |
bpatel@766 | 1914 | * @param cd the class to link to |
bpatel@766 | 1915 | * @param isStrong true if the link should be strong |
bpatel@766 | 1916 | * @param contentTree the content tree to which the link with be added |
bpatel@766 | 1917 | */ |
bpatel@766 | 1918 | public void addPreQualifiedClassLink(int context, |
bpatel@766 | 1919 | ClassDoc cd, boolean isStrong, Content contentTree) { |
bpatel@766 | 1920 | PackageDoc pd = cd.containingPackage(); |
bpatel@766 | 1921 | if(pd != null && ! configuration.shouldExcludeQualifier(pd.name())) { |
bpatel@766 | 1922 | contentTree.addContent(getPkgName(cd)); |
bpatel@766 | 1923 | } |
bpatel@766 | 1924 | contentTree.addContent(new RawHtml(getLink(new LinkInfoImpl( |
bpatel@766 | 1925 | context, cd, cd.name(), isStrong)))); |
bpatel@766 | 1926 | } |
duke@1 | 1927 | |
duke@1 | 1928 | /** |
bpatel@766 | 1929 | * Add the class link, with only class name as the strong link and prefixing |
duke@1 | 1930 | * plain package name. |
bpatel@766 | 1931 | * |
bpatel@766 | 1932 | * @param context the id of the context where the link will be added |
bpatel@766 | 1933 | * @param cd the class to link to |
bpatel@766 | 1934 | * @param contentTree the content tree to which the link with be added |
duke@1 | 1935 | */ |
bpatel@766 | 1936 | public void addPreQualifiedStrongClassLink(int context, ClassDoc cd, Content contentTree) { |
bpatel@766 | 1937 | addPreQualifiedClassLink(context, cd, true, contentTree); |
duke@1 | 1938 | } |
duke@1 | 1939 | |
duke@1 | 1940 | public void printText(String key) { |
duke@1 | 1941 | print(configuration.getText(key)); |
duke@1 | 1942 | } |
duke@1 | 1943 | |
duke@1 | 1944 | public void printText(String key, String a1) { |
duke@1 | 1945 | print(configuration.getText(key, a1)); |
duke@1 | 1946 | } |
duke@1 | 1947 | |
duke@1 | 1948 | public void printText(String key, String a1, String a2) { |
duke@1 | 1949 | print(configuration.getText(key, a1, a2)); |
duke@1 | 1950 | } |
duke@1 | 1951 | |
bpatel@182 | 1952 | public void strongText(String key) { |
bpatel@182 | 1953 | strong(configuration.getText(key)); |
duke@1 | 1954 | } |
duke@1 | 1955 | |
bpatel@182 | 1956 | public void strongText(String key, String a1) { |
bpatel@182 | 1957 | strong(configuration.getText(key, a1)); |
duke@1 | 1958 | } |
duke@1 | 1959 | |
bpatel@182 | 1960 | public void strongText(String key, String a1, String a2) { |
bpatel@182 | 1961 | strong(configuration.getText(key, a1, a2)); |
duke@1 | 1962 | } |
duke@1 | 1963 | |
duke@1 | 1964 | /** |
bpatel@766 | 1965 | * Get the link for the given member. |
duke@1 | 1966 | * |
bpatel@766 | 1967 | * @param context the id of the context where the link will be added |
bpatel@766 | 1968 | * @param doc the member being linked to |
bpatel@766 | 1969 | * @param label the label for the link |
bpatel@766 | 1970 | * @return a content tree for the doc link |
duke@1 | 1971 | */ |
bpatel@766 | 1972 | public Content getDocLink(int context, MemberDoc doc, String label) { |
bpatel@766 | 1973 | return getDocLink(context, doc.containingClass(), doc, label); |
duke@1 | 1974 | } |
duke@1 | 1975 | |
duke@1 | 1976 | /** |
duke@1 | 1977 | * Print the link for the given member. |
duke@1 | 1978 | * |
duke@1 | 1979 | * @param context the id of the context where the link will be printed. |
duke@1 | 1980 | * @param classDoc the classDoc that we should link to. This is not |
duke@1 | 1981 | * necessarily equal to doc.containingClass(). We may be |
duke@1 | 1982 | * inheriting comments. |
duke@1 | 1983 | * @param doc the member being linked to. |
duke@1 | 1984 | * @param label the label for the link. |
bpatel@182 | 1985 | * @param strong true if the link should be strong. |
duke@1 | 1986 | */ |
duke@1 | 1987 | public void printDocLink(int context, ClassDoc classDoc, MemberDoc doc, |
bpatel@182 | 1988 | String label, boolean strong) { |
bpatel@182 | 1989 | print(getDocLink(context, classDoc, doc, label, strong)); |
duke@1 | 1990 | } |
duke@1 | 1991 | |
duke@1 | 1992 | /** |
duke@1 | 1993 | * Return the link for the given member. |
duke@1 | 1994 | * |
duke@1 | 1995 | * @param context the id of the context where the link will be printed. |
duke@1 | 1996 | * @param doc the member being linked to. |
duke@1 | 1997 | * @param label the label for the link. |
bpatel@182 | 1998 | * @param strong true if the link should be strong. |
duke@1 | 1999 | * @return the link for the given member. |
duke@1 | 2000 | */ |
duke@1 | 2001 | public String getDocLink(int context, MemberDoc doc, String label, |
bpatel@182 | 2002 | boolean strong) { |
bpatel@182 | 2003 | return getDocLink(context, doc.containingClass(), doc, label, strong); |
duke@1 | 2004 | } |
duke@1 | 2005 | |
duke@1 | 2006 | /** |
duke@1 | 2007 | * Return the link for the given member. |
duke@1 | 2008 | * |
duke@1 | 2009 | * @param context the id of the context where the link will be printed. |
duke@1 | 2010 | * @param classDoc the classDoc that we should link to. This is not |
duke@1 | 2011 | * necessarily equal to doc.containingClass(). We may be |
duke@1 | 2012 | * inheriting comments. |
duke@1 | 2013 | * @param doc the member being linked to. |
duke@1 | 2014 | * @param label the label for the link. |
bpatel@182 | 2015 | * @param strong true if the link should be strong. |
duke@1 | 2016 | * @return the link for the given member. |
duke@1 | 2017 | */ |
duke@1 | 2018 | public String getDocLink(int context, ClassDoc classDoc, MemberDoc doc, |
bpatel@182 | 2019 | String label, boolean strong) { |
duke@1 | 2020 | if (! (doc.isIncluded() || |
duke@1 | 2021 | Util.isLinkable(classDoc, configuration()))) { |
duke@1 | 2022 | return label; |
duke@1 | 2023 | } else if (doc instanceof ExecutableMemberDoc) { |
duke@1 | 2024 | ExecutableMemberDoc emd = (ExecutableMemberDoc)doc; |
duke@1 | 2025 | return getLink(new LinkInfoImpl(context, classDoc, |
bpatel@182 | 2026 | getAnchor(emd), label, strong)); |
duke@1 | 2027 | } else if (doc instanceof MemberDoc) { |
duke@1 | 2028 | return getLink(new LinkInfoImpl(context, classDoc, |
bpatel@182 | 2029 | doc.name(), label, strong)); |
duke@1 | 2030 | } else { |
duke@1 | 2031 | return label; |
duke@1 | 2032 | } |
duke@1 | 2033 | } |
duke@1 | 2034 | |
bpatel@766 | 2035 | /** |
bpatel@766 | 2036 | * Return the link for the given member. |
bpatel@766 | 2037 | * |
bpatel@766 | 2038 | * @param context the id of the context where the link will be added |
bpatel@766 | 2039 | * @param classDoc the classDoc that we should link to. This is not |
bpatel@766 | 2040 | * necessarily equal to doc.containingClass(). We may be |
bpatel@766 | 2041 | * inheriting comments |
bpatel@766 | 2042 | * @param doc the member being linked to |
bpatel@766 | 2043 | * @param label the label for the link |
bpatel@766 | 2044 | * @return the link for the given member |
bpatel@766 | 2045 | */ |
bpatel@766 | 2046 | public Content getDocLink(int context, ClassDoc classDoc, MemberDoc doc, |
bpatel@766 | 2047 | String label) { |
bpatel@766 | 2048 | if (! (doc.isIncluded() || |
bpatel@766 | 2049 | Util.isLinkable(classDoc, configuration()))) { |
bpatel@766 | 2050 | return new StringContent(label); |
bpatel@766 | 2051 | } else if (doc instanceof ExecutableMemberDoc) { |
bpatel@766 | 2052 | ExecutableMemberDoc emd = (ExecutableMemberDoc)doc; |
bpatel@766 | 2053 | return new RawHtml(getLink(new LinkInfoImpl(context, classDoc, |
bpatel@766 | 2054 | getAnchor(emd), label, false))); |
bpatel@766 | 2055 | } else if (doc instanceof MemberDoc) { |
bpatel@766 | 2056 | return new RawHtml(getLink(new LinkInfoImpl(context, classDoc, |
bpatel@766 | 2057 | doc.name(), label, false))); |
bpatel@766 | 2058 | } else { |
bpatel@766 | 2059 | return new StringContent(label); |
bpatel@766 | 2060 | } |
bpatel@766 | 2061 | } |
bpatel@766 | 2062 | |
duke@1 | 2063 | public void anchor(ExecutableMemberDoc emd) { |
duke@1 | 2064 | anchor(getAnchor(emd)); |
duke@1 | 2065 | } |
duke@1 | 2066 | |
duke@1 | 2067 | public String getAnchor(ExecutableMemberDoc emd) { |
duke@1 | 2068 | StringBuilder signature = new StringBuilder(emd.signature()); |
duke@1 | 2069 | StringBuilder signatureParsed = new StringBuilder(); |
duke@1 | 2070 | int counter = 0; |
duke@1 | 2071 | for (int i = 0; i < signature.length(); i++) { |
duke@1 | 2072 | char c = signature.charAt(i); |
duke@1 | 2073 | if (c == '<') { |
duke@1 | 2074 | counter++; |
duke@1 | 2075 | } else if (c == '>') { |
duke@1 | 2076 | counter--; |
duke@1 | 2077 | } else if (counter == 0) { |
duke@1 | 2078 | signatureParsed.append(c); |
duke@1 | 2079 | } |
duke@1 | 2080 | } |
duke@1 | 2081 | return emd.name() + signatureParsed.toString(); |
duke@1 | 2082 | } |
duke@1 | 2083 | |
duke@1 | 2084 | public String seeTagToString(SeeTag see) { |
duke@1 | 2085 | String tagName = see.name(); |
duke@1 | 2086 | if (! (tagName.startsWith("@link") || tagName.equals("@see"))) { |
duke@1 | 2087 | return ""; |
duke@1 | 2088 | } |
duke@1 | 2089 | StringBuffer result = new StringBuffer(); |
duke@1 | 2090 | boolean isplaintext = tagName.toLowerCase().equals("@linkplain"); |
duke@1 | 2091 | String label = see.label(); |
duke@1 | 2092 | label = (label.length() > 0)? |
duke@1 | 2093 | ((isplaintext) ? label : |
duke@1 | 2094 | getCode() + label + getCodeEnd()):""; |
duke@1 | 2095 | String seetext = replaceDocRootDir(see.text()); |
duke@1 | 2096 | |
duke@1 | 2097 | //Check if @see is an href or "string" |
duke@1 | 2098 | if (seetext.startsWith("<") || seetext.startsWith("\"")) { |
duke@1 | 2099 | result.append(seetext); |
duke@1 | 2100 | return result.toString(); |
duke@1 | 2101 | } |
duke@1 | 2102 | |
duke@1 | 2103 | //The text from the @see tag. We will output this text when a label is not specified. |
duke@1 | 2104 | String text = (isplaintext) ? seetext : getCode() + seetext + getCodeEnd(); |
duke@1 | 2105 | |
duke@1 | 2106 | ClassDoc refClass = see.referencedClass(); |
duke@1 | 2107 | String refClassName = see.referencedClassName(); |
duke@1 | 2108 | MemberDoc refMem = see.referencedMember(); |
duke@1 | 2109 | String refMemName = see.referencedMemberName(); |
duke@1 | 2110 | if (refClass == null) { |
duke@1 | 2111 | //@see is not referencing an included class |
duke@1 | 2112 | PackageDoc refPackage = see.referencedPackage(); |
duke@1 | 2113 | if (refPackage != null && refPackage.isIncluded()) { |
duke@1 | 2114 | //@see is referencing an included package |
duke@1 | 2115 | String packageName = isplaintext ? refPackage.name() : |
duke@1 | 2116 | getCode() + refPackage.name() + getCodeEnd(); |
bpatel@766 | 2117 | result.append(getPackageLinkString(refPackage, |
duke@1 | 2118 | label.length() == 0 ? packageName : label, false)); |
duke@1 | 2119 | } else { |
duke@1 | 2120 | //@see is not referencing an included class or package. Check for cross links. |
duke@1 | 2121 | String classCrossLink, packageCrossLink = getCrossPackageLink(refClassName); |
duke@1 | 2122 | if (packageCrossLink != null) { |
duke@1 | 2123 | //Package cross link found |
bpatel@766 | 2124 | result.append(getHyperLinkString(packageCrossLink, "", |
duke@1 | 2125 | (label.length() == 0)? text : label, false)); |
duke@1 | 2126 | } else if ((classCrossLink = getCrossClassLink(refClassName, |
duke@1 | 2127 | refMemName, label, false, "", ! isplaintext)) != null) { |
duke@1 | 2128 | //Class cross link found (possiblly to a member in the class) |
duke@1 | 2129 | result.append(classCrossLink); |
duke@1 | 2130 | } else { |
duke@1 | 2131 | //No cross link found so print warning |
duke@1 | 2132 | configuration.getDocletSpecificMsg().warning(see.position(), "doclet.see.class_or_package_not_found", |
duke@1 | 2133 | tagName, seetext); |
duke@1 | 2134 | result.append((label.length() == 0)? text: label); |
duke@1 | 2135 | } |
duke@1 | 2136 | } |
duke@1 | 2137 | } else if (refMemName == null) { |
duke@1 | 2138 | // Must be a class reference since refClass is not null and refMemName is null. |
duke@1 | 2139 | if (label.length() == 0) { |
duke@1 | 2140 | label = (isplaintext) ? refClass.name() : getCode() + refClass.name() + getCodeEnd(); |
duke@1 | 2141 | result.append(getLink(new LinkInfoImpl(refClass, label))); |
duke@1 | 2142 | } else { |
duke@1 | 2143 | result.append(getLink(new LinkInfoImpl(refClass, label))); |
duke@1 | 2144 | } |
duke@1 | 2145 | } else if (refMem == null) { |
duke@1 | 2146 | // Must be a member reference since refClass is not null and refMemName is not null. |
duke@1 | 2147 | // However, refMem is null, so this referenced member does not exist. |
duke@1 | 2148 | result.append((label.length() == 0)? text: label); |
duke@1 | 2149 | } else { |
duke@1 | 2150 | // Must be a member reference since refClass is not null and refMemName is not null. |
duke@1 | 2151 | // refMem is not null, so this @see tag must be referencing a valid member. |
duke@1 | 2152 | ClassDoc containing = refMem.containingClass(); |
duke@1 | 2153 | if (see.text().trim().startsWith("#") && |
duke@1 | 2154 | ! (containing.isPublic() || |
duke@1 | 2155 | Util.isLinkable(containing, configuration()))) { |
duke@1 | 2156 | // Since the link is relative and the holder is not even being |
duke@1 | 2157 | // documented, this must be an inherited link. Redirect it. |
duke@1 | 2158 | // The current class either overrides the referenced member or |
duke@1 | 2159 | // inherits it automatically. |
jjg@405 | 2160 | if (this instanceof ClassWriterImpl) { |
jjg@405 | 2161 | containing = ((ClassWriterImpl) this).getClassDoc(); |
jjg@405 | 2162 | } else if (!containing.isPublic()){ |
jjg@405 | 2163 | configuration.getDocletSpecificMsg().warning( |
jjg@405 | 2164 | see.position(), "doclet.see.class_or_package_not_accessible", |
jjg@405 | 2165 | tagName, containing.qualifiedName()); |
jjg@405 | 2166 | } else { |
jjg@405 | 2167 | configuration.getDocletSpecificMsg().warning( |
jjg@405 | 2168 | see.position(), "doclet.see.class_or_package_not_found", |
jjg@405 | 2169 | tagName, seetext); |
jjg@405 | 2170 | } |
duke@1 | 2171 | } |
duke@1 | 2172 | if (configuration.currentcd != containing) { |
duke@1 | 2173 | refMemName = containing.name() + "." + refMemName; |
duke@1 | 2174 | } |
duke@1 | 2175 | if (refMem instanceof ExecutableMemberDoc) { |
duke@1 | 2176 | if (refMemName.indexOf('(') < 0) { |
duke@1 | 2177 | refMemName += ((ExecutableMemberDoc)refMem).signature(); |
duke@1 | 2178 | } |
duke@1 | 2179 | } |
duke@1 | 2180 | text = (isplaintext) ? |
bpatel@981 | 2181 | refMemName : getCode() + Util.escapeHtmlChars(refMemName) + getCodeEnd(); |
duke@1 | 2182 | |
duke@1 | 2183 | result.append(getDocLink(LinkInfoImpl.CONTEXT_SEE_TAG, containing, |
duke@1 | 2184 | refMem, (label.length() == 0)? text: label, false)); |
duke@1 | 2185 | } |
duke@1 | 2186 | return result.toString(); |
duke@1 | 2187 | } |
duke@1 | 2188 | |
duke@1 | 2189 | public void printInlineComment(Doc doc, Tag tag) { |
duke@1 | 2190 | printCommentTags(doc, tag.inlineTags(), false, false); |
duke@1 | 2191 | } |
duke@1 | 2192 | |
bpatel@766 | 2193 | /** |
bpatel@766 | 2194 | * Add the inline comment. |
bpatel@766 | 2195 | * |
bpatel@766 | 2196 | * @param doc the doc for which the inline comment will be added |
bpatel@766 | 2197 | * @param tag the inline tag to be added |
bpatel@766 | 2198 | * @param htmltree the content tree to which the comment will be added |
bpatel@766 | 2199 | */ |
bpatel@766 | 2200 | public void addInlineComment(Doc doc, Tag tag, Content htmltree) { |
bpatel@766 | 2201 | addCommentTags(doc, tag.inlineTags(), false, false, htmltree); |
bpatel@766 | 2202 | } |
bpatel@766 | 2203 | |
duke@1 | 2204 | public void printInlineDeprecatedComment(Doc doc, Tag tag) { |
duke@1 | 2205 | printCommentTags(doc, tag.inlineTags(), true, false); |
duke@1 | 2206 | } |
duke@1 | 2207 | |
bpatel@766 | 2208 | /** |
bpatel@766 | 2209 | * Add the inline deprecated comment. |
bpatel@766 | 2210 | * |
bpatel@766 | 2211 | * @param doc the doc for which the inline deprecated comment will be added |
bpatel@766 | 2212 | * @param tag the inline tag to be added |
bpatel@766 | 2213 | * @param htmltree the content tree to which the comment will be added |
bpatel@766 | 2214 | */ |
bpatel@766 | 2215 | public void addInlineDeprecatedComment(Doc doc, Tag tag, Content htmltree) { |
bpatel@766 | 2216 | addCommentTags(doc, tag.inlineTags(), true, false, htmltree); |
bpatel@766 | 2217 | } |
bpatel@766 | 2218 | |
duke@1 | 2219 | public void printSummaryComment(Doc doc) { |
duke@1 | 2220 | printSummaryComment(doc, doc.firstSentenceTags()); |
duke@1 | 2221 | } |
duke@1 | 2222 | |
bpatel@766 | 2223 | /** |
bpatel@766 | 2224 | * Adds the summary content. |
bpatel@766 | 2225 | * |
bpatel@766 | 2226 | * @param doc the doc for which the summary will be generated |
bpatel@766 | 2227 | * @param htmltree the documentation tree to which the summary will be added |
bpatel@766 | 2228 | */ |
bpatel@766 | 2229 | public void addSummaryComment(Doc doc, Content htmltree) { |
bpatel@766 | 2230 | addSummaryComment(doc, doc.firstSentenceTags(), htmltree); |
bpatel@766 | 2231 | } |
bpatel@766 | 2232 | |
duke@1 | 2233 | public void printSummaryComment(Doc doc, Tag[] firstSentenceTags) { |
duke@1 | 2234 | printCommentTags(doc, firstSentenceTags, false, true); |
duke@1 | 2235 | } |
duke@1 | 2236 | |
bpatel@766 | 2237 | /** |
bpatel@766 | 2238 | * Adds the summary content. |
bpatel@766 | 2239 | * |
bpatel@766 | 2240 | * @param doc the doc for which the summary will be generated |
bpatel@766 | 2241 | * @param firstSentenceTags the first sentence tags for the doc |
bpatel@766 | 2242 | * @param htmltree the documentation tree to which the summary will be added |
bpatel@766 | 2243 | */ |
bpatel@766 | 2244 | public void addSummaryComment(Doc doc, Tag[] firstSentenceTags, Content htmltree) { |
bpatel@766 | 2245 | addCommentTags(doc, firstSentenceTags, false, true, htmltree); |
bpatel@766 | 2246 | } |
bpatel@766 | 2247 | |
duke@1 | 2248 | public void printSummaryDeprecatedComment(Doc doc) { |
duke@1 | 2249 | printCommentTags(doc, doc.firstSentenceTags(), true, true); |
duke@1 | 2250 | } |
duke@1 | 2251 | |
duke@1 | 2252 | public void printSummaryDeprecatedComment(Doc doc, Tag tag) { |
duke@1 | 2253 | printCommentTags(doc, tag.firstSentenceTags(), true, true); |
duke@1 | 2254 | } |
duke@1 | 2255 | |
bpatel@766 | 2256 | public void addSummaryDeprecatedComment(Doc doc, Tag tag, Content htmltree) { |
bpatel@766 | 2257 | addCommentTags(doc, tag.firstSentenceTags(), true, true, htmltree); |
bpatel@766 | 2258 | } |
bpatel@766 | 2259 | |
duke@1 | 2260 | public void printInlineComment(Doc doc) { |
duke@1 | 2261 | printCommentTags(doc, doc.inlineTags(), false, false); |
duke@1 | 2262 | p(); |
duke@1 | 2263 | } |
duke@1 | 2264 | |
bpatel@766 | 2265 | /** |
bpatel@766 | 2266 | * Adds the inline comment. |
bpatel@766 | 2267 | * |
bpatel@766 | 2268 | * @param doc the doc for which the inline comments will be generated |
bpatel@766 | 2269 | * @param htmltree the documentation tree to which the inline comments will be added |
bpatel@766 | 2270 | */ |
bpatel@766 | 2271 | public void addInlineComment(Doc doc, Content htmltree) { |
bpatel@766 | 2272 | addCommentTags(doc, doc.inlineTags(), false, false, htmltree); |
bpatel@766 | 2273 | } |
bpatel@766 | 2274 | |
duke@1 | 2275 | public void printInlineDeprecatedComment(Doc doc) { |
duke@1 | 2276 | printCommentTags(doc, doc.inlineTags(), true, false); |
duke@1 | 2277 | } |
duke@1 | 2278 | |
duke@1 | 2279 | private void printCommentTags(Doc doc, Tag[] tags, boolean depr, boolean first) { |
duke@1 | 2280 | if(configuration.nocomment){ |
duke@1 | 2281 | return; |
duke@1 | 2282 | } |
duke@1 | 2283 | if (depr) { |
duke@1 | 2284 | italic(); |
duke@1 | 2285 | } |
duke@1 | 2286 | String result = commentTagsToString(null, doc, tags, first); |
duke@1 | 2287 | print(result); |
duke@1 | 2288 | if (depr) { |
duke@1 | 2289 | italicEnd(); |
duke@1 | 2290 | } |
duke@1 | 2291 | if (tags.length == 0) { |
duke@1 | 2292 | space(); |
duke@1 | 2293 | } |
duke@1 | 2294 | } |
duke@1 | 2295 | |
duke@1 | 2296 | /** |
bpatel@766 | 2297 | * Adds the comment tags. |
bpatel@766 | 2298 | * |
bpatel@766 | 2299 | * @param doc the doc for which the comment tags will be generated |
bpatel@766 | 2300 | * @param tags the first sentence tags for the doc |
bpatel@766 | 2301 | * @param depr true if it is deprecated |
bpatel@766 | 2302 | * @param first true if the first sentenge tags should be added |
bpatel@766 | 2303 | * @param htmltree the documentation tree to which the comment tags will be added |
bpatel@766 | 2304 | */ |
bpatel@766 | 2305 | private void addCommentTags(Doc doc, Tag[] tags, boolean depr, |
bpatel@766 | 2306 | boolean first, Content htmltree) { |
bpatel@766 | 2307 | if(configuration.nocomment){ |
bpatel@766 | 2308 | return; |
bpatel@766 | 2309 | } |
bpatel@766 | 2310 | Content div; |
bpatel@766 | 2311 | Content result = new RawHtml(commentTagsToString(null, doc, tags, first)); |
bpatel@766 | 2312 | if (depr) { |
bpatel@766 | 2313 | Content italic = HtmlTree.I(result); |
bpatel@766 | 2314 | div = HtmlTree.DIV(HtmlStyle.block, italic); |
bpatel@766 | 2315 | htmltree.addContent(div); |
bpatel@766 | 2316 | } |
bpatel@766 | 2317 | else { |
bpatel@766 | 2318 | div = HtmlTree.DIV(HtmlStyle.block, result); |
bpatel@766 | 2319 | htmltree.addContent(div); |
bpatel@766 | 2320 | } |
bpatel@766 | 2321 | if (tags.length == 0) { |
bpatel@766 | 2322 | htmltree.addContent(getSpace()); |
bpatel@766 | 2323 | } |
bpatel@766 | 2324 | } |
bpatel@766 | 2325 | |
bpatel@766 | 2326 | /** |
duke@1 | 2327 | * Converts inline tags and text to text strings, expanding the |
duke@1 | 2328 | * inline tags along the way. Called wherever text can contain |
duke@1 | 2329 | * an inline tag, such as in comments or in free-form text arguments |
duke@1 | 2330 | * to non-inline tags. |
duke@1 | 2331 | * |
duke@1 | 2332 | * @param holderTag specific tag where comment resides |
duke@1 | 2333 | * @param doc specific doc where comment resides |
duke@1 | 2334 | * @param tags array of text tags and inline tags (often alternating) |
duke@1 | 2335 | * present in the text of interest for this doc |
duke@1 | 2336 | * @param isFirstSentence true if text is first sentence |
duke@1 | 2337 | */ |
duke@1 | 2338 | public String commentTagsToString(Tag holderTag, Doc doc, Tag[] tags, |
duke@1 | 2339 | boolean isFirstSentence) { |
jjg@910 | 2340 | StringBuilder result = new StringBuilder(); |
bpatel@997 | 2341 | boolean textTagChange = false; |
duke@1 | 2342 | // Array of all possible inline tags for this javadoc run |
duke@1 | 2343 | configuration.tagletManager.checkTags(doc, tags, true); |
duke@1 | 2344 | for (int i = 0; i < tags.length; i++) { |
duke@1 | 2345 | Tag tagelem = tags[i]; |
duke@1 | 2346 | String tagName = tagelem.name(); |
duke@1 | 2347 | if (tagelem instanceof SeeTag) { |
duke@1 | 2348 | result.append(seeTagToString((SeeTag)tagelem)); |
duke@1 | 2349 | } else if (! tagName.equals("Text")) { |
duke@1 | 2350 | int originalLength = result.length(); |
duke@1 | 2351 | TagletOutput output = TagletWriter.getInlineTagOuput( |
duke@1 | 2352 | configuration.tagletManager, holderTag, |
jjg@74 | 2353 | tagelem, getTagletWriterInstance(isFirstSentence)); |
duke@1 | 2354 | result.append(output == null ? "" : output.toString()); |
duke@1 | 2355 | if (originalLength == 0 && isFirstSentence && tagelem.name().equals("@inheritDoc") && result.length() > 0) { |
duke@1 | 2356 | break; |
bpatel@997 | 2357 | } else if (configuration.docrootparent.length() > 0 && |
bpatel@997 | 2358 | tagelem.name().equals("@docRoot") && |
bpatel@997 | 2359 | ((tags[i + 1]).text()).startsWith("/..")) { |
bpatel@997 | 2360 | //If Xdocrootparent switch ON, set the flag to remove the /.. occurance after |
bpatel@997 | 2361 | //{@docRoot} tag in the very next Text tag. |
bpatel@997 | 2362 | textTagChange = true; |
bpatel@997 | 2363 | continue; |
duke@1 | 2364 | } else { |
bpatel@997 | 2365 | continue; |
duke@1 | 2366 | } |
duke@1 | 2367 | } else { |
bpatel@997 | 2368 | String text = tagelem.text(); |
bpatel@997 | 2369 | //If Xdocrootparent switch ON, remove the /.. occurance after {@docRoot} tag. |
bpatel@997 | 2370 | if (textTagChange) { |
bpatel@997 | 2371 | text = text.replaceFirst("/..", ""); |
bpatel@997 | 2372 | textTagChange = false; |
bpatel@997 | 2373 | } |
duke@1 | 2374 | //This is just a regular text tag. The text may contain html links (<a>) |
duke@1 | 2375 | //or inline tag {@docRoot}, which will be handled as special cases. |
bpatel@997 | 2376 | text = redirectRelativeLinks(tagelem.holder(), text); |
duke@1 | 2377 | |
duke@1 | 2378 | // Replace @docRoot only if not represented by an instance of DocRootTaglet, |
duke@1 | 2379 | // that is, only if it was not present in a source file doc comment. |
duke@1 | 2380 | // This happens when inserted by the doclet (a few lines |
duke@1 | 2381 | // above in this method). [It might also happen when passed in on the command |
duke@1 | 2382 | // line as a text argument to an option (like -header).] |
duke@1 | 2383 | text = replaceDocRootDir(text); |
duke@1 | 2384 | if (isFirstSentence) { |
duke@1 | 2385 | text = removeNonInlineHtmlTags(text); |
duke@1 | 2386 | } |
duke@1 | 2387 | StringTokenizer lines = new StringTokenizer(text, "\r\n", true); |
duke@1 | 2388 | StringBuffer textBuff = new StringBuffer(); |
duke@1 | 2389 | while (lines.hasMoreTokens()) { |
jjg@910 | 2390 | StringBuilder line = new StringBuilder(lines.nextToken()); |
duke@1 | 2391 | Util.replaceTabs(configuration.sourcetab, line); |
duke@1 | 2392 | textBuff.append(line.toString()); |
duke@1 | 2393 | } |
duke@1 | 2394 | result.append(textBuff); |
duke@1 | 2395 | } |
duke@1 | 2396 | } |
duke@1 | 2397 | return result.toString(); |
duke@1 | 2398 | } |
duke@1 | 2399 | |
duke@1 | 2400 | /** |
duke@1 | 2401 | * Return true if relative links should not be redirected. |
duke@1 | 2402 | * |
duke@1 | 2403 | * @return Return true if a relative link should not be redirected. |
duke@1 | 2404 | */ |
duke@1 | 2405 | private boolean shouldNotRedirectRelativeLinks() { |
duke@1 | 2406 | return this instanceof AnnotationTypeWriter || |
duke@1 | 2407 | this instanceof ClassWriter || |
duke@1 | 2408 | this instanceof PackageSummaryWriter; |
duke@1 | 2409 | } |
duke@1 | 2410 | |
duke@1 | 2411 | /** |
duke@1 | 2412 | * Suppose a piece of documentation has a relative link. When you copy |
duke@1 | 2413 | * that documetation to another place such as the index or class-use page, |
duke@1 | 2414 | * that relative link will no longer work. We should redirect those links |
duke@1 | 2415 | * so that they will work again. |
duke@1 | 2416 | * <p> |
duke@1 | 2417 | * Here is the algorithm used to fix the link: |
duke@1 | 2418 | * <p> |
jjg@1326 | 2419 | * {@literal <relative link> => docRoot + <relative path to file> + <relative link> } |
duke@1 | 2420 | * <p> |
duke@1 | 2421 | * For example, suppose com.sun.javadoc.RootDoc has this link: |
jjg@1326 | 2422 | * {@literal <a href="package-summary.html">The package Page</a> } |
duke@1 | 2423 | * <p> |
duke@1 | 2424 | * If this link appeared in the index, we would redirect |
duke@1 | 2425 | * the link like this: |
duke@1 | 2426 | * |
jjg@1326 | 2427 | * {@literal <a href="./com/sun/javadoc/package-summary.html">The package Page</a>} |
duke@1 | 2428 | * |
duke@1 | 2429 | * @param doc the Doc object whose documentation is being written. |
duke@1 | 2430 | * @param text the text being written. |
duke@1 | 2431 | * |
duke@1 | 2432 | * @return the text, with all the relative links redirected to work. |
duke@1 | 2433 | */ |
duke@1 | 2434 | private String redirectRelativeLinks(Doc doc, String text) { |
duke@1 | 2435 | if (doc == null || shouldNotRedirectRelativeLinks()) { |
duke@1 | 2436 | return text; |
duke@1 | 2437 | } |
duke@1 | 2438 | |
duke@1 | 2439 | String redirectPathFromRoot; |
duke@1 | 2440 | if (doc instanceof ClassDoc) { |
duke@1 | 2441 | redirectPathFromRoot = DirectoryManager.getDirectoryPath(((ClassDoc) doc).containingPackage()); |
duke@1 | 2442 | } else if (doc instanceof MemberDoc) { |
duke@1 | 2443 | redirectPathFromRoot = DirectoryManager.getDirectoryPath(((MemberDoc) doc).containingPackage()); |
duke@1 | 2444 | } else if (doc instanceof PackageDoc) { |
duke@1 | 2445 | redirectPathFromRoot = DirectoryManager.getDirectoryPath((PackageDoc) doc); |
duke@1 | 2446 | } else { |
duke@1 | 2447 | return text; |
duke@1 | 2448 | } |
duke@1 | 2449 | |
bpatel@766 | 2450 | if (! redirectPathFromRoot.endsWith(DirectoryManager.URL_FILE_SEPARATOR)) { |
bpatel@766 | 2451 | redirectPathFromRoot += DirectoryManager.URL_FILE_SEPARATOR; |
duke@1 | 2452 | } |
duke@1 | 2453 | |
duke@1 | 2454 | //Redirect all relative links. |
duke@1 | 2455 | int end, begin = text.toLowerCase().indexOf("<a"); |
duke@1 | 2456 | if(begin >= 0){ |
duke@1 | 2457 | StringBuffer textBuff = new StringBuffer(text); |
duke@1 | 2458 | |
duke@1 | 2459 | while(begin >=0){ |
duke@1 | 2460 | if (textBuff.length() > begin + 2 && ! Character.isWhitespace(textBuff.charAt(begin+2))) { |
duke@1 | 2461 | begin = textBuff.toString().toLowerCase().indexOf("<a", begin + 1); |
duke@1 | 2462 | continue; |
duke@1 | 2463 | } |
duke@1 | 2464 | |
duke@1 | 2465 | begin = textBuff.indexOf("=", begin) + 1; |
duke@1 | 2466 | end = textBuff.indexOf(">", begin +1); |
duke@1 | 2467 | if(begin == 0){ |
duke@1 | 2468 | //Link has no equal symbol. |
duke@1 | 2469 | configuration.root.printWarning( |
duke@1 | 2470 | doc.position(), |
duke@1 | 2471 | configuration.getText("doclet.malformed_html_link_tag", text)); |
duke@1 | 2472 | break; |
duke@1 | 2473 | } |
duke@1 | 2474 | if (end == -1) { |
duke@1 | 2475 | //Break without warning. This <a> tag is not necessarily malformed. The text |
duke@1 | 2476 | //might be missing '>' character because the href has an inline tag. |
duke@1 | 2477 | break; |
duke@1 | 2478 | } |
duke@1 | 2479 | if(textBuff.substring(begin, end).indexOf("\"") != -1){ |
duke@1 | 2480 | begin = textBuff.indexOf("\"", begin) + 1; |
duke@1 | 2481 | end = textBuff.indexOf("\"", begin +1); |
duke@1 | 2482 | if(begin == 0 || end == -1){ |
duke@1 | 2483 | //Link is missing a quote. |
duke@1 | 2484 | break; |
duke@1 | 2485 | } |
duke@1 | 2486 | } |
duke@1 | 2487 | String relativeLink = textBuff.substring(begin, end); |
duke@1 | 2488 | if(!(relativeLink.toLowerCase().startsWith("mailto:") || |
duke@1 | 2489 | relativeLink.toLowerCase().startsWith("http:") || |
duke@1 | 2490 | relativeLink.toLowerCase().startsWith("https:") || |
duke@1 | 2491 | relativeLink.toLowerCase().startsWith("file:"))){ |
duke@1 | 2492 | relativeLink = "{@"+(new DocRootTaglet()).getName() + "}" |
duke@1 | 2493 | + redirectPathFromRoot |
duke@1 | 2494 | + relativeLink; |
duke@1 | 2495 | textBuff.replace(begin, end, relativeLink); |
duke@1 | 2496 | } |
duke@1 | 2497 | begin = textBuff.toString().toLowerCase().indexOf("<a", begin + 1); |
duke@1 | 2498 | } |
duke@1 | 2499 | return textBuff.toString(); |
duke@1 | 2500 | } |
duke@1 | 2501 | return text; |
duke@1 | 2502 | } |
duke@1 | 2503 | |
duke@1 | 2504 | public String removeNonInlineHtmlTags(String text) { |
duke@1 | 2505 | if (text.indexOf('<') < 0) { |
duke@1 | 2506 | return text; |
duke@1 | 2507 | } |
duke@1 | 2508 | String noninlinetags[] = { "<ul>", "</ul>", "<ol>", "</ol>", |
duke@1 | 2509 | "<dl>", "</dl>", "<table>", "</table>", |
duke@1 | 2510 | "<tr>", "</tr>", "<td>", "</td>", |
duke@1 | 2511 | "<th>", "</th>", "<p>", "</p>", |
duke@1 | 2512 | "<li>", "</li>", "<dd>", "</dd>", |
duke@1 | 2513 | "<dir>", "</dir>", "<dt>", "</dt>", |
duke@1 | 2514 | "<h1>", "</h1>", "<h2>", "</h2>", |
duke@1 | 2515 | "<h3>", "</h3>", "<h4>", "</h4>", |
duke@1 | 2516 | "<h5>", "</h5>", "<h6>", "</h6>", |
duke@1 | 2517 | "<pre>", "</pre>", "<menu>", "</menu>", |
duke@1 | 2518 | "<listing>", "</listing>", "<hr>", |
duke@1 | 2519 | "<blockquote>", "</blockquote>", |
duke@1 | 2520 | "<center>", "</center>", |
duke@1 | 2521 | "<UL>", "</UL>", "<OL>", "</OL>", |
duke@1 | 2522 | "<DL>", "</DL>", "<TABLE>", "</TABLE>", |
duke@1 | 2523 | "<TR>", "</TR>", "<TD>", "</TD>", |
duke@1 | 2524 | "<TH>", "</TH>", "<P>", "</P>", |
duke@1 | 2525 | "<LI>", "</LI>", "<DD>", "</DD>", |
duke@1 | 2526 | "<DIR>", "</DIR>", "<DT>", "</DT>", |
duke@1 | 2527 | "<H1>", "</H1>", "<H2>", "</H2>", |
duke@1 | 2528 | "<H3>", "</H3>", "<H4>", "</H4>", |
duke@1 | 2529 | "<H5>", "</H5>", "<H6>", "</H6>", |
duke@1 | 2530 | "<PRE>", "</PRE>", "<MENU>", "</MENU>", |
duke@1 | 2531 | "<LISTING>", "</LISTING>", "<HR>", |
duke@1 | 2532 | "<BLOCKQUOTE>", "</BLOCKQUOTE>", |
duke@1 | 2533 | "<CENTER>", "</CENTER>" |
duke@1 | 2534 | }; |
duke@1 | 2535 | for (int i = 0; i < noninlinetags.length; i++) { |
duke@1 | 2536 | text = replace(text, noninlinetags[i], ""); |
duke@1 | 2537 | } |
duke@1 | 2538 | return text; |
duke@1 | 2539 | } |
duke@1 | 2540 | |
duke@1 | 2541 | public String replace(String text, String tobe, String by) { |
duke@1 | 2542 | while (true) { |
duke@1 | 2543 | int startindex = text.indexOf(tobe); |
duke@1 | 2544 | if (startindex < 0) { |
duke@1 | 2545 | return text; |
duke@1 | 2546 | } |
duke@1 | 2547 | int endindex = startindex + tobe.length(); |
jjg@910 | 2548 | StringBuilder replaced = new StringBuilder(); |
duke@1 | 2549 | if (startindex > 0) { |
duke@1 | 2550 | replaced.append(text.substring(0, startindex)); |
duke@1 | 2551 | } |
duke@1 | 2552 | replaced.append(by); |
duke@1 | 2553 | if (text.length() > endindex) { |
duke@1 | 2554 | replaced.append(text.substring(endindex)); |
duke@1 | 2555 | } |
duke@1 | 2556 | text = replaced.toString(); |
duke@1 | 2557 | } |
duke@1 | 2558 | } |
duke@1 | 2559 | |
duke@1 | 2560 | public void printStyleSheetProperties() { |
duke@1 | 2561 | String filename = configuration.stylesheetfile; |
duke@1 | 2562 | if (filename.length() > 0) { |
duke@1 | 2563 | File stylefile = new File(filename); |
duke@1 | 2564 | String parent = stylefile.getParent(); |
duke@1 | 2565 | filename = (parent == null)? |
duke@1 | 2566 | filename: |
duke@1 | 2567 | filename.substring(parent.length() + 1); |
duke@1 | 2568 | } else { |
duke@1 | 2569 | filename = "stylesheet.css"; |
duke@1 | 2570 | } |
duke@1 | 2571 | filename = relativePath + filename; |
duke@1 | 2572 | link("REL =\"stylesheet\" TYPE=\"text/css\" HREF=\"" + |
duke@1 | 2573 | filename + "\" " + "TITLE=\"Style\""); |
duke@1 | 2574 | } |
duke@1 | 2575 | |
duke@1 | 2576 | /** |
bpatel@766 | 2577 | * Returns a link to the stylesheet file. |
bpatel@766 | 2578 | * |
bpatel@766 | 2579 | * @return an HtmlTree for the lINK tag which provides the stylesheet location |
bpatel@766 | 2580 | */ |
bpatel@766 | 2581 | public HtmlTree getStyleSheetProperties() { |
bpatel@766 | 2582 | String filename = configuration.stylesheetfile; |
bpatel@766 | 2583 | if (filename.length() > 0) { |
bpatel@766 | 2584 | File stylefile = new File(filename); |
bpatel@766 | 2585 | String parent = stylefile.getParent(); |
bpatel@766 | 2586 | filename = (parent == null)? |
bpatel@766 | 2587 | filename: |
bpatel@766 | 2588 | filename.substring(parent.length() + 1); |
bpatel@766 | 2589 | } else { |
bpatel@766 | 2590 | filename = "stylesheet.css"; |
bpatel@766 | 2591 | } |
bpatel@766 | 2592 | filename = relativePath + filename; |
bpatel@766 | 2593 | HtmlTree link = HtmlTree.LINK("stylesheet", "text/css", filename, "Style"); |
bpatel@766 | 2594 | return link; |
bpatel@766 | 2595 | } |
bpatel@766 | 2596 | |
bpatel@766 | 2597 | /** |
jjh@972 | 2598 | * According to |
jjh@972 | 2599 | * <cite>The Java™ Language Specification</cite>, |
jjh@972 | 2600 | * all the outer classes and static nested classes are core classes. |
duke@1 | 2601 | */ |
duke@1 | 2602 | public boolean isCoreClass(ClassDoc cd) { |
duke@1 | 2603 | return cd.containingClass() == null || cd.isStatic(); |
duke@1 | 2604 | } |
duke@1 | 2605 | |
duke@1 | 2606 | /** |
duke@1 | 2607 | * Write the annotatation types for the given packageDoc. |
duke@1 | 2608 | * |
duke@1 | 2609 | * @param packageDoc the package to write annotations for. |
duke@1 | 2610 | */ |
duke@1 | 2611 | public void writeAnnotationInfo(PackageDoc packageDoc) { |
duke@1 | 2612 | writeAnnotationInfo(packageDoc, packageDoc.annotations()); |
duke@1 | 2613 | } |
duke@1 | 2614 | |
duke@1 | 2615 | /** |
bpatel@766 | 2616 | * Adds the annotatation types for the given packageDoc. |
bpatel@766 | 2617 | * |
bpatel@766 | 2618 | * @param packageDoc the package to write annotations for. |
bpatel@766 | 2619 | * @param htmltree the documentation tree to which the annotation info will be |
bpatel@766 | 2620 | * added |
bpatel@766 | 2621 | */ |
bpatel@766 | 2622 | public void addAnnotationInfo(PackageDoc packageDoc, Content htmltree) { |
bpatel@766 | 2623 | addAnnotationInfo(packageDoc, packageDoc.annotations(), htmltree); |
bpatel@766 | 2624 | } |
bpatel@766 | 2625 | |
bpatel@766 | 2626 | /** |
duke@1 | 2627 | * Write the annotatation types for the given doc. |
duke@1 | 2628 | * |
duke@1 | 2629 | * @param doc the doc to write annotations for. |
duke@1 | 2630 | */ |
duke@1 | 2631 | public void writeAnnotationInfo(ProgramElementDoc doc) { |
duke@1 | 2632 | writeAnnotationInfo(doc, doc.annotations()); |
duke@1 | 2633 | } |
duke@1 | 2634 | |
duke@1 | 2635 | /** |
bpatel@766 | 2636 | * Adds the annotatation types for the given doc. |
bpatel@766 | 2637 | * |
bpatel@766 | 2638 | * @param packageDoc the package to write annotations for |
bpatel@766 | 2639 | * @param htmltree the content tree to which the annotation types will be added |
bpatel@766 | 2640 | */ |
bpatel@766 | 2641 | public void addAnnotationInfo(ProgramElementDoc doc, Content htmltree) { |
bpatel@766 | 2642 | addAnnotationInfo(doc, doc.annotations(), htmltree); |
bpatel@766 | 2643 | } |
bpatel@766 | 2644 | |
bpatel@766 | 2645 | /** |
duke@1 | 2646 | * Write the annotatation types for the given doc and parameter. |
duke@1 | 2647 | * |
duke@1 | 2648 | * @param indent the number of spaced to indent the parameters. |
duke@1 | 2649 | * @param doc the doc to write annotations for. |
duke@1 | 2650 | * @param param the parameter to write annotations for. |
duke@1 | 2651 | */ |
duke@1 | 2652 | public boolean writeAnnotationInfo(int indent, Doc doc, Parameter param) { |
duke@1 | 2653 | return writeAnnotationInfo(indent, doc, param.annotations(), false); |
duke@1 | 2654 | } |
duke@1 | 2655 | |
duke@1 | 2656 | /** |
bpatel@766 | 2657 | * Add the annotatation types for the given doc and parameter. |
bpatel@766 | 2658 | * |
bpatel@766 | 2659 | * @param indent the number of spaces to indent the parameters. |
bpatel@766 | 2660 | * @param doc the doc to write annotations for. |
bpatel@766 | 2661 | * @param param the parameter to write annotations for. |
bpatel@766 | 2662 | * @param tree the content tree to which the annotation types will be added |
bpatel@766 | 2663 | */ |
bpatel@766 | 2664 | public boolean addAnnotationInfo(int indent, Doc doc, Parameter param, |
bpatel@766 | 2665 | Content tree) { |
bpatel@766 | 2666 | return addAnnotationInfo(indent, doc, param.annotations(), false, tree); |
bpatel@766 | 2667 | } |
bpatel@766 | 2668 | |
bpatel@766 | 2669 | /** |
duke@1 | 2670 | * Write the annotatation types for the given doc. |
duke@1 | 2671 | * |
duke@1 | 2672 | * @param doc the doc to write annotations for. |
duke@1 | 2673 | * @param descList the array of {@link AnnotationDesc}. |
duke@1 | 2674 | */ |
duke@1 | 2675 | private void writeAnnotationInfo(Doc doc, AnnotationDesc[] descList) { |
duke@1 | 2676 | writeAnnotationInfo(0, doc, descList, true); |
duke@1 | 2677 | } |
duke@1 | 2678 | |
duke@1 | 2679 | /** |
bpatel@766 | 2680 | * Adds the annotatation types for the given doc. |
bpatel@766 | 2681 | * |
bpatel@766 | 2682 | * @param doc the doc to write annotations for. |
bpatel@766 | 2683 | * @param descList the array of {@link AnnotationDesc}. |
bpatel@766 | 2684 | * @param htmltree the documentation tree to which the annotation info will be |
bpatel@766 | 2685 | * added |
bpatel@766 | 2686 | */ |
bpatel@766 | 2687 | private void addAnnotationInfo(Doc doc, AnnotationDesc[] descList, |
bpatel@766 | 2688 | Content htmltree) { |
bpatel@766 | 2689 | addAnnotationInfo(0, doc, descList, true, htmltree); |
bpatel@766 | 2690 | } |
bpatel@766 | 2691 | |
bpatel@766 | 2692 | /** |
duke@1 | 2693 | * Write the annotatation types for the given doc. |
duke@1 | 2694 | * |
duke@1 | 2695 | * @param indent the number of extra spaces to indent the annotations. |
duke@1 | 2696 | * @param doc the doc to write annotations for. |
duke@1 | 2697 | * @param descList the array of {@link AnnotationDesc}. |
duke@1 | 2698 | */ |
duke@1 | 2699 | private boolean writeAnnotationInfo(int indent, Doc doc, AnnotationDesc[] descList, boolean lineBreak) { |
mcimadamore@184 | 2700 | List<String> annotations = getAnnotations(indent, descList, lineBreak); |
duke@1 | 2701 | if (annotations.size() == 0) { |
duke@1 | 2702 | return false; |
duke@1 | 2703 | } |
duke@1 | 2704 | fontNoNewLine("-1"); |
mcimadamore@184 | 2705 | for (Iterator<String> iter = annotations.iterator(); iter.hasNext();) { |
mcimadamore@184 | 2706 | print(iter.next()); |
duke@1 | 2707 | } |
duke@1 | 2708 | fontEnd(); |
duke@1 | 2709 | return true; |
duke@1 | 2710 | } |
duke@1 | 2711 | |
duke@1 | 2712 | /** |
bpatel@766 | 2713 | * Adds the annotatation types for the given doc. |
bpatel@766 | 2714 | * |
bpatel@766 | 2715 | * @param indent the number of extra spaces to indent the annotations. |
bpatel@766 | 2716 | * @param doc the doc to write annotations for. |
bpatel@766 | 2717 | * @param descList the array of {@link AnnotationDesc}. |
bpatel@766 | 2718 | * @param htmltree the documentation tree to which the annotation info will be |
bpatel@766 | 2719 | * added |
bpatel@766 | 2720 | */ |
bpatel@766 | 2721 | private boolean addAnnotationInfo(int indent, Doc doc, |
bpatel@766 | 2722 | AnnotationDesc[] descList, boolean lineBreak, Content htmltree) { |
bpatel@766 | 2723 | List<String> annotations = getAnnotations(indent, descList, lineBreak); |
bpatel@766 | 2724 | if (annotations.size() == 0) { |
bpatel@766 | 2725 | return false; |
bpatel@766 | 2726 | } |
bpatel@766 | 2727 | Content annotationContent; |
bpatel@766 | 2728 | for (Iterator<String> iter = annotations.iterator(); iter.hasNext();) { |
bpatel@766 | 2729 | annotationContent = new RawHtml(iter.next()); |
bpatel@766 | 2730 | htmltree.addContent(annotationContent); |
bpatel@766 | 2731 | } |
bpatel@766 | 2732 | return true; |
bpatel@766 | 2733 | } |
bpatel@766 | 2734 | |
bpatel@766 | 2735 | /** |
duke@1 | 2736 | * Return the string representations of the annotation types for |
duke@1 | 2737 | * the given doc. |
duke@1 | 2738 | * |
duke@1 | 2739 | * @param indent the number of extra spaces to indent the annotations. |
duke@1 | 2740 | * @param descList the array of {@link AnnotationDesc}. |
duke@1 | 2741 | * @param linkBreak if true, add new line between each member value. |
duke@1 | 2742 | * @return an array of strings representing the annotations being |
duke@1 | 2743 | * documented. |
duke@1 | 2744 | */ |
jjg@74 | 2745 | private List<String> getAnnotations(int indent, AnnotationDesc[] descList, boolean linkBreak) { |
jjg@74 | 2746 | List<String> results = new ArrayList<String>(); |
duke@1 | 2747 | StringBuffer annotation; |
duke@1 | 2748 | for (int i = 0; i < descList.length; i++) { |
duke@1 | 2749 | AnnotationTypeDoc annotationDoc = descList[i].annotationType(); |
duke@1 | 2750 | if (! Util.isDocumentedAnnotation(annotationDoc)){ |
duke@1 | 2751 | continue; |
duke@1 | 2752 | } |
duke@1 | 2753 | annotation = new StringBuffer(); |
duke@1 | 2754 | LinkInfoImpl linkInfo = new LinkInfoImpl( |
duke@1 | 2755 | LinkInfoImpl.CONTEXT_ANNOTATION, annotationDoc); |
duke@1 | 2756 | linkInfo.label = "@" + annotationDoc.name(); |
duke@1 | 2757 | annotation.append(getLink(linkInfo)); |
duke@1 | 2758 | AnnotationDesc.ElementValuePair[] pairs = descList[i].elementValues(); |
duke@1 | 2759 | if (pairs.length > 0) { |
duke@1 | 2760 | annotation.append('('); |
duke@1 | 2761 | for (int j = 0; j < pairs.length; j++) { |
duke@1 | 2762 | if (j > 0) { |
duke@1 | 2763 | annotation.append(","); |
duke@1 | 2764 | if (linkBreak) { |
duke@1 | 2765 | annotation.append(DocletConstants.NL); |
duke@1 | 2766 | int spaces = annotationDoc.name().length() + 2; |
duke@1 | 2767 | for (int k = 0; k < (spaces + indent); k++) { |
duke@1 | 2768 | annotation.append(' '); |
duke@1 | 2769 | } |
duke@1 | 2770 | } |
duke@1 | 2771 | } |
duke@1 | 2772 | annotation.append(getDocLink(LinkInfoImpl.CONTEXT_ANNOTATION, |
duke@1 | 2773 | pairs[j].element(), pairs[j].element().name(), false)); |
duke@1 | 2774 | annotation.append('='); |
duke@1 | 2775 | AnnotationValue annotationValue = pairs[j].value(); |
jjg@74 | 2776 | List<AnnotationValue> annotationTypeValues = new ArrayList<AnnotationValue>(); |
duke@1 | 2777 | if (annotationValue.value() instanceof AnnotationValue[]) { |
duke@1 | 2778 | AnnotationValue[] annotationArray = |
duke@1 | 2779 | (AnnotationValue[]) annotationValue.value(); |
duke@1 | 2780 | for (int k = 0; k < annotationArray.length; k++) { |
duke@1 | 2781 | annotationTypeValues.add(annotationArray[k]); |
duke@1 | 2782 | } |
duke@1 | 2783 | } else { |
duke@1 | 2784 | annotationTypeValues.add(annotationValue); |
duke@1 | 2785 | } |
duke@1 | 2786 | annotation.append(annotationTypeValues.size() == 1 ? "" : "{"); |
mcimadamore@184 | 2787 | for (Iterator<AnnotationValue> iter = annotationTypeValues.iterator(); iter.hasNext(); ) { |
mcimadamore@184 | 2788 | annotation.append(annotationValueToString(iter.next())); |
duke@1 | 2789 | annotation.append(iter.hasNext() ? "," : ""); |
duke@1 | 2790 | } |
duke@1 | 2791 | annotation.append(annotationTypeValues.size() == 1 ? "" : "}"); |
duke@1 | 2792 | } |
duke@1 | 2793 | annotation.append(")"); |
duke@1 | 2794 | } |
duke@1 | 2795 | annotation.append(linkBreak ? DocletConstants.NL : ""); |
duke@1 | 2796 | results.add(annotation.toString()); |
duke@1 | 2797 | } |
duke@1 | 2798 | return results; |
duke@1 | 2799 | } |
duke@1 | 2800 | |
duke@1 | 2801 | private String annotationValueToString(AnnotationValue annotationValue) { |
duke@1 | 2802 | if (annotationValue.value() instanceof Type) { |
duke@1 | 2803 | Type type = (Type) annotationValue.value(); |
duke@1 | 2804 | if (type.asClassDoc() != null) { |
duke@1 | 2805 | LinkInfoImpl linkInfo = new LinkInfoImpl( |
duke@1 | 2806 | LinkInfoImpl.CONTEXT_ANNOTATION, type); |
duke@1 | 2807 | linkInfo.label = (type.asClassDoc().isIncluded() ? |
duke@1 | 2808 | type.typeName() : |
duke@1 | 2809 | type.qualifiedTypeName()) + type.dimension() + ".class"; |
duke@1 | 2810 | return getLink(linkInfo); |
duke@1 | 2811 | } else { |
duke@1 | 2812 | return type.typeName() + type.dimension() + ".class"; |
duke@1 | 2813 | } |
duke@1 | 2814 | } else if (annotationValue.value() instanceof AnnotationDesc) { |
mcimadamore@184 | 2815 | List<String> list = getAnnotations(0, |
duke@1 | 2816 | new AnnotationDesc[]{(AnnotationDesc) annotationValue.value()}, |
duke@1 | 2817 | false); |
duke@1 | 2818 | StringBuffer buf = new StringBuffer(); |
mcimadamore@184 | 2819 | for (Iterator<String> iter = list.iterator(); iter.hasNext(); ) { |
duke@1 | 2820 | buf.append(iter.next()); |
duke@1 | 2821 | } |
duke@1 | 2822 | return buf.toString(); |
duke@1 | 2823 | } else if (annotationValue.value() instanceof MemberDoc) { |
duke@1 | 2824 | return getDocLink(LinkInfoImpl.CONTEXT_ANNOTATION, |
duke@1 | 2825 | (MemberDoc) annotationValue.value(), |
duke@1 | 2826 | ((MemberDoc) annotationValue.value()).name(), false); |
duke@1 | 2827 | } else { |
duke@1 | 2828 | return annotationValue.toString(); |
duke@1 | 2829 | } |
duke@1 | 2830 | } |
duke@1 | 2831 | |
duke@1 | 2832 | /** |
duke@1 | 2833 | * Return the configuation for this doclet. |
duke@1 | 2834 | * |
duke@1 | 2835 | * @return the configuration for this doclet. |
duke@1 | 2836 | */ |
duke@1 | 2837 | public Configuration configuration() { |
duke@1 | 2838 | return configuration; |
duke@1 | 2839 | } |
duke@1 | 2840 | } |