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

Tue, 16 Oct 2012 21:03:36 -0700

author
jjg
date
Tue, 16 Oct 2012 21:03:36 -0700
changeset 1365
2013982bee34
parent 1364
8db45b13526e
child 1372
78962d89f283
permissions
-rw-r--r--

8000673: remove dead code from HtmlWriter and subtypes
Reviewed-by: bpatel

duke@1 1 /*
jjg@1326 2 * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
duke@1 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@1 4 *
duke@1 5 * This code is free software; you can redistribute it and/or modify it
duke@1 6 * under the terms of the GNU General Public License version 2 only, as
ohair@554 7 * published by the Free Software Foundation. Oracle designates this
duke@1 8 * particular file as subject to the "Classpath" exception as provided
ohair@554 9 * by Oracle in the LICENSE file that accompanied this code.
duke@1 10 *
duke@1 11 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@1 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@1 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@1 14 * version 2 for more details (a copy is included in the LICENSE file that
duke@1 15 * accompanied this code).
duke@1 16 *
duke@1 17 * You should have received a copy of the GNU General Public License version
duke@1 18 * 2 along with this work; if not, write to the Free Software Foundation,
duke@1 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@1 20 *
ohair@554 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ohair@554 22 * or visit www.oracle.com if you need additional information or have any
ohair@554 23 * questions.
duke@1 24 */
duke@1 25
duke@1 26 package com.sun.tools.doclets.formats.html;
duke@1 27
duke@1 28 import java.io.*;
duke@1 29 import java.text.SimpleDateFormat;
duke@1 30 import java.util.*;
duke@1 31
bpatel@233 32 import com.sun.javadoc.*;
bpatel@233 33 import com.sun.tools.doclets.formats.html.markup.*;
bpatel@233 34 import com.sun.tools.doclets.internal.toolkit.*;
jjg@1357 35 import com.sun.tools.doclets.internal.toolkit.taglets.*;
bpatel@233 36 import com.sun.tools.doclets.internal.toolkit.util.*;
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 *
jjg@1359 43 * <p><b>This is NOT part of any supported API.
jjg@1359 44 * If you write code that depends on this, you do so at your own risk.
jjg@1359 45 * This code and its internal interfaces are subject to change or
jjg@1359 46 * deletion without notice.</b>
jjg@1359 47 *
duke@1 48 * @since 1.2
duke@1 49 * @author Atul M Dambalkar
duke@1 50 * @author Robert Field
bpatel@233 51 * @author Bhavesh Patel (Modified)
duke@1 52 */
duke@1 53 public class HtmlDocletWriter extends HtmlDocWriter {
duke@1 54
duke@1 55 /**
duke@1 56 * Relative path from the file getting generated to the destination
duke@1 57 * directory. For example, if the file getting generated is
duke@1 58 * "java/lang/Object.html", then the relative path string is "../../".
duke@1 59 * This string can be empty if the file getting generated is in
duke@1 60 * the destination directory.
duke@1 61 */
duke@1 62 public String relativePath = "";
duke@1 63
duke@1 64 /**
duke@1 65 * Same as relativepath, but normalized to never be empty or
duke@1 66 * end with a slash.
duke@1 67 */
duke@1 68 public String relativepathNoSlash = "";
duke@1 69
duke@1 70 /**
duke@1 71 * Platform-dependent directory path from the current or the
duke@1 72 * destination directory to the file getting generated.
duke@1 73 * Used when creating the file.
duke@1 74 * For example, if the file getting generated is
duke@1 75 * "java/lang/Object.html", then the path string is "java/lang".
duke@1 76 */
duke@1 77 public String path = "";
duke@1 78
duke@1 79 /**
duke@1 80 * Name of the file getting generated. If the file getting generated is
duke@1 81 * "java/lang/Object.html", then the filename is "Object.html".
duke@1 82 */
duke@1 83 public String filename = "";
duke@1 84
duke@1 85 /**
duke@1 86 * The display length used for indentation while generating the class page.
duke@1 87 */
duke@1 88 public int displayLength = 0;
duke@1 89
duke@1 90 /**
duke@1 91 * The global configuration information for this run.
duke@1 92 */
duke@1 93 public ConfigurationImpl configuration;
duke@1 94
duke@1 95 /**
bpatel@766 96 * To check whether annotation heading is printed or not.
bpatel@766 97 */
bpatel@766 98 protected boolean printedAnnotationHeading = false;
bpatel@766 99
bpatel@766 100 /**
duke@1 101 * Constructor to construct the HtmlStandardWriter object.
duke@1 102 *
duke@1 103 * @param filename File to be generated.
duke@1 104 */
duke@1 105 public HtmlDocletWriter(ConfigurationImpl configuration,
duke@1 106 String filename) throws IOException {
duke@1 107 super(configuration, filename);
duke@1 108 this.configuration = configuration;
duke@1 109 this.filename = filename;
duke@1 110 }
duke@1 111
duke@1 112 /**
duke@1 113 * Constructor to construct the HtmlStandardWriter object.
duke@1 114 *
duke@1 115 * @param path Platform-dependent {@link #path} used when
duke@1 116 * creating file.
duke@1 117 * @param filename Name of file to be generated.
duke@1 118 * @param relativePath Value for the variable {@link #relativePath}.
duke@1 119 */
duke@1 120 public HtmlDocletWriter(ConfigurationImpl configuration,
duke@1 121 String path, String filename,
duke@1 122 String relativePath) throws IOException {
duke@1 123 super(configuration, path, filename);
duke@1 124 this.configuration = configuration;
duke@1 125 this.path = path;
duke@1 126 this.relativePath = relativePath;
duke@1 127 this.relativepathNoSlash =
duke@1 128 DirectoryManager.getPathNoTrailingSlash(this.relativePath);
duke@1 129 this.filename = filename;
duke@1 130 }
duke@1 131
duke@1 132 /**
duke@1 133 * Replace {&#064;docRoot} tag used in options that accept HTML text, such
duke@1 134 * as -header, -footer, -top and -bottom, and when converting a relative
duke@1 135 * HREF where commentTagsToString inserts a {&#064;docRoot} where one was
duke@1 136 * missing. (Also see DocRootTaglet for {&#064;docRoot} tags in doc
duke@1 137 * comments.)
duke@1 138 * <p>
duke@1 139 * Replace {&#064;docRoot} tag in htmlstr with the relative path to the
duke@1 140 * destination directory from the directory where the file is being
duke@1 141 * written, looping to handle all such tags in htmlstr.
duke@1 142 * <p>
duke@1 143 * For example, for "-d docs" and -header containing {&#064;docRoot}, when
duke@1 144 * the HTML page for source file p/C1.java is being generated, the
duke@1 145 * {&#064;docRoot} tag would be inserted into the header as "../",
duke@1 146 * the relative path from docs/p/ to docs/ (the document root).
duke@1 147 * <p>
duke@1 148 * Note: This doc comment was written with '&amp;#064;' representing '@'
duke@1 149 * to prevent the inline tag from being interpreted.
duke@1 150 */
duke@1 151 public String replaceDocRootDir(String htmlstr) {
duke@1 152 // Return if no inline tags exist
duke@1 153 int index = htmlstr.indexOf("{@");
duke@1 154 if (index < 0) {
duke@1 155 return htmlstr;
duke@1 156 }
duke@1 157 String lowerHtml = htmlstr.toLowerCase();
duke@1 158 // Return index of first occurrence of {@docroot}
duke@1 159 // Note: {@docRoot} is not case sensitive when passed in w/command line option
duke@1 160 index = lowerHtml.indexOf("{@docroot}", index);
duke@1 161 if (index < 0) {
duke@1 162 return htmlstr;
duke@1 163 }
jjg@910 164 StringBuilder buf = new StringBuilder();
duke@1 165 int previndex = 0;
duke@1 166 while (true) {
bpatel@997 167 if (configuration.docrootparent.length() > 0) {
bpatel@997 168 // Search for lowercase version of {@docRoot}/..
bpatel@997 169 index = lowerHtml.indexOf("{@docroot}/..", previndex);
bpatel@997 170 // If next {@docRoot}/.. pattern not found, append rest of htmlstr and exit loop
bpatel@997 171 if (index < 0) {
bpatel@997 172 buf.append(htmlstr.substring(previndex));
bpatel@997 173 break;
bpatel@997 174 }
bpatel@997 175 // If next {@docroot}/.. pattern found, append htmlstr up to start of tag
bpatel@997 176 buf.append(htmlstr.substring(previndex, index));
bpatel@997 177 previndex = index + 13; // length for {@docroot}/.. string
bpatel@997 178 // Insert docrootparent absolute path where {@docRoot}/.. was located
bpatel@997 179
bpatel@997 180 buf.append(configuration.docrootparent);
bpatel@997 181 // Append slash if next character is not a slash
bpatel@997 182 if (previndex < htmlstr.length() && htmlstr.charAt(previndex) != '/') {
bpatel@997 183 buf.append(DirectoryManager.URL_FILE_SEPARATOR);
bpatel@997 184 }
bpatel@997 185 } else {
bpatel@997 186 // Search for lowercase version of {@docRoot}
bpatel@997 187 index = lowerHtml.indexOf("{@docroot}", previndex);
bpatel@997 188 // If next {@docRoot} tag not found, append rest of htmlstr and exit loop
bpatel@997 189 if (index < 0) {
bpatel@997 190 buf.append(htmlstr.substring(previndex));
bpatel@997 191 break;
bpatel@997 192 }
bpatel@997 193 // If next {@docroot} tag found, append htmlstr up to start of tag
bpatel@997 194 buf.append(htmlstr.substring(previndex, index));
bpatel@997 195 previndex = index + 10; // length for {@docroot} string
bpatel@997 196 // Insert relative path where {@docRoot} was located
bpatel@997 197 buf.append(relativepathNoSlash);
bpatel@997 198 // Append slash if next character is not a slash
bpatel@997 199 if (relativepathNoSlash.length() > 0 && previndex < htmlstr.length() &&
bpatel@997 200 htmlstr.charAt(previndex) != '/') {
bpatel@997 201 buf.append(DirectoryManager.URL_FILE_SEPARATOR);
bpatel@997 202 }
duke@1 203 }
duke@1 204 }
duke@1 205 return buf.toString();
duke@1 206 }
duke@1 207
duke@1 208 /**
bpatel@766 209 * Get the script to show or hide the All classes link.
bpatel@766 210 *
bpatel@766 211 * @param id id of the element to show or hide
bpatel@766 212 * @return a content tree for the script
bpatel@766 213 */
bpatel@766 214 public Content getAllClassesLinkScript(String id) {
bpatel@766 215 HtmlTree script = new HtmlTree(HtmlTag.SCRIPT);
bpatel@766 216 script.addAttr(HtmlAttr.TYPE, "text/javascript");
bpatel@793 217 String scriptCode = "<!--" + DocletConstants.NL +
bpatel@793 218 " allClassesLink = document.getElementById(\"" + id + "\");" + DocletConstants.NL +
bpatel@793 219 " if(window==top) {" + DocletConstants.NL +
bpatel@793 220 " allClassesLink.style.display = \"block\";" + DocletConstants.NL +
bpatel@793 221 " }" + DocletConstants.NL +
bpatel@793 222 " else {" + DocletConstants.NL +
bpatel@793 223 " allClassesLink.style.display = \"none\";" + DocletConstants.NL +
bpatel@793 224 " }" + DocletConstants.NL +
bpatel@793 225 " //-->" + DocletConstants.NL;
bpatel@766 226 Content scriptContent = new RawHtml(scriptCode);
bpatel@766 227 script.addContent(scriptContent);
bpatel@766 228 Content div = HtmlTree.DIV(script);
bpatel@766 229 return div;
bpatel@766 230 }
bpatel@766 231
bpatel@766 232 /**
bpatel@766 233 * Add method information.
bpatel@766 234 *
bpatel@766 235 * @param method the method to be documented
bpatel@766 236 * @param dl the content tree to which the method information will be added
bpatel@766 237 */
bpatel@766 238 private void addMethodInfo(MethodDoc method, Content dl) {
duke@1 239 ClassDoc[] intfacs = method.containingClass().interfaces();
duke@1 240 MethodDoc overriddenMethod = method.overriddenMethod();
bpatel@233 241 // Check whether there is any implementation or overridden info to be
bpatel@233 242 // printed. If no overridden or implementation info needs to be
bpatel@233 243 // printed, do not print this section.
bpatel@233 244 if ((intfacs.length > 0 &&
bpatel@233 245 new ImplementedMethods(method, this.configuration).build().length > 0) ||
bpatel@233 246 overriddenMethod != null) {
bpatel@766 247 MethodWriterImpl.addImplementsInfo(this, method, dl);
duke@1 248 if (overriddenMethod != null) {
bpatel@766 249 MethodWriterImpl.addOverridden(this,
bpatel@766 250 method.overriddenType(), overriddenMethod, dl);
duke@1 251 }
duke@1 252 }
duke@1 253 }
duke@1 254
bpatel@766 255 /**
bpatel@766 256 * Adds the tags information.
bpatel@766 257 *
bpatel@766 258 * @param doc the doc for which the tags will be generated
bpatel@766 259 * @param htmltree the documentation tree to which the tags will be added
bpatel@766 260 */
bpatel@766 261 protected void addTagsInfo(Doc doc, Content htmltree) {
bpatel@766 262 if (configuration.nocomment) {
duke@1 263 return;
duke@1 264 }
bpatel@766 265 Content dl = new HtmlTree(HtmlTag.DL);
duke@1 266 if (doc instanceof MethodDoc) {
bpatel@766 267 addMethodInfo((MethodDoc) doc, dl);
duke@1 268 }
duke@1 269 TagletOutputImpl output = new TagletOutputImpl("");
duke@1 270 TagletWriter.genTagOuput(configuration.tagletManager, doc,
duke@1 271 configuration.tagletManager.getCustomTags(doc),
duke@1 272 getTagletWriterInstance(false), output);
bpatel@233 273 String outputString = output.toString().trim();
bpatel@233 274 if (!outputString.isEmpty()) {
bpatel@766 275 Content resultString = new RawHtml(outputString);
bpatel@766 276 dl.addContent(resultString);
duke@1 277 }
bpatel@766 278 htmltree.addContent(dl);
duke@1 279 }
duke@1 280
duke@1 281 /**
bpatel@233 282 * Check whether there are any tags for Serialization Overview
bpatel@233 283 * section to be printed.
bpatel@222 284 *
bpatel@233 285 * @param field the FieldDoc object to check for tags.
bpatel@222 286 * @return true if there are tags to be printed else return false.
bpatel@222 287 */
bpatel@233 288 protected boolean hasSerializationOverviewTags(FieldDoc field) {
bpatel@222 289 TagletOutputImpl output = new TagletOutputImpl("");
bpatel@233 290 TagletWriter.genTagOuput(configuration.tagletManager, field,
bpatel@233 291 configuration.tagletManager.getCustomTags(field),
bpatel@222 292 getTagletWriterInstance(false), output);
bpatel@233 293 return (!output.toString().trim().isEmpty());
bpatel@222 294 }
bpatel@222 295
bpatel@222 296 /**
duke@1 297 * Returns a TagletWriter that knows how to write HTML.
duke@1 298 *
duke@1 299 * @return a TagletWriter that knows how to write HTML.
duke@1 300 */
duke@1 301 public TagletWriter getTagletWriterInstance(boolean isFirstSentence) {
duke@1 302 return new TagletWriterImpl(this, isFirstSentence);
duke@1 303 }
duke@1 304
duke@1 305 /**
bpatel@766 306 * Get Package link, with target frame.
duke@1 307 *
bpatel@766 308 * @param pd The link will be to the "package-summary.html" page for this package
bpatel@766 309 * @param target name of the target frame
bpatel@766 310 * @param label tag for the link
bpatel@766 311 * @return a content for the target package link
duke@1 312 */
bpatel@766 313 public Content getTargetPackageLink(PackageDoc pd, String target,
bpatel@766 314 Content label) {
bpatel@766 315 return getHyperLink(pathString(pd, "package-summary.html"), "", label, "", target);
duke@1 316 }
duke@1 317
duke@1 318 /**
bpatel@766 319 * Generates the HTML document tree and prints it out.
bpatel@766 320 *
bpatel@766 321 * @param metakeywords Array of String keywords for META tag. Each element
bpatel@766 322 * of the array is assigned to a separate META tag.
bpatel@766 323 * Pass in null for no array
bpatel@766 324 * @param includeScript true if printing windowtitle script
bpatel@766 325 * false for files that appear in the left-hand frames
bpatel@766 326 * @param body the body htmltree to be included in the document
bpatel@766 327 */
bpatel@766 328 public void printHtmlDocument(String[] metakeywords, boolean includeScript,
jjg@1364 329 Content body) throws IOException {
bpatel@766 330 Content htmlDocType = DocType.Transitional();
bpatel@766 331 Content htmlComment = new Comment(configuration.getText("doclet.New_Page"));
bpatel@766 332 Content head = new HtmlTree(HtmlTag.HEAD);
bpatel@766 333 if (!configuration.notimestamp) {
jjg@1361 334 Content headComment = new Comment(getGeneratedByString());
bpatel@766 335 head.addContent(headComment);
bpatel@766 336 }
bpatel@766 337 if (configuration.charset.length() > 0) {
bpatel@766 338 Content meta = HtmlTree.META("Content-Type", "text/html",
bpatel@766 339 configuration.charset);
bpatel@766 340 head.addContent(meta);
bpatel@766 341 }
bpatel@766 342 head.addContent(getTitle());
bpatel@766 343 if (!configuration.notimestamp) {
bpatel@766 344 SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
bpatel@766 345 Content meta = HtmlTree.META("date", dateFormat.format(new Date()));
bpatel@766 346 head.addContent(meta);
bpatel@766 347 }
bpatel@766 348 if (metakeywords != null) {
bpatel@766 349 for (int i=0; i < metakeywords.length; i++) {
bpatel@766 350 Content meta = HtmlTree.META("keywords", metakeywords[i]);
bpatel@766 351 head.addContent(meta);
bpatel@766 352 }
bpatel@766 353 }
bpatel@766 354 head.addContent(getStyleSheetProperties());
bpatel@766 355 Content htmlTree = HtmlTree.HTML(configuration.getLocale().getLanguage(),
bpatel@766 356 head, body);
bpatel@766 357 Content htmlDocument = new HtmlDocument(htmlDocType,
bpatel@766 358 htmlComment, htmlTree);
jjg@1365 359 write(htmlDocument);
bpatel@766 360 }
bpatel@766 361
bpatel@766 362 /**
bpatel@766 363 * Get the window title.
bpatel@766 364 *
bpatel@766 365 * @param title the title string to construct the complete window title
bpatel@766 366 * @return the window title string
bpatel@766 367 */
bpatel@766 368 public String getWindowTitle(String title) {
bpatel@766 369 if (configuration.windowtitle.length() > 0) {
bpatel@766 370 title += " (" + configuration.windowtitle + ")";
bpatel@766 371 }
bpatel@766 372 return title;
bpatel@766 373 }
bpatel@766 374
bpatel@766 375 /**
bpatel@766 376 * Get user specified header and the footer.
bpatel@766 377 *
bpatel@766 378 * @param header if true print the user provided header else print the
bpatel@766 379 * user provided footer.
bpatel@766 380 */
bpatel@766 381 public Content getUserHeaderFooter(boolean header) {
bpatel@766 382 String content;
bpatel@766 383 if (header) {
bpatel@766 384 content = replaceDocRootDir(configuration.header);
bpatel@766 385 } else {
bpatel@766 386 if (configuration.footer.length() != 0) {
bpatel@766 387 content = replaceDocRootDir(configuration.footer);
bpatel@766 388 } else {
bpatel@766 389 content = replaceDocRootDir(configuration.header);
bpatel@766 390 }
bpatel@766 391 }
bpatel@766 392 Content rawContent = new RawHtml(content);
bpatel@766 393 Content em = HtmlTree.EM(rawContent);
bpatel@766 394 return em;
bpatel@766 395 }
bpatel@766 396
bpatel@766 397 /**
bpatel@766 398 * Adds the user specified top.
bpatel@766 399 *
bpatel@766 400 * @param body the content tree to which user specified top will be added
bpatel@766 401 */
bpatel@766 402 public void addTop(Content body) {
bpatel@766 403 Content top = new RawHtml(replaceDocRootDir(configuration.top));
bpatel@766 404 body.addContent(top);
bpatel@766 405 }
bpatel@766 406
bpatel@766 407 /**
bpatel@766 408 * Adds the user specified bottom.
bpatel@766 409 *
bpatel@766 410 * @param body the content tree to which user specified bottom will be added
bpatel@766 411 */
bpatel@766 412 public void addBottom(Content body) {
bpatel@766 413 Content bottom = new RawHtml(replaceDocRootDir(configuration.bottom));
bpatel@766 414 Content small = HtmlTree.SMALL(bottom);
bpatel@766 415 Content p = HtmlTree.P(HtmlStyle.legalCopy, small);
bpatel@766 416 body.addContent(p);
bpatel@766 417 }
bpatel@766 418
bpatel@766 419 /**
bpatel@766 420 * Adds the navigation bar for the Html page at the top and and the bottom.
bpatel@766 421 *
bpatel@766 422 * @param header If true print navigation bar at the top of the page else
bpatel@766 423 * @param body the HtmlTree to which the nav links will be added
bpatel@766 424 */
bpatel@766 425 protected void addNavLinks(boolean header, Content body) {
bpatel@766 426 if (!configuration.nonavbar) {
bpatel@766 427 String allClassesId = "allclasses_";
bpatel@766 428 HtmlTree navDiv = new HtmlTree(HtmlTag.DIV);
bpatel@766 429 if (header) {
bpatel@766 430 body.addContent(HtmlConstants.START_OF_TOP_NAVBAR);
bpatel@766 431 navDiv.addStyle(HtmlStyle.topNav);
bpatel@766 432 allClassesId += "navbar_top";
bpatel@766 433 Content a = getMarkerAnchor("navbar_top");
bpatel@766 434 navDiv.addContent(a);
bpatel@766 435 Content skipLinkContent = getHyperLink("",
bpatel@766 436 "skip-navbar_top", HtmlTree.EMPTY, configuration.getText(
bpatel@766 437 "doclet.Skip_navigation_links"), "");
bpatel@766 438 navDiv.addContent(skipLinkContent);
bpatel@766 439 } else {
bpatel@766 440 body.addContent(HtmlConstants.START_OF_BOTTOM_NAVBAR);
bpatel@766 441 navDiv.addStyle(HtmlStyle.bottomNav);
bpatel@766 442 allClassesId += "navbar_bottom";
bpatel@766 443 Content a = getMarkerAnchor("navbar_bottom");
bpatel@766 444 navDiv.addContent(a);
bpatel@766 445 Content skipLinkContent = getHyperLink("",
bpatel@766 446 "skip-navbar_bottom", HtmlTree.EMPTY, configuration.getText(
bpatel@766 447 "doclet.Skip_navigation_links"), "");
bpatel@766 448 navDiv.addContent(skipLinkContent);
bpatel@766 449 }
bpatel@766 450 if (header) {
bpatel@766 451 navDiv.addContent(getMarkerAnchor("navbar_top_firstrow"));
bpatel@766 452 } else {
bpatel@766 453 navDiv.addContent(getMarkerAnchor("navbar_bottom_firstrow"));
bpatel@766 454 }
bpatel@766 455 HtmlTree navList = new HtmlTree(HtmlTag.UL);
bpatel@766 456 navList.addStyle(HtmlStyle.navList);
bpatel@766 457 navList.addAttr(HtmlAttr.TITLE, "Navigation");
bpatel@766 458 if (configuration.createoverview) {
bpatel@766 459 navList.addContent(getNavLinkContents());
bpatel@766 460 }
bpatel@766 461 if (configuration.packages.length == 1) {
bpatel@766 462 navList.addContent(getNavLinkPackage(configuration.packages[0]));
bpatel@766 463 } else if (configuration.packages.length > 1) {
bpatel@766 464 navList.addContent(getNavLinkPackage());
bpatel@766 465 }
bpatel@766 466 navList.addContent(getNavLinkClass());
bpatel@766 467 if(configuration.classuse) {
bpatel@766 468 navList.addContent(getNavLinkClassUse());
bpatel@766 469 }
bpatel@766 470 if(configuration.createtree) {
bpatel@766 471 navList.addContent(getNavLinkTree());
bpatel@766 472 }
bpatel@766 473 if(!(configuration.nodeprecated ||
bpatel@766 474 configuration.nodeprecatedlist)) {
bpatel@766 475 navList.addContent(getNavLinkDeprecated());
bpatel@766 476 }
bpatel@766 477 if(configuration.createindex) {
bpatel@766 478 navList.addContent(getNavLinkIndex());
bpatel@766 479 }
bpatel@766 480 if (!configuration.nohelp) {
bpatel@766 481 navList.addContent(getNavLinkHelp());
bpatel@766 482 }
bpatel@766 483 navDiv.addContent(navList);
bpatel@766 484 Content aboutDiv = HtmlTree.DIV(HtmlStyle.aboutLanguage, getUserHeaderFooter(header));
bpatel@766 485 navDiv.addContent(aboutDiv);
bpatel@766 486 body.addContent(navDiv);
bpatel@766 487 Content ulNav = HtmlTree.UL(HtmlStyle.navList, getNavLinkPrevious());
bpatel@766 488 ulNav.addContent(getNavLinkNext());
bpatel@766 489 Content subDiv = HtmlTree.DIV(HtmlStyle.subNav, ulNav);
bpatel@766 490 Content ulFrames = HtmlTree.UL(HtmlStyle.navList, getNavShowLists());
bpatel@766 491 ulFrames.addContent(getNavHideLists(filename));
bpatel@766 492 subDiv.addContent(ulFrames);
bpatel@766 493 HtmlTree ulAllClasses = HtmlTree.UL(HtmlStyle.navList, getNavLinkClassIndex());
bpatel@766 494 ulAllClasses.addAttr(HtmlAttr.ID, allClassesId.toString());
bpatel@766 495 subDiv.addContent(ulAllClasses);
bpatel@766 496 subDiv.addContent(getAllClassesLinkScript(allClassesId.toString()));
bpatel@766 497 addSummaryDetailLinks(subDiv);
bpatel@766 498 if (header) {
bpatel@766 499 subDiv.addContent(getMarkerAnchor("skip-navbar_top"));
bpatel@766 500 body.addContent(subDiv);
bpatel@766 501 body.addContent(HtmlConstants.END_OF_TOP_NAVBAR);
bpatel@766 502 } else {
bpatel@766 503 subDiv.addContent(getMarkerAnchor("skip-navbar_bottom"));
bpatel@766 504 body.addContent(subDiv);
bpatel@766 505 body.addContent(HtmlConstants.END_OF_BOTTOM_NAVBAR);
bpatel@766 506 }
bpatel@766 507 }
bpatel@766 508 }
bpatel@766 509
bpatel@766 510 /**
bpatel@766 511 * Get the word "NEXT" to indicate that no link is available. Override
bpatel@766 512 * this method to customize next link.
bpatel@766 513 *
bpatel@766 514 * @return a content tree for the link
bpatel@766 515 */
bpatel@766 516 protected Content getNavLinkNext() {
bpatel@766 517 return getNavLinkNext(null);
bpatel@766 518 }
bpatel@766 519
bpatel@766 520 /**
bpatel@766 521 * Get the word "PREV" to indicate that no link is available. Override
bpatel@766 522 * this method to customize prev link.
bpatel@766 523 *
bpatel@766 524 * @return a content tree for the link
bpatel@766 525 */
bpatel@766 526 protected Content getNavLinkPrevious() {
bpatel@766 527 return getNavLinkPrevious(null);
bpatel@766 528 }
bpatel@766 529
bpatel@766 530 /**
duke@1 531 * Do nothing. This is the default method.
duke@1 532 */
bpatel@766 533 protected void addSummaryDetailLinks(Content navDiv) {
bpatel@766 534 }
bpatel@766 535
bpatel@766 536 /**
bpatel@766 537 * Get link to the "overview-summary.html" page.
bpatel@766 538 *
bpatel@766 539 * @return a content tree for the link
bpatel@766 540 */
bpatel@766 541 protected Content getNavLinkContents() {
bpatel@766 542 Content linkContent = getHyperLink(relativePath +
bpatel@766 543 "overview-summary.html", "", overviewLabel, "", "");
bpatel@766 544 Content li = HtmlTree.LI(linkContent);
bpatel@766 545 return li;
bpatel@766 546 }
bpatel@766 547
bpatel@766 548 /**
bpatel@766 549 * Get link to the "package-summary.html" page for the package passed.
bpatel@766 550 *
bpatel@766 551 * @param pkg Package to which link will be generated
bpatel@766 552 * @return a content tree for the link
bpatel@766 553 */
bpatel@766 554 protected Content getNavLinkPackage(PackageDoc pkg) {
bpatel@766 555 Content linkContent = getPackageLink(pkg,
bpatel@766 556 packageLabel);
bpatel@766 557 Content li = HtmlTree.LI(linkContent);
bpatel@766 558 return li;
bpatel@766 559 }
bpatel@766 560
bpatel@766 561 /**
bpatel@766 562 * Get the word "Package" , to indicate that link is not available here.
bpatel@766 563 *
bpatel@766 564 * @return a content tree for the link
bpatel@766 565 */
bpatel@766 566 protected Content getNavLinkPackage() {
bpatel@766 567 Content li = HtmlTree.LI(packageLabel);
bpatel@766 568 return li;
bpatel@766 569 }
bpatel@766 570
bpatel@766 571 /**
bpatel@766 572 * Get the word "Use", to indicate that link is not available.
bpatel@766 573 *
bpatel@766 574 * @return a content tree for the link
bpatel@766 575 */
bpatel@766 576 protected Content getNavLinkClassUse() {
bpatel@766 577 Content li = HtmlTree.LI(useLabel);
bpatel@766 578 return li;
bpatel@766 579 }
bpatel@766 580
bpatel@766 581 /**
bpatel@766 582 * Get link for previous file.
bpatel@766 583 *
bpatel@766 584 * @param prev File name for the prev link
bpatel@766 585 * @return a content tree for the link
bpatel@766 586 */
bpatel@766 587 public Content getNavLinkPrevious(String prev) {
bpatel@766 588 Content li;
bpatel@766 589 if (prev != null) {
bpatel@766 590 li = HtmlTree.LI(getHyperLink(prev, "", prevLabel, "", ""));
bpatel@766 591 }
bpatel@766 592 else
bpatel@766 593 li = HtmlTree.LI(prevLabel);
bpatel@766 594 return li;
bpatel@766 595 }
bpatel@766 596
bpatel@766 597 /**
bpatel@766 598 * Get link for next file. If next is null, just print the label
bpatel@766 599 * without linking it anywhere.
bpatel@766 600 *
bpatel@766 601 * @param next File name for the next link
bpatel@766 602 * @return a content tree for the link
bpatel@766 603 */
bpatel@766 604 public Content getNavLinkNext(String next) {
bpatel@766 605 Content li;
bpatel@766 606 if (next != null) {
bpatel@766 607 li = HtmlTree.LI(getHyperLink(next, "", nextLabel, "", ""));
bpatel@766 608 }
bpatel@766 609 else
bpatel@766 610 li = HtmlTree.LI(nextLabel);
bpatel@766 611 return li;
bpatel@766 612 }
bpatel@766 613
bpatel@766 614 /**
bpatel@766 615 * Get "FRAMES" link, to switch to the frame version of the output.
bpatel@766 616 *
bpatel@766 617 * @param link File to be linked, "index.html"
bpatel@766 618 * @return a content tree for the link
bpatel@766 619 */
bpatel@766 620 protected Content getNavShowLists(String link) {
bpatel@766 621 Content framesContent = getHyperLink(link + "?" + path +
bpatel@766 622 filename, "", framesLabel, "", "_top");
bpatel@766 623 Content li = HtmlTree.LI(framesContent);
bpatel@766 624 return li;
bpatel@766 625 }
bpatel@766 626
bpatel@766 627 /**
bpatel@766 628 * Get "FRAMES" link, to switch to the frame version of the output.
bpatel@766 629 *
bpatel@766 630 * @return a content tree for the link
bpatel@766 631 */
bpatel@766 632 protected Content getNavShowLists() {
bpatel@766 633 return getNavShowLists(relativePath + "index.html");
bpatel@766 634 }
bpatel@766 635
bpatel@766 636 /**
bpatel@766 637 * Get "NO FRAMES" link, to switch to the non-frame version of the output.
bpatel@766 638 *
bpatel@766 639 * @param link File to be linked
bpatel@766 640 * @return a content tree for the link
bpatel@766 641 */
bpatel@766 642 protected Content getNavHideLists(String link) {
bpatel@766 643 Content noFramesContent = getHyperLink(link, "", noframesLabel, "", "_top");
bpatel@766 644 Content li = HtmlTree.LI(noFramesContent);
bpatel@766 645 return li;
bpatel@766 646 }
bpatel@766 647
bpatel@766 648 /**
bpatel@766 649 * Get "Tree" link in the navigation bar. If there is only one package
bpatel@766 650 * specified on the command line, then the "Tree" link will be to the
bpatel@766 651 * only "package-tree.html" file otherwise it will be to the
bpatel@766 652 * "overview-tree.html" file.
bpatel@766 653 *
bpatel@766 654 * @return a content tree for the link
duke@1 655 */
bpatel@766 656 protected Content getNavLinkTree() {
bpatel@766 657 Content treeLinkContent;
bpatel@766 658 PackageDoc[] packages = configuration.root.specifiedPackages();
bpatel@766 659 if (packages.length == 1 && configuration.root.specifiedClasses().length == 0) {
bpatel@766 660 treeLinkContent = getHyperLink(pathString(packages[0],
bpatel@766 661 "package-tree.html"), "", treeLabel,
bpatel@766 662 "", "");
bpatel@766 663 } else {
bpatel@766 664 treeLinkContent = getHyperLink(relativePath + "overview-tree.html",
bpatel@766 665 "", treeLabel, "", "");
bpatel@766 666 }
bpatel@766 667 Content li = HtmlTree.LI(treeLinkContent);
bpatel@766 668 return li;
bpatel@766 669 }
bpatel@766 670
bpatel@766 671 /**
bpatel@766 672 * Get the overview tree link for the main tree.
bpatel@766 673 *
bpatel@766 674 * @param label the label for the link
bpatel@766 675 * @return a content tree for the link
bpatel@766 676 */
bpatel@766 677 protected Content getNavLinkMainTree(String label) {
bpatel@766 678 Content mainTreeContent = getHyperLink(relativePath + "overview-tree.html",
bpatel@766 679 new StringContent(label));
bpatel@766 680 Content li = HtmlTree.LI(mainTreeContent);
bpatel@766 681 return li;
duke@1 682 }
duke@1 683
duke@1 684 /**
bpatel@766 685 * Get the word "Class", to indicate that class link is not available.
bpatel@766 686 *
bpatel@766 687 * @return a content tree for the link
bpatel@766 688 */
bpatel@766 689 protected Content getNavLinkClass() {
bpatel@766 690 Content li = HtmlTree.LI(classLabel);
bpatel@766 691 return li;
bpatel@766 692 }
bpatel@766 693
bpatel@766 694 /**
bpatel@766 695 * Get "Deprecated" API link in the navigation bar.
bpatel@766 696 *
bpatel@766 697 * @return a content tree for the link
bpatel@766 698 */
bpatel@766 699 protected Content getNavLinkDeprecated() {
bpatel@766 700 Content linkContent = getHyperLink(relativePath +
bpatel@766 701 "deprecated-list.html", "", deprecatedLabel, "", "");
bpatel@766 702 Content li = HtmlTree.LI(linkContent);
bpatel@766 703 return li;
bpatel@766 704 }
bpatel@766 705
bpatel@766 706 /**
bpatel@766 707 * Get link for generated index. If the user has used "-splitindex"
bpatel@766 708 * command line option, then link to file "index-files/index-1.html" is
bpatel@766 709 * generated otherwise link to file "index-all.html" is generated.
bpatel@766 710 *
bpatel@766 711 * @return a content tree for the link
bpatel@766 712 */
bpatel@766 713 protected Content getNavLinkClassIndex() {
bpatel@766 714 Content allClassesContent = getHyperLink(relativePath +
bpatel@766 715 AllClassesFrameWriter.OUTPUT_FILE_NAME_NOFRAMES, "",
bpatel@766 716 allclassesLabel, "", "");
bpatel@766 717 Content li = HtmlTree.LI(allClassesContent);
bpatel@766 718 return li;
bpatel@766 719 }
duke@1 720
duke@1 721 /**
bpatel@766 722 * Get link for generated class index.
bpatel@766 723 *
bpatel@766 724 * @return a content tree for the link
bpatel@766 725 */
bpatel@766 726 protected Content getNavLinkIndex() {
bpatel@766 727 Content linkContent = getHyperLink(relativePath +(configuration.splitindex?
bpatel@766 728 DirectoryManager.getPath("index-files") + fileseparator: "") +
bpatel@766 729 (configuration.splitindex?"index-1.html" : "index-all.html"), "",
bpatel@766 730 indexLabel, "", "");
bpatel@766 731 Content li = HtmlTree.LI(linkContent);
bpatel@766 732 return li;
bpatel@766 733 }
bpatel@766 734
bpatel@766 735 /**
bpatel@766 736 * Get help file link. If user has provided a help file, then generate a
bpatel@766 737 * link to the user given file, which is already copied to current or
bpatel@766 738 * destination directory.
bpatel@766 739 *
bpatel@766 740 * @return a content tree for the link
bpatel@766 741 */
bpatel@766 742 protected Content getNavLinkHelp() {
bpatel@766 743 String helpfilenm = configuration.helpfile;
bpatel@766 744 if (helpfilenm.equals("")) {
bpatel@766 745 helpfilenm = "help-doc.html";
bpatel@766 746 } else {
bpatel@766 747 int lastsep;
bpatel@766 748 if ((lastsep = helpfilenm.lastIndexOf(File.separatorChar)) != -1) {
bpatel@766 749 helpfilenm = helpfilenm.substring(lastsep + 1);
bpatel@766 750 }
bpatel@766 751 }
bpatel@766 752 Content linkContent = getHyperLink(relativePath + helpfilenm, "",
bpatel@766 753 helpLabel, "", "");
bpatel@766 754 Content li = HtmlTree.LI(linkContent);
bpatel@766 755 return li;
bpatel@766 756 }
bpatel@766 757
bpatel@766 758 /**
bpatel@766 759 * Get summary table header.
bpatel@766 760 *
bpatel@766 761 * @param header the header for the table
bpatel@766 762 * @param scope the scope of the headers
bpatel@766 763 * @return a content tree for the header
bpatel@766 764 */
bpatel@766 765 public Content getSummaryTableHeader(String[] header, String scope) {
bpatel@766 766 Content tr = new HtmlTree(HtmlTag.TR);
bpatel@766 767 int size = header.length;
bpatel@766 768 Content tableHeader;
bpatel@766 769 if (size == 1) {
bpatel@766 770 tableHeader = new StringContent(header[0]);
bpatel@766 771 tr.addContent(HtmlTree.TH(HtmlStyle.colOne, scope, tableHeader));
bpatel@766 772 return tr;
bpatel@766 773 }
bpatel@766 774 for (int i = 0; i < size; i++) {
bpatel@766 775 tableHeader = new StringContent(header[i]);
bpatel@766 776 if(i == 0)
bpatel@766 777 tr.addContent(HtmlTree.TH(HtmlStyle.colFirst, scope, tableHeader));
bpatel@766 778 else if(i == (size - 1))
bpatel@766 779 tr.addContent(HtmlTree.TH(HtmlStyle.colLast, scope, tableHeader));
bpatel@766 780 else
bpatel@766 781 tr.addContent(HtmlTree.TH(scope, tableHeader));
bpatel@766 782 }
bpatel@766 783 return tr;
bpatel@766 784 }
bpatel@766 785
bpatel@766 786 /**
bpatel@766 787 * Get table caption.
bpatel@766 788 *
bpatel@766 789 * @param rawText the caption for the table which could be raw Html
bpatel@766 790 * @return a content tree for the caption
bpatel@766 791 */
bpatel@766 792 public Content getTableCaption(String rawText) {
bpatel@766 793 Content title = new RawHtml(rawText);
bpatel@766 794 Content captionSpan = HtmlTree.SPAN(title);
bpatel@766 795 Content space = getSpace();
bpatel@766 796 Content tabSpan = HtmlTree.SPAN(HtmlStyle.tabEnd, space);
bpatel@766 797 Content caption = HtmlTree.CAPTION(captionSpan);
bpatel@766 798 caption.addContent(tabSpan);
bpatel@766 799 return caption;
bpatel@766 800 }
bpatel@766 801
bpatel@766 802 /**
bpatel@766 803 * Get the marker anchor which will be added to the documentation tree.
bpatel@766 804 *
bpatel@766 805 * @param anchorName the anchor name attribute
bpatel@766 806 * @return a content tree for the marker anchor
bpatel@766 807 */
bpatel@766 808 public Content getMarkerAnchor(String anchorName) {
bpatel@766 809 return getMarkerAnchor(anchorName, null);
bpatel@766 810 }
bpatel@766 811
bpatel@766 812 /**
bpatel@766 813 * Get the marker anchor which will be added to the documentation tree.
bpatel@766 814 *
bpatel@766 815 * @param anchorName the anchor name attribute
bpatel@766 816 * @param anchorContent the content that should be added to the anchor
bpatel@766 817 * @return a content tree for the marker anchor
bpatel@766 818 */
bpatel@766 819 public Content getMarkerAnchor(String anchorName, Content anchorContent) {
bpatel@766 820 if (anchorContent == null)
bpatel@766 821 anchorContent = new Comment(" ");
bpatel@766 822 Content markerAnchor = HtmlTree.A_NAME(anchorName, anchorContent);
bpatel@766 823 return markerAnchor;
bpatel@766 824 }
bpatel@766 825
bpatel@766 826 /**
bpatel@766 827 * Returns a packagename content.
bpatel@766 828 *
bpatel@766 829 * @param packageDoc the package to check
bpatel@766 830 * @return package name content
bpatel@766 831 */
bpatel@766 832 public Content getPackageName(PackageDoc packageDoc) {
bpatel@766 833 return packageDoc == null || packageDoc.name().length() == 0 ?
bpatel@766 834 defaultPackageLabel :
bpatel@766 835 getPackageLabel(packageDoc.name());
bpatel@766 836 }
bpatel@766 837
bpatel@766 838 /**
bpatel@766 839 * Returns a package name label.
bpatel@766 840 *
jjg@1358 841 * @param packageName the package name
bpatel@766 842 * @return the package name content
bpatel@766 843 */
bpatel@766 844 public Content getPackageLabel(String packageName) {
bpatel@766 845 return new StringContent(packageName);
bpatel@766 846 }
bpatel@766 847
bpatel@766 848 /**
bpatel@995 849 * Add package deprecation information to the documentation tree
bpatel@995 850 *
bpatel@995 851 * @param deprPkgs list of deprecated packages
bpatel@995 852 * @param headingKey the caption for the deprecated package table
bpatel@995 853 * @param tableSummary the summary for the deprecated package table
bpatel@995 854 * @param tableHeader table headers for the deprecated package table
bpatel@995 855 * @param contentTree the content tree to which the deprecated package table will be added
bpatel@995 856 */
bpatel@995 857 protected void addPackageDeprecatedAPI(List<Doc> deprPkgs, String headingKey,
bpatel@995 858 String tableSummary, String[] tableHeader, Content contentTree) {
bpatel@995 859 if (deprPkgs.size() > 0) {
bpatel@995 860 Content table = HtmlTree.TABLE(0, 3, 0, tableSummary,
bpatel@995 861 getTableCaption(configuration().getText(headingKey)));
bpatel@995 862 table.addContent(getSummaryTableHeader(tableHeader, "col"));
bpatel@995 863 Content tbody = new HtmlTree(HtmlTag.TBODY);
bpatel@995 864 for (int i = 0; i < deprPkgs.size(); i++) {
bpatel@995 865 PackageDoc pkg = (PackageDoc) deprPkgs.get(i);
bpatel@995 866 HtmlTree td = HtmlTree.TD(HtmlStyle.colOne,
bpatel@995 867 getPackageLink(pkg, getPackageName(pkg)));
bpatel@995 868 if (pkg.tags("deprecated").length > 0) {
bpatel@995 869 addInlineDeprecatedComment(pkg, pkg.tags("deprecated")[0], td);
bpatel@995 870 }
bpatel@995 871 HtmlTree tr = HtmlTree.TR(td);
bpatel@995 872 if (i % 2 == 0) {
bpatel@995 873 tr.addStyle(HtmlStyle.altColor);
bpatel@995 874 } else {
bpatel@995 875 tr.addStyle(HtmlStyle.rowColor);
bpatel@995 876 }
bpatel@995 877 tbody.addContent(tr);
bpatel@995 878 }
bpatel@995 879 table.addContent(tbody);
bpatel@995 880 Content li = HtmlTree.LI(HtmlStyle.blockList, table);
bpatel@995 881 Content ul = HtmlTree.UL(HtmlStyle.blockList, li);
bpatel@995 882 contentTree.addContent(ul);
bpatel@995 883 }
bpatel@995 884 }
bpatel@995 885
bpatel@995 886 /**
duke@1 887 * Return path to the class page for a classdoc. For example, the class
duke@1 888 * name is "java.lang.Object" and if the current file getting generated is
duke@1 889 * "java/io/File.html", then the path string to the class, returned is
duke@1 890 * "../../java/lang.Object.html".
duke@1 891 *
duke@1 892 * @param cd Class to which the path is requested.
duke@1 893 */
duke@1 894 protected String pathToClass(ClassDoc cd) {
duke@1 895 return pathString(cd.containingPackage(), cd.name() + ".html");
duke@1 896 }
duke@1 897
duke@1 898 /**
duke@1 899 * Return the path to the class page for a classdoc. Works same as
duke@1 900 * {@link #pathToClass(ClassDoc)}.
duke@1 901 *
duke@1 902 * @param cd Class to which the path is requested.
duke@1 903 * @param name Name of the file(doesn't include path).
duke@1 904 */
duke@1 905 protected String pathString(ClassDoc cd, String name) {
duke@1 906 return pathString(cd.containingPackage(), name);
duke@1 907 }
duke@1 908
duke@1 909 /**
duke@1 910 * Return path to the given file name in the given package. So if the name
duke@1 911 * passed is "Object.html" and the name of the package is "java.lang", and
duke@1 912 * if the relative path is "../.." then returned string will be
duke@1 913 * "../../java/lang/Object.html"
duke@1 914 *
duke@1 915 * @param pd Package in which the file name is assumed to be.
duke@1 916 * @param name File name, to which path string is.
duke@1 917 */
duke@1 918 protected String pathString(PackageDoc pd, String name) {
jjg@1362 919 StringBuilder buf = new StringBuilder(relativePath);
duke@1 920 buf.append(DirectoryManager.getPathToPackage(pd, name));
duke@1 921 return buf.toString();
duke@1 922 }
duke@1 923
duke@1 924 /**
duke@1 925 * Return the link to the given package.
duke@1 926 *
duke@1 927 * @param pkg the package to link to.
duke@1 928 * @param label the label for the link.
bpatel@182 929 * @param isStrong true if the label should be strong.
duke@1 930 * @return the link to the given package.
duke@1 931 */
bpatel@766 932 public String getPackageLinkString(PackageDoc pkg, String label,
bpatel@182 933 boolean isStrong) {
bpatel@766 934 return getPackageLinkString(pkg, label, isStrong, "");
duke@1 935 }
duke@1 936
duke@1 937 /**
duke@1 938 * Return the link to the given package.
duke@1 939 *
duke@1 940 * @param pkg the package to link to.
duke@1 941 * @param label the label for the link.
bpatel@182 942 * @param isStrong true if the label should be strong.
duke@1 943 * @param style the font of the package link label.
duke@1 944 * @return the link to the given package.
duke@1 945 */
bpatel@766 946 public String getPackageLinkString(PackageDoc pkg, String label, boolean isStrong,
duke@1 947 String style) {
duke@1 948 boolean included = pkg != null && pkg.isIncluded();
duke@1 949 if (! included) {
duke@1 950 PackageDoc[] packages = configuration.packages;
duke@1 951 for (int i = 0; i < packages.length; i++) {
duke@1 952 if (packages[i].equals(pkg)) {
duke@1 953 included = true;
duke@1 954 break;
duke@1 955 }
duke@1 956 }
duke@1 957 }
duke@1 958 if (included || pkg == null) {
bpatel@766 959 return getHyperLinkString(pathString(pkg, "package-summary.html"),
bpatel@182 960 "", label, isStrong, style);
duke@1 961 } else {
duke@1 962 String crossPkgLink = getCrossPackageLink(Util.getPackageName(pkg));
duke@1 963 if (crossPkgLink != null) {
bpatel@766 964 return getHyperLinkString(crossPkgLink, "", label, isStrong, style);
bpatel@766 965 } else {
bpatel@766 966 return label;
bpatel@766 967 }
bpatel@766 968 }
bpatel@766 969 }
bpatel@766 970
bpatel@766 971 /**
bpatel@766 972 * Return the link to the given package.
bpatel@766 973 *
bpatel@766 974 * @param pkg the package to link to.
bpatel@766 975 * @param label the label for the link.
bpatel@766 976 * @return a content tree for the package link.
bpatel@766 977 */
bpatel@766 978 public Content getPackageLink(PackageDoc pkg, Content label) {
bpatel@766 979 boolean included = pkg != null && pkg.isIncluded();
bpatel@766 980 if (! included) {
bpatel@766 981 PackageDoc[] packages = configuration.packages;
bpatel@766 982 for (int i = 0; i < packages.length; i++) {
bpatel@766 983 if (packages[i].equals(pkg)) {
bpatel@766 984 included = true;
bpatel@766 985 break;
bpatel@766 986 }
bpatel@766 987 }
bpatel@766 988 }
bpatel@766 989 if (included || pkg == null) {
bpatel@766 990 return getHyperLink(pathString(pkg, "package-summary.html"),
bpatel@766 991 "", label);
bpatel@766 992 } else {
bpatel@766 993 String crossPkgLink = getCrossPackageLink(Util.getPackageName(pkg));
bpatel@766 994 if (crossPkgLink != null) {
bpatel@766 995 return getHyperLink(crossPkgLink, "", label);
duke@1 996 } else {
duke@1 997 return label;
duke@1 998 }
duke@1 999 }
duke@1 1000 }
duke@1 1001
duke@1 1002 public String italicsClassName(ClassDoc cd, boolean qual) {
duke@1 1003 String name = (qual)? cd.qualifiedName(): cd.name();
duke@1 1004 return (cd.isInterface())? italicsText(name): name;
duke@1 1005 }
duke@1 1006
duke@1 1007 /**
bpatel@766 1008 * Add the link to the content tree.
bpatel@766 1009 *
bpatel@766 1010 * @param doc program element doc for which the link will be added
bpatel@766 1011 * @param label label for the link
bpatel@766 1012 * @param htmltree the content tree to which the link will be added
bpatel@766 1013 */
bpatel@766 1014 public void addSrcLink(ProgramElementDoc doc, Content label, Content htmltree) {
bpatel@766 1015 if (doc == null) {
bpatel@766 1016 return;
bpatel@766 1017 }
bpatel@766 1018 ClassDoc cd = doc.containingClass();
bpatel@766 1019 if (cd == null) {
bpatel@766 1020 //d must be a class doc since in has no containing class.
bpatel@766 1021 cd = (ClassDoc) doc;
bpatel@766 1022 }
bpatel@766 1023 String href = relativePath + DocletConstants.SOURCE_OUTPUT_DIR_NAME
bpatel@766 1024 + DirectoryManager.getDirectoryPath(cd.containingPackage())
bpatel@766 1025 + cd.name() + ".html#" + SourceToHTMLConverter.getAnchorName(doc);
bpatel@766 1026 Content linkContent = getHyperLink(href, "", label, "", "");
bpatel@766 1027 htmltree.addContent(linkContent);
bpatel@766 1028 }
bpatel@766 1029
bpatel@766 1030 /**
duke@1 1031 * Return the link to the given class.
duke@1 1032 *
duke@1 1033 * @param linkInfo the information about the link.
duke@1 1034 *
duke@1 1035 * @return the link for the given class.
duke@1 1036 */
duke@1 1037 public String getLink(LinkInfoImpl linkInfo) {
duke@1 1038 LinkFactoryImpl factory = new LinkFactoryImpl(this);
duke@1 1039 String link = ((LinkOutputImpl) factory.getLinkOutput(linkInfo)).toString();
duke@1 1040 displayLength += linkInfo.displayLength;
duke@1 1041 return link;
duke@1 1042 }
duke@1 1043
duke@1 1044 /**
duke@1 1045 * Return the type parameters for the given class.
duke@1 1046 *
duke@1 1047 * @param linkInfo the information about the link.
duke@1 1048 * @return the type for the given class.
duke@1 1049 */
duke@1 1050 public String getTypeParameterLinks(LinkInfoImpl linkInfo) {
duke@1 1051 LinkFactoryImpl factory = new LinkFactoryImpl(this);
duke@1 1052 return ((LinkOutputImpl)
duke@1 1053 factory.getTypeParameterLinks(linkInfo, false)).toString();
duke@1 1054 }
duke@1 1055
duke@1 1056 /*************************************************************
duke@1 1057 * Return a class cross link to external class documentation.
duke@1 1058 * The name must be fully qualified to determine which package
duke@1 1059 * the class is in. The -link option does not allow users to
duke@1 1060 * link to external classes in the "default" package.
duke@1 1061 *
duke@1 1062 * @param qualifiedClassName the qualified name of the external class.
duke@1 1063 * @param refMemName the name of the member being referenced. This should
duke@1 1064 * be null or empty string if no member is being referenced.
duke@1 1065 * @param label the label for the external link.
bpatel@182 1066 * @param strong true if the link should be strong.
duke@1 1067 * @param style the style of the link.
duke@1 1068 * @param code true if the label should be code font.
duke@1 1069 */
duke@1 1070 public String getCrossClassLink(String qualifiedClassName, String refMemName,
bpatel@182 1071 String label, boolean strong, String style,
duke@1 1072 boolean code) {
duke@1 1073 String className = "",
duke@1 1074 packageName = qualifiedClassName == null ? "" : qualifiedClassName;
duke@1 1075 int periodIndex;
duke@1 1076 while((periodIndex = packageName.lastIndexOf('.')) != -1) {
duke@1 1077 className = packageName.substring(periodIndex + 1, packageName.length()) +
duke@1 1078 (className.length() > 0 ? "." + className : "");
jjg@1365 1079 String defaultLabel = code ? codeText(className) : className;
duke@1 1080 packageName = packageName.substring(0, periodIndex);
duke@1 1081 if (getCrossPackageLink(packageName) != null) {
duke@1 1082 //The package exists in external documentation, so link to the external
duke@1 1083 //class (assuming that it exists). This is definitely a limitation of
duke@1 1084 //the -link option. There are ways to determine if an external package
duke@1 1085 //exists, but no way to determine if the external class exists. We just
duke@1 1086 //have to assume that it does.
bpatel@766 1087 return getHyperLinkString(
duke@1 1088 configuration.extern.getExternalLink(packageName, relativePath,
duke@1 1089 className + ".html?is-external=true"),
duke@1 1090 refMemName == null ? "" : refMemName,
duke@1 1091 label == null || label.length() == 0 ? defaultLabel : label,
bpatel@182 1092 strong, style,
duke@1 1093 configuration.getText("doclet.Href_Class_Or_Interface_Title", packageName),
duke@1 1094 "");
duke@1 1095 }
duke@1 1096 }
duke@1 1097 return null;
duke@1 1098 }
duke@1 1099
duke@1 1100 public boolean isClassLinkable(ClassDoc cd) {
duke@1 1101 if (cd.isIncluded()) {
duke@1 1102 return configuration.isGeneratedDoc(cd);
duke@1 1103 }
duke@1 1104 return configuration.extern.isExternal(cd);
duke@1 1105 }
duke@1 1106
duke@1 1107 public String getCrossPackageLink(String pkgName) {
duke@1 1108 return configuration.extern.getExternalLink(pkgName, relativePath,
duke@1 1109 "package-summary.html?is-external=true");
duke@1 1110 }
duke@1 1111
bpatel@766 1112 /**
bpatel@766 1113 * Get the class link.
bpatel@766 1114 *
bpatel@766 1115 * @param context the id of the context where the link will be added
bpatel@766 1116 * @param cd the class doc to link to
bpatel@766 1117 * @return a content tree for the link
bpatel@766 1118 */
bpatel@766 1119 public Content getQualifiedClassLink(int context, ClassDoc cd) {
bpatel@766 1120 return new RawHtml(getLink(new LinkInfoImpl(context, cd,
bpatel@766 1121 configuration.getClassName(cd), "")));
duke@1 1122 }
duke@1 1123
duke@1 1124 /**
bpatel@766 1125 * Add the class link.
bpatel@766 1126 *
bpatel@766 1127 * @param context the id of the context where the link will be added
bpatel@766 1128 * @param cd the class doc to link to
bpatel@766 1129 * @param contentTree the content tree to which the link will be added
duke@1 1130 */
bpatel@766 1131 public void addPreQualifiedClassLink(int context, ClassDoc cd, Content contentTree) {
bpatel@766 1132 addPreQualifiedClassLink(context, cd, false, contentTree);
duke@1 1133 }
duke@1 1134
duke@1 1135 /**
duke@1 1136 * Retrieve the class link with the package portion of the label in
duke@1 1137 * plain text. If the qualifier is excluded, it willnot be included in the
duke@1 1138 * link label.
duke@1 1139 *
duke@1 1140 * @param cd the class to link to.
bpatel@182 1141 * @param isStrong true if the link should be strong.
duke@1 1142 * @return the link with the package portion of the label in plain text.
duke@1 1143 */
duke@1 1144 public String getPreQualifiedClassLink(int context,
bpatel@182 1145 ClassDoc cd, boolean isStrong) {
duke@1 1146 String classlink = "";
duke@1 1147 PackageDoc pd = cd.containingPackage();
duke@1 1148 if(pd != null && ! configuration.shouldExcludeQualifier(pd.name())) {
duke@1 1149 classlink = getPkgName(cd);
duke@1 1150 }
bpatel@182 1151 classlink += getLink(new LinkInfoImpl(context, cd, cd.name(), isStrong));
duke@1 1152 return classlink;
duke@1 1153 }
duke@1 1154
bpatel@766 1155 /**
bpatel@766 1156 * Add the class link with the package portion of the label in
bpatel@766 1157 * plain text. If the qualifier is excluded, it will not be included in the
bpatel@766 1158 * link label.
bpatel@766 1159 *
bpatel@766 1160 * @param context the id of the context where the link will be added
bpatel@766 1161 * @param cd the class to link to
bpatel@766 1162 * @param isStrong true if the link should be strong
bpatel@766 1163 * @param contentTree the content tree to which the link with be added
bpatel@766 1164 */
bpatel@766 1165 public void addPreQualifiedClassLink(int context,
bpatel@766 1166 ClassDoc cd, boolean isStrong, Content contentTree) {
bpatel@766 1167 PackageDoc pd = cd.containingPackage();
bpatel@766 1168 if(pd != null && ! configuration.shouldExcludeQualifier(pd.name())) {
bpatel@766 1169 contentTree.addContent(getPkgName(cd));
bpatel@766 1170 }
bpatel@766 1171 contentTree.addContent(new RawHtml(getLink(new LinkInfoImpl(
bpatel@766 1172 context, cd, cd.name(), isStrong))));
bpatel@766 1173 }
duke@1 1174
duke@1 1175 /**
bpatel@766 1176 * Add the class link, with only class name as the strong link and prefixing
duke@1 1177 * plain package name.
bpatel@766 1178 *
bpatel@766 1179 * @param context the id of the context where the link will be added
bpatel@766 1180 * @param cd the class to link to
bpatel@766 1181 * @param contentTree the content tree to which the link with be added
duke@1 1182 */
bpatel@766 1183 public void addPreQualifiedStrongClassLink(int context, ClassDoc cd, Content contentTree) {
bpatel@766 1184 addPreQualifiedClassLink(context, cd, true, contentTree);
duke@1 1185 }
duke@1 1186
duke@1 1187 /**
bpatel@766 1188 * Get the link for the given member.
duke@1 1189 *
bpatel@766 1190 * @param context the id of the context where the link will be added
bpatel@766 1191 * @param doc the member being linked to
bpatel@766 1192 * @param label the label for the link
bpatel@766 1193 * @return a content tree for the doc link
duke@1 1194 */
bpatel@766 1195 public Content getDocLink(int context, MemberDoc doc, String label) {
bpatel@766 1196 return getDocLink(context, doc.containingClass(), doc, label);
duke@1 1197 }
duke@1 1198
duke@1 1199 /**
duke@1 1200 * Return the link for the given member.
duke@1 1201 *
duke@1 1202 * @param context the id of the context where the link will be printed.
duke@1 1203 * @param doc the member being linked to.
duke@1 1204 * @param label the label for the link.
bpatel@182 1205 * @param strong true if the link should be strong.
duke@1 1206 * @return the link for the given member.
duke@1 1207 */
duke@1 1208 public String getDocLink(int context, MemberDoc doc, String label,
bpatel@182 1209 boolean strong) {
bpatel@182 1210 return getDocLink(context, doc.containingClass(), doc, label, strong);
duke@1 1211 }
duke@1 1212
duke@1 1213 /**
duke@1 1214 * Return the link for the given member.
duke@1 1215 *
duke@1 1216 * @param context the id of the context where the link will be printed.
duke@1 1217 * @param classDoc the classDoc that we should link to. This is not
duke@1 1218 * necessarily equal to doc.containingClass(). We may be
duke@1 1219 * inheriting comments.
duke@1 1220 * @param doc the member being linked to.
duke@1 1221 * @param label the label for the link.
bpatel@182 1222 * @param strong true if the link should be strong.
duke@1 1223 * @return the link for the given member.
duke@1 1224 */
duke@1 1225 public String getDocLink(int context, ClassDoc classDoc, MemberDoc doc,
bpatel@182 1226 String label, boolean strong) {
duke@1 1227 if (! (doc.isIncluded() ||
duke@1 1228 Util.isLinkable(classDoc, configuration()))) {
duke@1 1229 return label;
duke@1 1230 } else if (doc instanceof ExecutableMemberDoc) {
duke@1 1231 ExecutableMemberDoc emd = (ExecutableMemberDoc)doc;
duke@1 1232 return getLink(new LinkInfoImpl(context, classDoc,
bpatel@182 1233 getAnchor(emd), label, strong));
duke@1 1234 } else if (doc instanceof MemberDoc) {
duke@1 1235 return getLink(new LinkInfoImpl(context, classDoc,
bpatel@182 1236 doc.name(), label, strong));
duke@1 1237 } else {
duke@1 1238 return label;
duke@1 1239 }
duke@1 1240 }
duke@1 1241
bpatel@766 1242 /**
bpatel@766 1243 * Return the link for the given member.
bpatel@766 1244 *
bpatel@766 1245 * @param context the id of the context where the link will be added
bpatel@766 1246 * @param classDoc the classDoc that we should link to. This is not
bpatel@766 1247 * necessarily equal to doc.containingClass(). We may be
bpatel@766 1248 * inheriting comments
bpatel@766 1249 * @param doc the member being linked to
bpatel@766 1250 * @param label the label for the link
bpatel@766 1251 * @return the link for the given member
bpatel@766 1252 */
bpatel@766 1253 public Content getDocLink(int context, ClassDoc classDoc, MemberDoc doc,
bpatel@766 1254 String label) {
bpatel@766 1255 if (! (doc.isIncluded() ||
bpatel@766 1256 Util.isLinkable(classDoc, configuration()))) {
bpatel@766 1257 return new StringContent(label);
bpatel@766 1258 } else if (doc instanceof ExecutableMemberDoc) {
bpatel@766 1259 ExecutableMemberDoc emd = (ExecutableMemberDoc)doc;
bpatel@766 1260 return new RawHtml(getLink(new LinkInfoImpl(context, classDoc,
bpatel@766 1261 getAnchor(emd), label, false)));
bpatel@766 1262 } else if (doc instanceof MemberDoc) {
bpatel@766 1263 return new RawHtml(getLink(new LinkInfoImpl(context, classDoc,
bpatel@766 1264 doc.name(), label, false)));
bpatel@766 1265 } else {
bpatel@766 1266 return new StringContent(label);
bpatel@766 1267 }
bpatel@766 1268 }
bpatel@766 1269
duke@1 1270 public String getAnchor(ExecutableMemberDoc emd) {
duke@1 1271 StringBuilder signature = new StringBuilder(emd.signature());
duke@1 1272 StringBuilder signatureParsed = new StringBuilder();
duke@1 1273 int counter = 0;
duke@1 1274 for (int i = 0; i < signature.length(); i++) {
duke@1 1275 char c = signature.charAt(i);
duke@1 1276 if (c == '<') {
duke@1 1277 counter++;
duke@1 1278 } else if (c == '>') {
duke@1 1279 counter--;
duke@1 1280 } else if (counter == 0) {
duke@1 1281 signatureParsed.append(c);
duke@1 1282 }
duke@1 1283 }
duke@1 1284 return emd.name() + signatureParsed.toString();
duke@1 1285 }
duke@1 1286
duke@1 1287 public String seeTagToString(SeeTag see) {
duke@1 1288 String tagName = see.name();
duke@1 1289 if (! (tagName.startsWith("@link") || tagName.equals("@see"))) {
duke@1 1290 return "";
duke@1 1291 }
jjg@1365 1292
duke@1 1293 String seetext = replaceDocRootDir(see.text());
duke@1 1294
duke@1 1295 //Check if @see is an href or "string"
duke@1 1296 if (seetext.startsWith("<") || seetext.startsWith("\"")) {
jjg@1365 1297 return seetext;
duke@1 1298 }
duke@1 1299
jjg@1365 1300 boolean plain = tagName.equalsIgnoreCase("@linkplain");
jjg@1365 1301 String label = plainOrCodeText(plain, see.label());
jjg@1365 1302
duke@1 1303 //The text from the @see tag. We will output this text when a label is not specified.
jjg@1365 1304 String text = plainOrCodeText(plain, seetext);
duke@1 1305
duke@1 1306 ClassDoc refClass = see.referencedClass();
duke@1 1307 String refClassName = see.referencedClassName();
duke@1 1308 MemberDoc refMem = see.referencedMember();
duke@1 1309 String refMemName = see.referencedMemberName();
jjg@1365 1310
duke@1 1311 if (refClass == null) {
duke@1 1312 //@see is not referencing an included class
duke@1 1313 PackageDoc refPackage = see.referencedPackage();
duke@1 1314 if (refPackage != null && refPackage.isIncluded()) {
duke@1 1315 //@see is referencing an included package
jjg@1365 1316 if (label.isEmpty())
jjg@1365 1317 label = plainOrCodeText(plain, refPackage.name());
jjg@1365 1318 return getPackageLinkString(refPackage, label, false);
duke@1 1319 } else {
duke@1 1320 //@see is not referencing an included class or package. Check for cross links.
duke@1 1321 String classCrossLink, packageCrossLink = getCrossPackageLink(refClassName);
duke@1 1322 if (packageCrossLink != null) {
duke@1 1323 //Package cross link found
jjg@1365 1324 return getHyperLinkString(packageCrossLink, "",
jjg@1365 1325 (label.isEmpty() ? text : label), false);
duke@1 1326 } else if ((classCrossLink = getCrossClassLink(refClassName,
jjg@1365 1327 refMemName, label, false, "", !plain)) != null) {
jjg@1365 1328 //Class cross link found (possibly to a member in the class)
jjg@1365 1329 return classCrossLink;
duke@1 1330 } else {
duke@1 1331 //No cross link found so print warning
duke@1 1332 configuration.getDocletSpecificMsg().warning(see.position(), "doclet.see.class_or_package_not_found",
duke@1 1333 tagName, seetext);
jjg@1365 1334 return (label.isEmpty() ? text: label);
duke@1 1335 }
duke@1 1336 }
duke@1 1337 } else if (refMemName == null) {
duke@1 1338 // Must be a class reference since refClass is not null and refMemName is null.
jjg@1365 1339 if (label.isEmpty()) {
jjg@1365 1340 label = plainOrCodeText(plain, refClass.name());
duke@1 1341 }
jjg@1365 1342 return getLink(new LinkInfoImpl(refClass, label));
duke@1 1343 } else if (refMem == null) {
duke@1 1344 // Must be a member reference since refClass is not null and refMemName is not null.
duke@1 1345 // However, refMem is null, so this referenced member does not exist.
jjg@1365 1346 return (label.isEmpty() ? text: label);
duke@1 1347 } else {
duke@1 1348 // Must be a member reference since refClass is not null and refMemName is not null.
duke@1 1349 // refMem is not null, so this @see tag must be referencing a valid member.
duke@1 1350 ClassDoc containing = refMem.containingClass();
duke@1 1351 if (see.text().trim().startsWith("#") &&
duke@1 1352 ! (containing.isPublic() ||
duke@1 1353 Util.isLinkable(containing, configuration()))) {
duke@1 1354 // Since the link is relative and the holder is not even being
duke@1 1355 // documented, this must be an inherited link. Redirect it.
duke@1 1356 // The current class either overrides the referenced member or
duke@1 1357 // inherits it automatically.
jjg@405 1358 if (this instanceof ClassWriterImpl) {
jjg@405 1359 containing = ((ClassWriterImpl) this).getClassDoc();
jjg@405 1360 } else if (!containing.isPublic()){
jjg@405 1361 configuration.getDocletSpecificMsg().warning(
jjg@405 1362 see.position(), "doclet.see.class_or_package_not_accessible",
jjg@405 1363 tagName, containing.qualifiedName());
jjg@405 1364 } else {
jjg@405 1365 configuration.getDocletSpecificMsg().warning(
jjg@405 1366 see.position(), "doclet.see.class_or_package_not_found",
jjg@405 1367 tagName, seetext);
jjg@405 1368 }
duke@1 1369 }
duke@1 1370 if (configuration.currentcd != containing) {
duke@1 1371 refMemName = containing.name() + "." + refMemName;
duke@1 1372 }
duke@1 1373 if (refMem instanceof ExecutableMemberDoc) {
duke@1 1374 if (refMemName.indexOf('(') < 0) {
duke@1 1375 refMemName += ((ExecutableMemberDoc)refMem).signature();
duke@1 1376 }
duke@1 1377 }
duke@1 1378
jjg@1365 1379 text = plainOrCodeText(plain, Util.escapeHtmlChars(refMemName));
jjg@1365 1380
jjg@1365 1381 return getDocLink(LinkInfoImpl.CONTEXT_SEE_TAG, containing,
jjg@1365 1382 refMem, (label.isEmpty() ? text: label), false);
duke@1 1383 }
duke@1 1384 }
duke@1 1385
jjg@1365 1386 private String plainOrCodeText(boolean plain, String text) {
jjg@1365 1387 return (plain || text.isEmpty()) ? text : codeText(text);
duke@1 1388 }
duke@1 1389
bpatel@766 1390 /**
bpatel@766 1391 * Add the inline comment.
bpatel@766 1392 *
bpatel@766 1393 * @param doc the doc for which the inline comment will be added
bpatel@766 1394 * @param tag the inline tag to be added
bpatel@766 1395 * @param htmltree the content tree to which the comment will be added
bpatel@766 1396 */
bpatel@766 1397 public void addInlineComment(Doc doc, Tag tag, Content htmltree) {
bpatel@766 1398 addCommentTags(doc, tag.inlineTags(), false, false, htmltree);
bpatel@766 1399 }
bpatel@766 1400
bpatel@766 1401 /**
bpatel@766 1402 * Add the inline deprecated comment.
bpatel@766 1403 *
bpatel@766 1404 * @param doc the doc for which the inline deprecated comment will be added
bpatel@766 1405 * @param tag the inline tag to be added
bpatel@766 1406 * @param htmltree the content tree to which the comment will be added
bpatel@766 1407 */
bpatel@766 1408 public void addInlineDeprecatedComment(Doc doc, Tag tag, Content htmltree) {
bpatel@766 1409 addCommentTags(doc, tag.inlineTags(), true, false, htmltree);
bpatel@766 1410 }
bpatel@766 1411
bpatel@766 1412 /**
bpatel@766 1413 * Adds the summary content.
bpatel@766 1414 *
bpatel@766 1415 * @param doc the doc for which the summary will be generated
bpatel@766 1416 * @param htmltree the documentation tree to which the summary will be added
bpatel@766 1417 */
bpatel@766 1418 public void addSummaryComment(Doc doc, Content htmltree) {
bpatel@766 1419 addSummaryComment(doc, doc.firstSentenceTags(), htmltree);
bpatel@766 1420 }
bpatel@766 1421
bpatel@766 1422 /**
bpatel@766 1423 * Adds the summary content.
bpatel@766 1424 *
bpatel@766 1425 * @param doc the doc for which the summary will be generated
bpatel@766 1426 * @param firstSentenceTags the first sentence tags for the doc
bpatel@766 1427 * @param htmltree the documentation tree to which the summary will be added
bpatel@766 1428 */
bpatel@766 1429 public void addSummaryComment(Doc doc, Tag[] firstSentenceTags, Content htmltree) {
bpatel@766 1430 addCommentTags(doc, firstSentenceTags, false, true, htmltree);
bpatel@766 1431 }
bpatel@766 1432
bpatel@766 1433 public void addSummaryDeprecatedComment(Doc doc, Tag tag, Content htmltree) {
bpatel@766 1434 addCommentTags(doc, tag.firstSentenceTags(), true, true, htmltree);
bpatel@766 1435 }
bpatel@766 1436
bpatel@766 1437 /**
bpatel@766 1438 * Adds the inline comment.
bpatel@766 1439 *
bpatel@766 1440 * @param doc the doc for which the inline comments will be generated
bpatel@766 1441 * @param htmltree the documentation tree to which the inline comments will be added
bpatel@766 1442 */
bpatel@766 1443 public void addInlineComment(Doc doc, Content htmltree) {
bpatel@766 1444 addCommentTags(doc, doc.inlineTags(), false, false, htmltree);
bpatel@766 1445 }
bpatel@766 1446
duke@1 1447 /**
bpatel@766 1448 * Adds the comment tags.
bpatel@766 1449 *
bpatel@766 1450 * @param doc the doc for which the comment tags will be generated
bpatel@766 1451 * @param tags the first sentence tags for the doc
bpatel@766 1452 * @param depr true if it is deprecated
bpatel@766 1453 * @param first true if the first sentenge tags should be added
bpatel@766 1454 * @param htmltree the documentation tree to which the comment tags will be added
bpatel@766 1455 */
bpatel@766 1456 private void addCommentTags(Doc doc, Tag[] tags, boolean depr,
bpatel@766 1457 boolean first, Content htmltree) {
bpatel@766 1458 if(configuration.nocomment){
bpatel@766 1459 return;
bpatel@766 1460 }
bpatel@766 1461 Content div;
bpatel@766 1462 Content result = new RawHtml(commentTagsToString(null, doc, tags, first));
bpatel@766 1463 if (depr) {
bpatel@766 1464 Content italic = HtmlTree.I(result);
bpatel@766 1465 div = HtmlTree.DIV(HtmlStyle.block, italic);
bpatel@766 1466 htmltree.addContent(div);
bpatel@766 1467 }
bpatel@766 1468 else {
bpatel@766 1469 div = HtmlTree.DIV(HtmlStyle.block, result);
bpatel@766 1470 htmltree.addContent(div);
bpatel@766 1471 }
bpatel@766 1472 if (tags.length == 0) {
bpatel@766 1473 htmltree.addContent(getSpace());
bpatel@766 1474 }
bpatel@766 1475 }
bpatel@766 1476
bpatel@766 1477 /**
duke@1 1478 * Converts inline tags and text to text strings, expanding the
duke@1 1479 * inline tags along the way. Called wherever text can contain
duke@1 1480 * an inline tag, such as in comments or in free-form text arguments
duke@1 1481 * to non-inline tags.
duke@1 1482 *
duke@1 1483 * @param holderTag specific tag where comment resides
duke@1 1484 * @param doc specific doc where comment resides
duke@1 1485 * @param tags array of text tags and inline tags (often alternating)
duke@1 1486 * present in the text of interest for this doc
duke@1 1487 * @param isFirstSentence true if text is first sentence
duke@1 1488 */
duke@1 1489 public String commentTagsToString(Tag holderTag, Doc doc, Tag[] tags,
duke@1 1490 boolean isFirstSentence) {
jjg@910 1491 StringBuilder result = new StringBuilder();
bpatel@997 1492 boolean textTagChange = false;
duke@1 1493 // Array of all possible inline tags for this javadoc run
duke@1 1494 configuration.tagletManager.checkTags(doc, tags, true);
duke@1 1495 for (int i = 0; i < tags.length; i++) {
duke@1 1496 Tag tagelem = tags[i];
duke@1 1497 String tagName = tagelem.name();
duke@1 1498 if (tagelem instanceof SeeTag) {
duke@1 1499 result.append(seeTagToString((SeeTag)tagelem));
duke@1 1500 } else if (! tagName.equals("Text")) {
duke@1 1501 int originalLength = result.length();
duke@1 1502 TagletOutput output = TagletWriter.getInlineTagOuput(
duke@1 1503 configuration.tagletManager, holderTag,
jjg@74 1504 tagelem, getTagletWriterInstance(isFirstSentence));
duke@1 1505 result.append(output == null ? "" : output.toString());
duke@1 1506 if (originalLength == 0 && isFirstSentence && tagelem.name().equals("@inheritDoc") && result.length() > 0) {
duke@1 1507 break;
bpatel@997 1508 } else if (configuration.docrootparent.length() > 0 &&
bpatel@997 1509 tagelem.name().equals("@docRoot") &&
bpatel@997 1510 ((tags[i + 1]).text()).startsWith("/..")) {
bpatel@997 1511 //If Xdocrootparent switch ON, set the flag to remove the /.. occurance after
bpatel@997 1512 //{@docRoot} tag in the very next Text tag.
bpatel@997 1513 textTagChange = true;
bpatel@997 1514 continue;
duke@1 1515 } else {
bpatel@997 1516 continue;
duke@1 1517 }
duke@1 1518 } else {
bpatel@997 1519 String text = tagelem.text();
bpatel@997 1520 //If Xdocrootparent switch ON, remove the /.. occurance after {@docRoot} tag.
bpatel@997 1521 if (textTagChange) {
bpatel@997 1522 text = text.replaceFirst("/..", "");
bpatel@997 1523 textTagChange = false;
bpatel@997 1524 }
duke@1 1525 //This is just a regular text tag. The text may contain html links (<a>)
duke@1 1526 //or inline tag {@docRoot}, which will be handled as special cases.
bpatel@997 1527 text = redirectRelativeLinks(tagelem.holder(), text);
duke@1 1528
duke@1 1529 // Replace @docRoot only if not represented by an instance of DocRootTaglet,
duke@1 1530 // that is, only if it was not present in a source file doc comment.
duke@1 1531 // This happens when inserted by the doclet (a few lines
duke@1 1532 // above in this method). [It might also happen when passed in on the command
duke@1 1533 // line as a text argument to an option (like -header).]
duke@1 1534 text = replaceDocRootDir(text);
duke@1 1535 if (isFirstSentence) {
duke@1 1536 text = removeNonInlineHtmlTags(text);
duke@1 1537 }
duke@1 1538 StringTokenizer lines = new StringTokenizer(text, "\r\n", true);
jjg@1362 1539 StringBuilder textBuff = new StringBuilder();
duke@1 1540 while (lines.hasMoreTokens()) {
jjg@910 1541 StringBuilder line = new StringBuilder(lines.nextToken());
duke@1 1542 Util.replaceTabs(configuration.sourcetab, line);
duke@1 1543 textBuff.append(line.toString());
duke@1 1544 }
duke@1 1545 result.append(textBuff);
duke@1 1546 }
duke@1 1547 }
duke@1 1548 return result.toString();
duke@1 1549 }
duke@1 1550
duke@1 1551 /**
duke@1 1552 * Return true if relative links should not be redirected.
duke@1 1553 *
duke@1 1554 * @return Return true if a relative link should not be redirected.
duke@1 1555 */
duke@1 1556 private boolean shouldNotRedirectRelativeLinks() {
duke@1 1557 return this instanceof AnnotationTypeWriter ||
duke@1 1558 this instanceof ClassWriter ||
duke@1 1559 this instanceof PackageSummaryWriter;
duke@1 1560 }
duke@1 1561
duke@1 1562 /**
duke@1 1563 * Suppose a piece of documentation has a relative link. When you copy
duke@1 1564 * that documetation to another place such as the index or class-use page,
duke@1 1565 * that relative link will no longer work. We should redirect those links
duke@1 1566 * so that they will work again.
duke@1 1567 * <p>
duke@1 1568 * Here is the algorithm used to fix the link:
duke@1 1569 * <p>
jjg@1326 1570 * {@literal <relative link> => docRoot + <relative path to file> + <relative link> }
duke@1 1571 * <p>
duke@1 1572 * For example, suppose com.sun.javadoc.RootDoc has this link:
jjg@1326 1573 * {@literal <a href="package-summary.html">The package Page</a> }
duke@1 1574 * <p>
duke@1 1575 * If this link appeared in the index, we would redirect
duke@1 1576 * the link like this:
duke@1 1577 *
jjg@1326 1578 * {@literal <a href="./com/sun/javadoc/package-summary.html">The package Page</a>}
duke@1 1579 *
duke@1 1580 * @param doc the Doc object whose documentation is being written.
duke@1 1581 * @param text the text being written.
duke@1 1582 *
duke@1 1583 * @return the text, with all the relative links redirected to work.
duke@1 1584 */
duke@1 1585 private String redirectRelativeLinks(Doc doc, String text) {
duke@1 1586 if (doc == null || shouldNotRedirectRelativeLinks()) {
duke@1 1587 return text;
duke@1 1588 }
duke@1 1589
duke@1 1590 String redirectPathFromRoot;
duke@1 1591 if (doc instanceof ClassDoc) {
duke@1 1592 redirectPathFromRoot = DirectoryManager.getDirectoryPath(((ClassDoc) doc).containingPackage());
duke@1 1593 } else if (doc instanceof MemberDoc) {
duke@1 1594 redirectPathFromRoot = DirectoryManager.getDirectoryPath(((MemberDoc) doc).containingPackage());
duke@1 1595 } else if (doc instanceof PackageDoc) {
duke@1 1596 redirectPathFromRoot = DirectoryManager.getDirectoryPath((PackageDoc) doc);
duke@1 1597 } else {
duke@1 1598 return text;
duke@1 1599 }
duke@1 1600
bpatel@766 1601 if (! redirectPathFromRoot.endsWith(DirectoryManager.URL_FILE_SEPARATOR)) {
bpatel@766 1602 redirectPathFromRoot += DirectoryManager.URL_FILE_SEPARATOR;
duke@1 1603 }
duke@1 1604
duke@1 1605 //Redirect all relative links.
duke@1 1606 int end, begin = text.toLowerCase().indexOf("<a");
duke@1 1607 if(begin >= 0){
jjg@1362 1608 StringBuilder textBuff = new StringBuilder(text);
duke@1 1609
duke@1 1610 while(begin >=0){
duke@1 1611 if (textBuff.length() > begin + 2 && ! Character.isWhitespace(textBuff.charAt(begin+2))) {
duke@1 1612 begin = textBuff.toString().toLowerCase().indexOf("<a", begin + 1);
duke@1 1613 continue;
duke@1 1614 }
duke@1 1615
duke@1 1616 begin = textBuff.indexOf("=", begin) + 1;
duke@1 1617 end = textBuff.indexOf(">", begin +1);
duke@1 1618 if(begin == 0){
duke@1 1619 //Link has no equal symbol.
duke@1 1620 configuration.root.printWarning(
duke@1 1621 doc.position(),
duke@1 1622 configuration.getText("doclet.malformed_html_link_tag", text));
duke@1 1623 break;
duke@1 1624 }
duke@1 1625 if (end == -1) {
duke@1 1626 //Break without warning. This <a> tag is not necessarily malformed. The text
duke@1 1627 //might be missing '>' character because the href has an inline tag.
duke@1 1628 break;
duke@1 1629 }
duke@1 1630 if(textBuff.substring(begin, end).indexOf("\"") != -1){
duke@1 1631 begin = textBuff.indexOf("\"", begin) + 1;
duke@1 1632 end = textBuff.indexOf("\"", begin +1);
duke@1 1633 if(begin == 0 || end == -1){
duke@1 1634 //Link is missing a quote.
duke@1 1635 break;
duke@1 1636 }
duke@1 1637 }
duke@1 1638 String relativeLink = textBuff.substring(begin, end);
duke@1 1639 if(!(relativeLink.toLowerCase().startsWith("mailto:") ||
duke@1 1640 relativeLink.toLowerCase().startsWith("http:") ||
duke@1 1641 relativeLink.toLowerCase().startsWith("https:") ||
duke@1 1642 relativeLink.toLowerCase().startsWith("file:"))){
duke@1 1643 relativeLink = "{@"+(new DocRootTaglet()).getName() + "}"
duke@1 1644 + redirectPathFromRoot
duke@1 1645 + relativeLink;
duke@1 1646 textBuff.replace(begin, end, relativeLink);
duke@1 1647 }
duke@1 1648 begin = textBuff.toString().toLowerCase().indexOf("<a", begin + 1);
duke@1 1649 }
duke@1 1650 return textBuff.toString();
duke@1 1651 }
duke@1 1652 return text;
duke@1 1653 }
duke@1 1654
duke@1 1655 public String removeNonInlineHtmlTags(String text) {
duke@1 1656 if (text.indexOf('<') < 0) {
duke@1 1657 return text;
duke@1 1658 }
duke@1 1659 String noninlinetags[] = { "<ul>", "</ul>", "<ol>", "</ol>",
duke@1 1660 "<dl>", "</dl>", "<table>", "</table>",
duke@1 1661 "<tr>", "</tr>", "<td>", "</td>",
duke@1 1662 "<th>", "</th>", "<p>", "</p>",
duke@1 1663 "<li>", "</li>", "<dd>", "</dd>",
duke@1 1664 "<dir>", "</dir>", "<dt>", "</dt>",
duke@1 1665 "<h1>", "</h1>", "<h2>", "</h2>",
duke@1 1666 "<h3>", "</h3>", "<h4>", "</h4>",
duke@1 1667 "<h5>", "</h5>", "<h6>", "</h6>",
duke@1 1668 "<pre>", "</pre>", "<menu>", "</menu>",
duke@1 1669 "<listing>", "</listing>", "<hr>",
duke@1 1670 "<blockquote>", "</blockquote>",
duke@1 1671 "<center>", "</center>",
duke@1 1672 "<UL>", "</UL>", "<OL>", "</OL>",
duke@1 1673 "<DL>", "</DL>", "<TABLE>", "</TABLE>",
duke@1 1674 "<TR>", "</TR>", "<TD>", "</TD>",
duke@1 1675 "<TH>", "</TH>", "<P>", "</P>",
duke@1 1676 "<LI>", "</LI>", "<DD>", "</DD>",
duke@1 1677 "<DIR>", "</DIR>", "<DT>", "</DT>",
duke@1 1678 "<H1>", "</H1>", "<H2>", "</H2>",
duke@1 1679 "<H3>", "</H3>", "<H4>", "</H4>",
duke@1 1680 "<H5>", "</H5>", "<H6>", "</H6>",
duke@1 1681 "<PRE>", "</PRE>", "<MENU>", "</MENU>",
duke@1 1682 "<LISTING>", "</LISTING>", "<HR>",
duke@1 1683 "<BLOCKQUOTE>", "</BLOCKQUOTE>",
duke@1 1684 "<CENTER>", "</CENTER>"
duke@1 1685 };
duke@1 1686 for (int i = 0; i < noninlinetags.length; i++) {
duke@1 1687 text = replace(text, noninlinetags[i], "");
duke@1 1688 }
duke@1 1689 return text;
duke@1 1690 }
duke@1 1691
duke@1 1692 public String replace(String text, String tobe, String by) {
duke@1 1693 while (true) {
duke@1 1694 int startindex = text.indexOf(tobe);
duke@1 1695 if (startindex < 0) {
duke@1 1696 return text;
duke@1 1697 }
duke@1 1698 int endindex = startindex + tobe.length();
jjg@910 1699 StringBuilder replaced = new StringBuilder();
duke@1 1700 if (startindex > 0) {
duke@1 1701 replaced.append(text.substring(0, startindex));
duke@1 1702 }
duke@1 1703 replaced.append(by);
duke@1 1704 if (text.length() > endindex) {
duke@1 1705 replaced.append(text.substring(endindex));
duke@1 1706 }
duke@1 1707 text = replaced.toString();
duke@1 1708 }
duke@1 1709 }
duke@1 1710
duke@1 1711 /**
bpatel@766 1712 * Returns a link to the stylesheet file.
bpatel@766 1713 *
bpatel@766 1714 * @return an HtmlTree for the lINK tag which provides the stylesheet location
bpatel@766 1715 */
bpatel@766 1716 public HtmlTree getStyleSheetProperties() {
bpatel@766 1717 String filename = configuration.stylesheetfile;
bpatel@766 1718 if (filename.length() > 0) {
bpatel@766 1719 File stylefile = new File(filename);
bpatel@766 1720 String parent = stylefile.getParent();
bpatel@766 1721 filename = (parent == null)?
bpatel@766 1722 filename:
bpatel@766 1723 filename.substring(parent.length() + 1);
bpatel@766 1724 } else {
bpatel@766 1725 filename = "stylesheet.css";
bpatel@766 1726 }
bpatel@766 1727 filename = relativePath + filename;
bpatel@766 1728 HtmlTree link = HtmlTree.LINK("stylesheet", "text/css", filename, "Style");
bpatel@766 1729 return link;
bpatel@766 1730 }
bpatel@766 1731
bpatel@766 1732 /**
jjh@972 1733 * According to
jjh@972 1734 * <cite>The Java&trade; Language Specification</cite>,
jjh@972 1735 * all the outer classes and static nested classes are core classes.
duke@1 1736 */
duke@1 1737 public boolean isCoreClass(ClassDoc cd) {
duke@1 1738 return cd.containingClass() == null || cd.isStatic();
duke@1 1739 }
duke@1 1740
duke@1 1741 /**
bpatel@766 1742 * Adds the annotatation types for the given packageDoc.
bpatel@766 1743 *
bpatel@766 1744 * @param packageDoc the package to write annotations for.
bpatel@766 1745 * @param htmltree the documentation tree to which the annotation info will be
bpatel@766 1746 * added
bpatel@766 1747 */
bpatel@766 1748 public void addAnnotationInfo(PackageDoc packageDoc, Content htmltree) {
bpatel@766 1749 addAnnotationInfo(packageDoc, packageDoc.annotations(), htmltree);
bpatel@766 1750 }
bpatel@766 1751
bpatel@766 1752 /**
bpatel@766 1753 * Adds the annotatation types for the given doc.
bpatel@766 1754 *
jjg@1358 1755 * @param doc the package to write annotations for
bpatel@766 1756 * @param htmltree the content tree to which the annotation types will be added
bpatel@766 1757 */
bpatel@766 1758 public void addAnnotationInfo(ProgramElementDoc doc, Content htmltree) {
bpatel@766 1759 addAnnotationInfo(doc, doc.annotations(), htmltree);
bpatel@766 1760 }
bpatel@766 1761
bpatel@766 1762 /**
bpatel@766 1763 * Add the annotatation types for the given doc and parameter.
bpatel@766 1764 *
bpatel@766 1765 * @param indent the number of spaces to indent the parameters.
bpatel@766 1766 * @param doc the doc to write annotations for.
bpatel@766 1767 * @param param the parameter to write annotations for.
bpatel@766 1768 * @param tree the content tree to which the annotation types will be added
bpatel@766 1769 */
bpatel@766 1770 public boolean addAnnotationInfo(int indent, Doc doc, Parameter param,
bpatel@766 1771 Content tree) {
bpatel@766 1772 return addAnnotationInfo(indent, doc, param.annotations(), false, tree);
bpatel@766 1773 }
bpatel@766 1774
bpatel@766 1775 /**
bpatel@766 1776 * Adds the annotatation types for the given doc.
bpatel@766 1777 *
bpatel@766 1778 * @param doc the doc to write annotations for.
bpatel@766 1779 * @param descList the array of {@link AnnotationDesc}.
bpatel@766 1780 * @param htmltree the documentation tree to which the annotation info will be
bpatel@766 1781 * added
bpatel@766 1782 */
bpatel@766 1783 private void addAnnotationInfo(Doc doc, AnnotationDesc[] descList,
bpatel@766 1784 Content htmltree) {
bpatel@766 1785 addAnnotationInfo(0, doc, descList, true, htmltree);
bpatel@766 1786 }
bpatel@766 1787
bpatel@766 1788 /**
bpatel@766 1789 * Adds the annotatation types for the given doc.
bpatel@766 1790 *
bpatel@766 1791 * @param indent the number of extra spaces to indent the annotations.
bpatel@766 1792 * @param doc the doc to write annotations for.
bpatel@766 1793 * @param descList the array of {@link AnnotationDesc}.
bpatel@766 1794 * @param htmltree the documentation tree to which the annotation info will be
bpatel@766 1795 * added
bpatel@766 1796 */
bpatel@766 1797 private boolean addAnnotationInfo(int indent, Doc doc,
bpatel@766 1798 AnnotationDesc[] descList, boolean lineBreak, Content htmltree) {
bpatel@766 1799 List<String> annotations = getAnnotations(indent, descList, lineBreak);
bpatel@766 1800 if (annotations.size() == 0) {
bpatel@766 1801 return false;
bpatel@766 1802 }
bpatel@766 1803 Content annotationContent;
bpatel@766 1804 for (Iterator<String> iter = annotations.iterator(); iter.hasNext();) {
bpatel@766 1805 annotationContent = new RawHtml(iter.next());
bpatel@766 1806 htmltree.addContent(annotationContent);
bpatel@766 1807 }
bpatel@766 1808 return true;
bpatel@766 1809 }
bpatel@766 1810
bpatel@766 1811 /**
duke@1 1812 * Return the string representations of the annotation types for
duke@1 1813 * the given doc.
duke@1 1814 *
duke@1 1815 * @param indent the number of extra spaces to indent the annotations.
duke@1 1816 * @param descList the array of {@link AnnotationDesc}.
duke@1 1817 * @param linkBreak if true, add new line between each member value.
duke@1 1818 * @return an array of strings representing the annotations being
duke@1 1819 * documented.
duke@1 1820 */
jjg@74 1821 private List<String> getAnnotations(int indent, AnnotationDesc[] descList, boolean linkBreak) {
jjg@74 1822 List<String> results = new ArrayList<String>();
jjg@1362 1823 StringBuilder annotation;
duke@1 1824 for (int i = 0; i < descList.length; i++) {
duke@1 1825 AnnotationTypeDoc annotationDoc = descList[i].annotationType();
duke@1 1826 if (! Util.isDocumentedAnnotation(annotationDoc)){
duke@1 1827 continue;
duke@1 1828 }
jjg@1362 1829 annotation = new StringBuilder();
duke@1 1830 LinkInfoImpl linkInfo = new LinkInfoImpl(
duke@1 1831 LinkInfoImpl.CONTEXT_ANNOTATION, annotationDoc);
duke@1 1832 linkInfo.label = "@" + annotationDoc.name();
duke@1 1833 annotation.append(getLink(linkInfo));
duke@1 1834 AnnotationDesc.ElementValuePair[] pairs = descList[i].elementValues();
duke@1 1835 if (pairs.length > 0) {
duke@1 1836 annotation.append('(');
duke@1 1837 for (int j = 0; j < pairs.length; j++) {
duke@1 1838 if (j > 0) {
duke@1 1839 annotation.append(",");
duke@1 1840 if (linkBreak) {
duke@1 1841 annotation.append(DocletConstants.NL);
duke@1 1842 int spaces = annotationDoc.name().length() + 2;
duke@1 1843 for (int k = 0; k < (spaces + indent); k++) {
duke@1 1844 annotation.append(' ');
duke@1 1845 }
duke@1 1846 }
duke@1 1847 }
duke@1 1848 annotation.append(getDocLink(LinkInfoImpl.CONTEXT_ANNOTATION,
duke@1 1849 pairs[j].element(), pairs[j].element().name(), false));
duke@1 1850 annotation.append('=');
duke@1 1851 AnnotationValue annotationValue = pairs[j].value();
jjg@74 1852 List<AnnotationValue> annotationTypeValues = new ArrayList<AnnotationValue>();
duke@1 1853 if (annotationValue.value() instanceof AnnotationValue[]) {
duke@1 1854 AnnotationValue[] annotationArray =
duke@1 1855 (AnnotationValue[]) annotationValue.value();
duke@1 1856 for (int k = 0; k < annotationArray.length; k++) {
duke@1 1857 annotationTypeValues.add(annotationArray[k]);
duke@1 1858 }
duke@1 1859 } else {
duke@1 1860 annotationTypeValues.add(annotationValue);
duke@1 1861 }
duke@1 1862 annotation.append(annotationTypeValues.size() == 1 ? "" : "{");
mcimadamore@184 1863 for (Iterator<AnnotationValue> iter = annotationTypeValues.iterator(); iter.hasNext(); ) {
mcimadamore@184 1864 annotation.append(annotationValueToString(iter.next()));
duke@1 1865 annotation.append(iter.hasNext() ? "," : "");
duke@1 1866 }
duke@1 1867 annotation.append(annotationTypeValues.size() == 1 ? "" : "}");
duke@1 1868 }
duke@1 1869 annotation.append(")");
duke@1 1870 }
duke@1 1871 annotation.append(linkBreak ? DocletConstants.NL : "");
duke@1 1872 results.add(annotation.toString());
duke@1 1873 }
duke@1 1874 return results;
duke@1 1875 }
duke@1 1876
duke@1 1877 private String annotationValueToString(AnnotationValue annotationValue) {
duke@1 1878 if (annotationValue.value() instanceof Type) {
duke@1 1879 Type type = (Type) annotationValue.value();
duke@1 1880 if (type.asClassDoc() != null) {
duke@1 1881 LinkInfoImpl linkInfo = new LinkInfoImpl(
duke@1 1882 LinkInfoImpl.CONTEXT_ANNOTATION, type);
duke@1 1883 linkInfo.label = (type.asClassDoc().isIncluded() ?
duke@1 1884 type.typeName() :
duke@1 1885 type.qualifiedTypeName()) + type.dimension() + ".class";
duke@1 1886 return getLink(linkInfo);
duke@1 1887 } else {
duke@1 1888 return type.typeName() + type.dimension() + ".class";
duke@1 1889 }
duke@1 1890 } else if (annotationValue.value() instanceof AnnotationDesc) {
mcimadamore@184 1891 List<String> list = getAnnotations(0,
duke@1 1892 new AnnotationDesc[]{(AnnotationDesc) annotationValue.value()},
duke@1 1893 false);
jjg@1362 1894 StringBuilder buf = new StringBuilder();
jjg@1362 1895 for (String s: list) {
jjg@1362 1896 buf.append(s);
duke@1 1897 }
duke@1 1898 return buf.toString();
duke@1 1899 } else if (annotationValue.value() instanceof MemberDoc) {
duke@1 1900 return getDocLink(LinkInfoImpl.CONTEXT_ANNOTATION,
duke@1 1901 (MemberDoc) annotationValue.value(),
duke@1 1902 ((MemberDoc) annotationValue.value()).name(), false);
duke@1 1903 } else {
duke@1 1904 return annotationValue.toString();
duke@1 1905 }
duke@1 1906 }
duke@1 1907
duke@1 1908 /**
duke@1 1909 * Return the configuation for this doclet.
duke@1 1910 *
duke@1 1911 * @return the configuration for this doclet.
duke@1 1912 */
duke@1 1913 public Configuration configuration() {
duke@1 1914 return configuration;
duke@1 1915 }
duke@1 1916 }

mercurial