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