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

changeset 766
90af8d87741f
parent 554
9d9f26857129
child 793
ffbf2b2a8611
     1.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java	Tue Nov 30 09:38:48 2010 -0800
     1.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java	Wed Dec 01 11:02:38 2010 -0800
     1.3 @@ -88,6 +88,11 @@
     1.4      public ConfigurationImpl configuration;
     1.5  
     1.6      /**
     1.7 +     * To check whether annotation heading is printed or not.
     1.8 +     */
     1.9 +    protected boolean printedAnnotationHeading = false;
    1.10 +
    1.11 +    /**
    1.12       * Constructor to construct the HtmlStandardWriter object.
    1.13       *
    1.14       * @param filename File to be generated.
    1.15 @@ -169,7 +174,7 @@
    1.16              // Append slash if next character is not a slash
    1.17              if (relativepathNoSlash.length() > 0 && previndex < htmlstr.length()
    1.18                      && htmlstr.charAt(previndex) != '/') {
    1.19 -                buf.append(DirectoryManager.URL_FILE_SEPERATOR);
    1.20 +                buf.append(DirectoryManager.URL_FILE_SEPARATOR);
    1.21              }
    1.22          }
    1.23          return buf.toString();
    1.24 @@ -192,17 +197,47 @@
    1.25          println("  <!--");
    1.26          println("  if(window==top) {");
    1.27          println("    document.writeln('"
    1.28 -            + getHyperLink(link, where, label, strong, "", "", target) + "');");
    1.29 +            + getHyperLinkString(link, where, label, strong, "", "", target) + "');");
    1.30          println("  }");
    1.31          println("  //-->");
    1.32          scriptEnd();
    1.33          noScript();
    1.34 -        println("  " + getHyperLink(link, where, label, strong, "", "", target));
    1.35 +        println("  " + getHyperLinkString(link, where, label, strong, "", "", target));
    1.36          noScriptEnd();
    1.37          println(DocletConstants.NL);
    1.38      }
    1.39  
    1.40 -    private void printMethodInfo(MethodDoc method) {
    1.41 +    /**
    1.42 +     * Get the script to show or hide the All classes link.
    1.43 +     *
    1.44 +     * @param id id of the element to show or hide
    1.45 +     * @return a content tree for the script
    1.46 +     */
    1.47 +    public Content getAllClassesLinkScript(String id) {
    1.48 +        HtmlTree script = new HtmlTree(HtmlTag.SCRIPT);
    1.49 +        script.addAttr(HtmlAttr.TYPE, "text/javascript");
    1.50 +        String scriptCode = "<!--\n" +
    1.51 +                "  allClassesLink = document.getElementById(\"" + id + "\");\n" +
    1.52 +                "  if(window==top) {\n" +
    1.53 +                "    allClassesLink.style.display = \"block\";\n" +
    1.54 +                "  }\n" +
    1.55 +                "  else {\n" +
    1.56 +                "    allClassesLink.style.display = \"none\";\n" +
    1.57 +                "  }\n" +
    1.58 +                "  //-->\n";
    1.59 +        Content scriptContent = new RawHtml(scriptCode);
    1.60 +        script.addContent(scriptContent);
    1.61 +        Content div = HtmlTree.DIV(script);
    1.62 +        return div;
    1.63 +    }
    1.64 +
    1.65 +    /**
    1.66 +     * Add method information.
    1.67 +     *
    1.68 +     * @param method the method to be documented
    1.69 +     * @param dl the content tree to which the method information will be added
    1.70 +     */
    1.71 +    private void addMethodInfo(MethodDoc method, Content dl) {
    1.72          ClassDoc[] intfacs = method.containingClass().interfaces();
    1.73          MethodDoc overriddenMethod = method.overriddenMethod();
    1.74          // Check whether there is any implementation or overridden info to be
    1.75 @@ -211,46 +246,38 @@
    1.76          if ((intfacs.length > 0 &&
    1.77                  new ImplementedMethods(method, this.configuration).build().length > 0) ||
    1.78                  overriddenMethod != null) {
    1.79 -            printMemberDetailsListStartTag();
    1.80 -            dd();
    1.81 -            printTagsInfoHeader();
    1.82 -            MethodWriterImpl.printImplementsInfo(this, method);
    1.83 +            MethodWriterImpl.addImplementsInfo(this, method, dl);
    1.84              if (overriddenMethod != null) {
    1.85 -                MethodWriterImpl.printOverridden(this,
    1.86 -                    method.overriddenType(), overriddenMethod);
    1.87 +                MethodWriterImpl.addOverridden(this,
    1.88 +                        method.overriddenType(), overriddenMethod, dl);
    1.89              }
    1.90 -            printTagsInfoFooter();
    1.91 -            ddEnd();
    1.92          }
    1.93      }
    1.94  
    1.95 -    protected void printTags(Doc doc) {
    1.96 -        if(configuration.nocomment){
    1.97 +    /**
    1.98 +     * Adds the tags information.
    1.99 +     *
   1.100 +     * @param doc the doc for which the tags will be generated
   1.101 +     * @param htmltree the documentation tree to which the tags will be added
   1.102 +     */
   1.103 +    protected void addTagsInfo(Doc doc, Content htmltree) {
   1.104 +        if (configuration.nocomment) {
   1.105              return;
   1.106          }
   1.107 +        Content dl = new HtmlTree(HtmlTag.DL);
   1.108          if (doc instanceof MethodDoc) {
   1.109 -            printMethodInfo((MethodDoc) doc);
   1.110 +            addMethodInfo((MethodDoc) doc, dl);
   1.111          }
   1.112          TagletOutputImpl output = new TagletOutputImpl("");
   1.113          TagletWriter.genTagOuput(configuration.tagletManager, doc,
   1.114              configuration.tagletManager.getCustomTags(doc),
   1.115                  getTagletWriterInstance(false), output);
   1.116          String outputString = output.toString().trim();
   1.117 -        // For RootDoc, ClassDoc and PackageDoc, this section is not the
   1.118 -        // definition description but the start of definition list.
   1.119          if (!outputString.isEmpty()) {
   1.120 -            if (!(doc instanceof RootDoc || doc instanceof ClassDoc ||
   1.121 -                    doc instanceof PackageDoc)) {
   1.122 -                printMemberDetailsListStartTag();
   1.123 -                dd();
   1.124 -            }
   1.125 -            printTagsInfoHeader();
   1.126 -            print(outputString);
   1.127 -            printTagsInfoFooter();
   1.128 -            if (!(doc instanceof RootDoc || doc instanceof ClassDoc ||
   1.129 -                    doc instanceof PackageDoc))
   1.130 -                ddEnd();
   1.131 +            Content resultString = new RawHtml(outputString);
   1.132 +            dl.addContent(resultString);
   1.133          }
   1.134 +        htmltree.addContent(dl);
   1.135      }
   1.136  
   1.137      /**
   1.138 @@ -286,17 +313,16 @@
   1.139      }
   1.140  
   1.141      /**
   1.142 -     * Print Package link, with target frame.
   1.143 +     * Get Package link, with target frame.
   1.144       *
   1.145 -     * @param pd The link will be to the "package-summary.html" page for this
   1.146 -     * package.
   1.147 -     * @param target Name of the target frame.
   1.148 -     * @param label Tag for the link.
   1.149 +     * @param pd The link will be to the "package-summary.html" page for this package
   1.150 +     * @param target name of the target frame
   1.151 +     * @param label tag for the link
   1.152 +     * @return a content for the target package link
   1.153       */
   1.154 -    public void printTargetPackageLink(PackageDoc pd, String target,
   1.155 -        String label) {
   1.156 -        print(getHyperLink(pathString(pd, "package-summary.html"), "", label,
   1.157 -            false, "", "", target));
   1.158 +    public Content getTargetPackageLink(PackageDoc pd, String target,
   1.159 +            Content label) {
   1.160 +        return getHyperLink(pathString(pd, "package-summary.html"), "", label, "", target);
   1.161      }
   1.162  
   1.163      /**
   1.164 @@ -360,6 +386,64 @@
   1.165      }
   1.166  
   1.167      /**
   1.168 +     * Generates the HTML document tree and prints it out.
   1.169 +     *
   1.170 +     * @param metakeywords Array of String keywords for META tag. Each element
   1.171 +     *                     of the array is assigned to a separate META tag.
   1.172 +     *                     Pass in null for no array
   1.173 +     * @param includeScript true if printing windowtitle script
   1.174 +     *                      false for files that appear in the left-hand frames
   1.175 +     * @param body the body htmltree to be included in the document
   1.176 +     */
   1.177 +    public void printHtmlDocument(String[] metakeywords, boolean includeScript,
   1.178 +            Content body) {
   1.179 +        Content htmlDocType = DocType.Transitional();
   1.180 +        Content htmlComment = new Comment(configuration.getText("doclet.New_Page"));
   1.181 +        Content head = new HtmlTree(HtmlTag.HEAD);
   1.182 +        if (!configuration.notimestamp) {
   1.183 +            Content headComment = new Comment("Generated by javadoc (version " +
   1.184 +                    ConfigurationImpl.BUILD_DATE + ") on " + today());
   1.185 +            head.addContent(headComment);
   1.186 +        }
   1.187 +        if (configuration.charset.length() > 0) {
   1.188 +            Content meta = HtmlTree.META("Content-Type", "text/html",
   1.189 +                    configuration.charset);
   1.190 +            head.addContent(meta);
   1.191 +        }
   1.192 +        head.addContent(getTitle());
   1.193 +        if (!configuration.notimestamp) {
   1.194 +            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
   1.195 +            Content meta = HtmlTree.META("date", dateFormat.format(new Date()));
   1.196 +            head.addContent(meta);
   1.197 +        }
   1.198 +        if (metakeywords != null) {
   1.199 +            for (int i=0; i < metakeywords.length; i++) {
   1.200 +                Content meta = HtmlTree.META("keywords", metakeywords[i]);
   1.201 +                head.addContent(meta);
   1.202 +            }
   1.203 +        }
   1.204 +        head.addContent(getStyleSheetProperties());
   1.205 +        Content htmlTree = HtmlTree.HTML(configuration.getLocale().getLanguage(),
   1.206 +                head, body);
   1.207 +        Content htmlDocument = new HtmlDocument(htmlDocType,
   1.208 +                htmlComment, htmlTree);
   1.209 +        print(htmlDocument.toString());
   1.210 +    }
   1.211 +
   1.212 +    /**
   1.213 +     * Get the window title.
   1.214 +     *
   1.215 +     * @param title the title string to construct the complete window title
   1.216 +     * @return the window title string
   1.217 +     */
   1.218 +    public String getWindowTitle(String title) {
   1.219 +        if (configuration.windowtitle.length() > 0) {
   1.220 +            title += " (" + configuration.windowtitle  + ")";
   1.221 +        }
   1.222 +        return title;
   1.223 +    }
   1.224 +
   1.225 +    /**
   1.226       * Print user specified header and the footer.
   1.227       *
   1.228       * @param header if true print the user provided header else print the
   1.229 @@ -380,6 +464,28 @@
   1.230      }
   1.231  
   1.232      /**
   1.233 +     * Get user specified header and the footer.
   1.234 +     *
   1.235 +     * @param header if true print the user provided header else print the
   1.236 +     * user provided footer.
   1.237 +     */
   1.238 +    public Content getUserHeaderFooter(boolean header) {
   1.239 +        String content;
   1.240 +        if (header) {
   1.241 +            content = replaceDocRootDir(configuration.header);
   1.242 +        } else {
   1.243 +            if (configuration.footer.length() != 0) {
   1.244 +                content = replaceDocRootDir(configuration.footer);
   1.245 +            } else {
   1.246 +                content = replaceDocRootDir(configuration.header);
   1.247 +            }
   1.248 +        }
   1.249 +        Content rawContent = new RawHtml(content);
   1.250 +        Content em = HtmlTree.EM(rawContent);
   1.251 +        return em;
   1.252 +    }
   1.253 +
   1.254 +    /**
   1.255       * Print the user specified top.
   1.256       */
   1.257      public void printTop() {
   1.258 @@ -388,6 +494,16 @@
   1.259      }
   1.260  
   1.261      /**
   1.262 +     * Adds the user specified top.
   1.263 +     *
   1.264 +     * @param body the content tree to which user specified top will be added
   1.265 +     */
   1.266 +    public void addTop(Content body) {
   1.267 +        Content top = new RawHtml(replaceDocRootDir(configuration.top));
   1.268 +        body.addContent(top);
   1.269 +    }
   1.270 +
   1.271 +    /**
   1.272       * Print the user specified bottom.
   1.273       */
   1.274      public void printBottom() {
   1.275 @@ -396,6 +512,18 @@
   1.276      }
   1.277  
   1.278      /**
   1.279 +     * Adds the user specified bottom.
   1.280 +     *
   1.281 +     * @param body the content tree to which user specified bottom will be added
   1.282 +     */
   1.283 +    public void addBottom(Content body) {
   1.284 +        Content bottom = new RawHtml(replaceDocRootDir(configuration.bottom));
   1.285 +        Content small = HtmlTree.SMALL(bottom);
   1.286 +        Content p = HtmlTree.P(HtmlStyle.legalCopy, small);
   1.287 +        body.addContent(p);
   1.288 +    }
   1.289 +
   1.290 +    /**
   1.291       * Print the navigation bar for the Html page at the top and and the bottom.
   1.292       *
   1.293       * @param header If true print navigation bar at the top of the page else
   1.294 @@ -408,13 +536,13 @@
   1.295                  println(DocletConstants.NL + "<!-- ========= START OF TOP NAVBAR ======= -->");
   1.296                  anchor("navbar_top");
   1.297                  println();
   1.298 -                print(getHyperLink("", "skip-navbar_top", "", false, "",
   1.299 +                print(getHyperLinkString("", "skip-navbar_top", "", false, "",
   1.300                      configuration.getText("doclet.Skip_navigation_links"), ""));
   1.301              } else {
   1.302                  println(DocletConstants.NL + "<!-- ======= START OF BOTTOM NAVBAR ====== -->");
   1.303                  anchor("navbar_bottom");
   1.304                  println();
   1.305 -                print(getHyperLink("", "skip-navbar_bottom", "", false, "",
   1.306 +                print(getHyperLinkString("", "skip-navbar_bottom", "", false, "",
   1.307                      configuration.getText("doclet.Skip_navigation_links"), ""));
   1.308              }
   1.309              table(0, "100%", 1, 0);
   1.310 @@ -518,6 +646,97 @@
   1.311      }
   1.312  
   1.313      /**
   1.314 +     * Adds the navigation bar for the Html page at the top and and the bottom.
   1.315 +     *
   1.316 +     * @param header If true print navigation bar at the top of the page else
   1.317 +     * @param body the HtmlTree to which the nav links will be added
   1.318 +     */
   1.319 +    protected void addNavLinks(boolean header, Content body) {
   1.320 +        if (!configuration.nonavbar) {
   1.321 +            String allClassesId = "allclasses_";
   1.322 +            HtmlTree navDiv = new HtmlTree(HtmlTag.DIV);
   1.323 +            if (header) {
   1.324 +                body.addContent(HtmlConstants.START_OF_TOP_NAVBAR);
   1.325 +                navDiv.addStyle(HtmlStyle.topNav);
   1.326 +                allClassesId += "navbar_top";
   1.327 +                Content a = getMarkerAnchor("navbar_top");
   1.328 +                navDiv.addContent(a);
   1.329 +                Content skipLinkContent = getHyperLink("",
   1.330 +                        "skip-navbar_top", HtmlTree.EMPTY, configuration.getText(
   1.331 +                        "doclet.Skip_navigation_links"), "");
   1.332 +                navDiv.addContent(skipLinkContent);
   1.333 +            } else {
   1.334 +                body.addContent(HtmlConstants.START_OF_BOTTOM_NAVBAR);
   1.335 +                navDiv.addStyle(HtmlStyle.bottomNav);
   1.336 +                allClassesId += "navbar_bottom";
   1.337 +                Content a = getMarkerAnchor("navbar_bottom");
   1.338 +                navDiv.addContent(a);
   1.339 +                Content skipLinkContent = getHyperLink("",
   1.340 +                        "skip-navbar_bottom", HtmlTree.EMPTY, configuration.getText(
   1.341 +                        "doclet.Skip_navigation_links"), "");
   1.342 +                navDiv.addContent(skipLinkContent);
   1.343 +            }
   1.344 +            if (header) {
   1.345 +                navDiv.addContent(getMarkerAnchor("navbar_top_firstrow"));
   1.346 +            } else {
   1.347 +                navDiv.addContent(getMarkerAnchor("navbar_bottom_firstrow"));
   1.348 +            }
   1.349 +            HtmlTree navList = new HtmlTree(HtmlTag.UL);
   1.350 +            navList.addStyle(HtmlStyle.navList);
   1.351 +            navList.addAttr(HtmlAttr.TITLE, "Navigation");
   1.352 +            if (configuration.createoverview) {
   1.353 +                navList.addContent(getNavLinkContents());
   1.354 +            }
   1.355 +            if (configuration.packages.length == 1) {
   1.356 +                navList.addContent(getNavLinkPackage(configuration.packages[0]));
   1.357 +            } else if (configuration.packages.length > 1) {
   1.358 +                navList.addContent(getNavLinkPackage());
   1.359 +            }
   1.360 +            navList.addContent(getNavLinkClass());
   1.361 +            if(configuration.classuse) {
   1.362 +                navList.addContent(getNavLinkClassUse());
   1.363 +            }
   1.364 +            if(configuration.createtree) {
   1.365 +                navList.addContent(getNavLinkTree());
   1.366 +            }
   1.367 +            if(!(configuration.nodeprecated ||
   1.368 +                     configuration.nodeprecatedlist)) {
   1.369 +                navList.addContent(getNavLinkDeprecated());
   1.370 +            }
   1.371 +            if(configuration.createindex) {
   1.372 +                navList.addContent(getNavLinkIndex());
   1.373 +            }
   1.374 +            if (!configuration.nohelp) {
   1.375 +                navList.addContent(getNavLinkHelp());
   1.376 +            }
   1.377 +            navDiv.addContent(navList);
   1.378 +            Content aboutDiv = HtmlTree.DIV(HtmlStyle.aboutLanguage, getUserHeaderFooter(header));
   1.379 +            navDiv.addContent(aboutDiv);
   1.380 +            body.addContent(navDiv);
   1.381 +            Content ulNav = HtmlTree.UL(HtmlStyle.navList, getNavLinkPrevious());
   1.382 +            ulNav.addContent(getNavLinkNext());
   1.383 +            Content subDiv = HtmlTree.DIV(HtmlStyle.subNav, ulNav);
   1.384 +            Content ulFrames = HtmlTree.UL(HtmlStyle.navList, getNavShowLists());
   1.385 +            ulFrames.addContent(getNavHideLists(filename));
   1.386 +            subDiv.addContent(ulFrames);
   1.387 +            HtmlTree ulAllClasses = HtmlTree.UL(HtmlStyle.navList, getNavLinkClassIndex());
   1.388 +            ulAllClasses.addAttr(HtmlAttr.ID, allClassesId.toString());
   1.389 +            subDiv.addContent(ulAllClasses);
   1.390 +            subDiv.addContent(getAllClassesLinkScript(allClassesId.toString()));
   1.391 +            addSummaryDetailLinks(subDiv);
   1.392 +            if (header) {
   1.393 +                subDiv.addContent(getMarkerAnchor("skip-navbar_top"));
   1.394 +                body.addContent(subDiv);
   1.395 +                body.addContent(HtmlConstants.END_OF_TOP_NAVBAR);
   1.396 +            } else {
   1.397 +                subDiv.addContent(getMarkerAnchor("skip-navbar_bottom"));
   1.398 +                body.addContent(subDiv);
   1.399 +                body.addContent(HtmlConstants.END_OF_BOTTOM_NAVBAR);
   1.400 +            }
   1.401 +        }
   1.402 +    }
   1.403 +
   1.404 +    /**
   1.405       * Print the word "NEXT" to indicate that no link is available.  Override
   1.406       * this method to customize next link.
   1.407       */
   1.408 @@ -526,6 +745,16 @@
   1.409      }
   1.410  
   1.411      /**
   1.412 +     * Get the word "NEXT" to indicate that no link is available.  Override
   1.413 +     * this method to customize next link.
   1.414 +     *
   1.415 +     * @return a content tree for the link
   1.416 +     */
   1.417 +    protected Content getNavLinkNext() {
   1.418 +        return getNavLinkNext(null);
   1.419 +    }
   1.420 +
   1.421 +    /**
   1.422       * Print the word "PREV" to indicate that no link is available.  Override
   1.423       * this method to customize prev link.
   1.424       */
   1.425 @@ -534,12 +763,28 @@
   1.426      }
   1.427  
   1.428      /**
   1.429 +     * Get the word "PREV" to indicate that no link is available.  Override
   1.430 +     * this method to customize prev link.
   1.431 +     *
   1.432 +     * @return a content tree for the link
   1.433 +     */
   1.434 +    protected Content getNavLinkPrevious() {
   1.435 +        return getNavLinkPrevious(null);
   1.436 +    }
   1.437 +
   1.438 +    /**
   1.439       * Do nothing. This is the default method.
   1.440       */
   1.441      protected void printSummaryDetailLinks() {
   1.442      }
   1.443  
   1.444      /**
   1.445 +     * Do nothing. This is the default method.
   1.446 +     */
   1.447 +    protected void addSummaryDetailLinks(Content navDiv) {
   1.448 +    }
   1.449 +
   1.450 +    /**
   1.451       * Print link to the "overview-summary.html" page.
   1.452       */
   1.453      protected void navLinkContents() {
   1.454 @@ -550,6 +795,18 @@
   1.455      }
   1.456  
   1.457      /**
   1.458 +     * Get link to the "overview-summary.html" page.
   1.459 +     *
   1.460 +     * @return a content tree for the link
   1.461 +     */
   1.462 +    protected Content getNavLinkContents() {
   1.463 +        Content linkContent = getHyperLink(relativePath +
   1.464 +                "overview-summary.html", "", overviewLabel, "", "");
   1.465 +        Content li = HtmlTree.LI(linkContent);
   1.466 +        return li;
   1.467 +    }
   1.468 +
   1.469 +    /**
   1.470       * Description for a cell in the navigation bar.
   1.471       */
   1.472      protected void navCellStart() {
   1.473 @@ -590,6 +847,19 @@
   1.474      }
   1.475  
   1.476      /**
   1.477 +     * Get link to the "package-summary.html" page for the package passed.
   1.478 +     *
   1.479 +     * @param pkg Package to which link will be generated
   1.480 +     * @return a content tree for the link
   1.481 +     */
   1.482 +    protected Content getNavLinkPackage(PackageDoc pkg) {
   1.483 +        Content linkContent = getPackageLink(pkg,
   1.484 +                packageLabel);
   1.485 +        Content li = HtmlTree.LI(linkContent);
   1.486 +        return li;
   1.487 +    }
   1.488 +
   1.489 +    /**
   1.490       * Print the word "Package" in the navigation bar cell, to indicate that
   1.491       * link is not available here.
   1.492       */
   1.493 @@ -602,6 +872,16 @@
   1.494      }
   1.495  
   1.496      /**
   1.497 +     * Get the word "Package" , to indicate that link is not available here.
   1.498 +     *
   1.499 +     * @return a content tree for the link
   1.500 +     */
   1.501 +    protected Content getNavLinkPackage() {
   1.502 +        Content li = HtmlTree.LI(packageLabel);
   1.503 +        return li;
   1.504 +    }
   1.505 +
   1.506 +    /**
   1.507       * Print the word "Use" in the navigation bar cell, to indicate that link
   1.508       * is not available.
   1.509       */
   1.510 @@ -614,6 +894,16 @@
   1.511      }
   1.512  
   1.513      /**
   1.514 +     * Get the word "Use", to indicate that link is not available.
   1.515 +     *
   1.516 +     * @return a content tree for the link
   1.517 +     */
   1.518 +    protected Content getNavLinkClassUse() {
   1.519 +        Content li = HtmlTree.LI(useLabel);
   1.520 +        return li;
   1.521 +    }
   1.522 +
   1.523 +    /**
   1.524       * Print link for previous file.
   1.525       *
   1.526       * @param prev File name for the prev link.
   1.527 @@ -628,6 +918,22 @@
   1.528      }
   1.529  
   1.530      /**
   1.531 +     * Get link for previous file.
   1.532 +     *
   1.533 +     * @param prev File name for the prev link
   1.534 +     * @return a content tree for the link
   1.535 +     */
   1.536 +    public Content getNavLinkPrevious(String prev) {
   1.537 +        Content li;
   1.538 +        if (prev != null) {
   1.539 +            li = HtmlTree.LI(getHyperLink(prev, "", prevLabel, "", ""));
   1.540 +        }
   1.541 +        else
   1.542 +            li = HtmlTree.LI(prevLabel);
   1.543 +        return li;
   1.544 +    }
   1.545 +
   1.546 +    /**
   1.547       * Print link for next file.  If next is null, just print the label
   1.548       * without linking it anywhere.
   1.549       *
   1.550 @@ -643,16 +949,46 @@
   1.551      }
   1.552  
   1.553      /**
   1.554 +     * Get link for next file.  If next is null, just print the label
   1.555 +     * without linking it anywhere.
   1.556 +     *
   1.557 +     * @param next File name for the next link
   1.558 +     * @return a content tree for the link
   1.559 +     */
   1.560 +    public Content getNavLinkNext(String next) {
   1.561 +        Content li;
   1.562 +        if (next != null) {
   1.563 +            li = HtmlTree.LI(getHyperLink(next, "", nextLabel, "", ""));
   1.564 +        }
   1.565 +        else
   1.566 +            li = HtmlTree.LI(nextLabel);
   1.567 +        return li;
   1.568 +    }
   1.569 +
   1.570 +    /**
   1.571       * Print "FRAMES" link, to switch to the frame version of the output.
   1.572       *
   1.573       * @param link File to be linked, "index.html".
   1.574       */
   1.575      protected void navShowLists(String link) {
   1.576 -        print(getHyperLink(link + "?" + path + filename, "",
   1.577 +        print(getHyperLinkString(link + "?" + path + filename, "",
   1.578              configuration.getText("doclet.FRAMES"), true, "", "", "_top"));
   1.579      }
   1.580  
   1.581      /**
   1.582 +     * Get "FRAMES" link, to switch to the frame version of the output.
   1.583 +     *
   1.584 +     * @param link File to be linked, "index.html"
   1.585 +     * @return a content tree for the link
   1.586 +     */
   1.587 +    protected Content getNavShowLists(String link) {
   1.588 +        Content framesContent = getHyperLink(link + "?" + path +
   1.589 +                filename, "", framesLabel, "", "_top");
   1.590 +        Content li = HtmlTree.LI(framesContent);
   1.591 +        return li;
   1.592 +    }
   1.593 +
   1.594 +    /**
   1.595       * Print "FRAMES" link, to switch to the frame version of the output.
   1.596       */
   1.597      protected void navShowLists() {
   1.598 @@ -660,16 +996,37 @@
   1.599      }
   1.600  
   1.601      /**
   1.602 +     * Get "FRAMES" link, to switch to the frame version of the output.
   1.603 +     *
   1.604 +     * @return a content tree for the link
   1.605 +     */
   1.606 +    protected Content getNavShowLists() {
   1.607 +        return getNavShowLists(relativePath + "index.html");
   1.608 +    }
   1.609 +
   1.610 +    /**
   1.611       * Print "NO FRAMES" link, to switch to the non-frame version of the output.
   1.612       *
   1.613       * @param link File to be linked.
   1.614       */
   1.615      protected void navHideLists(String link) {
   1.616 -        print(getHyperLink(link, "", configuration.getText("doclet.NO_FRAMES"),
   1.617 +        print(getHyperLinkString(link, "", configuration.getText("doclet.NO_FRAMES"),
   1.618              true, "", "", "_top"));
   1.619      }
   1.620  
   1.621      /**
   1.622 +     * Get "NO FRAMES" link, to switch to the non-frame version of the output.
   1.623 +     *
   1.624 +     * @param link File to be linked
   1.625 +     * @return a content tree for the link
   1.626 +     */
   1.627 +    protected Content getNavHideLists(String link) {
   1.628 +        Content noFramesContent = getHyperLink(link, "", noframesLabel, "", "_top");
   1.629 +        Content li = HtmlTree.LI(noFramesContent);
   1.630 +        return li;
   1.631 +    }
   1.632 +
   1.633 +    /**
   1.634       * Print "Tree" link in the navigation bar. If there is only one package
   1.635       * specified on the command line, then the "Tree" link will be to the
   1.636       * only "package-tree.html" file otherwise it will be to the
   1.637 @@ -689,10 +1046,39 @@
   1.638      }
   1.639  
   1.640      /**
   1.641 -     * Print "Tree" link to the "overview-tree.html" file.
   1.642 +     * Get "Tree" link in the navigation bar. If there is only one package
   1.643 +     * specified on the command line, then the "Tree" link will be to the
   1.644 +     * only "package-tree.html" file otherwise it will be to the
   1.645 +     * "overview-tree.html" file.
   1.646 +     *
   1.647 +     * @return a content tree for the link
   1.648       */
   1.649 -    protected void navLinkMainTree(String label) {
   1.650 -        printHyperLink(relativePath + "overview-tree.html", label);
   1.651 +    protected Content getNavLinkTree() {
   1.652 +        Content treeLinkContent;
   1.653 +        PackageDoc[] packages = configuration.root.specifiedPackages();
   1.654 +        if (packages.length == 1 && configuration.root.specifiedClasses().length == 0) {
   1.655 +            treeLinkContent = getHyperLink(pathString(packages[0],
   1.656 +                    "package-tree.html"), "", treeLabel,
   1.657 +                    "", "");
   1.658 +        } else {
   1.659 +            treeLinkContent = getHyperLink(relativePath + "overview-tree.html",
   1.660 +                    "", treeLabel, "", "");
   1.661 +        }
   1.662 +        Content li = HtmlTree.LI(treeLinkContent);
   1.663 +        return li;
   1.664 +    }
   1.665 +
   1.666 +    /**
   1.667 +     * Get the overview tree link for the main tree.
   1.668 +     *
   1.669 +     * @param label the label for the link
   1.670 +     * @return a content tree for the link
   1.671 +     */
   1.672 +    protected Content getNavLinkMainTree(String label) {
   1.673 +        Content mainTreeContent = getHyperLink(relativePath + "overview-tree.html",
   1.674 +                new StringContent(label));
   1.675 +        Content li = HtmlTree.LI(mainTreeContent);
   1.676 +        return li;
   1.677      }
   1.678  
   1.679      /**
   1.680 @@ -708,6 +1094,16 @@
   1.681      }
   1.682  
   1.683      /**
   1.684 +     * Get the word "Class", to indicate that class link is not available.
   1.685 +     *
   1.686 +     * @return a content tree for the link
   1.687 +     */
   1.688 +    protected Content getNavLinkClass() {
   1.689 +        Content li = HtmlTree.LI(classLabel);
   1.690 +        return li;
   1.691 +    }
   1.692 +
   1.693 +    /**
   1.694       * Print "Deprecated" API link in the navigation bar.
   1.695       */
   1.696      protected void navLinkDeprecated() {
   1.697 @@ -718,6 +1114,18 @@
   1.698      }
   1.699  
   1.700      /**
   1.701 +     * Get "Deprecated" API link in the navigation bar.
   1.702 +     *
   1.703 +     * @return a content tree for the link
   1.704 +     */
   1.705 +    protected Content getNavLinkDeprecated() {
   1.706 +        Content linkContent = getHyperLink(relativePath +
   1.707 +                "deprecated-list.html", "", deprecatedLabel, "", "");
   1.708 +        Content li = HtmlTree.LI(linkContent);
   1.709 +        return li;
   1.710 +    }
   1.711 +
   1.712 +    /**
   1.713       * Print link for generated index. If the user has used "-splitindex"
   1.714       * command line option, then link to file "index-files/index-1.html" is
   1.715       * generated otherwise link to file "index-all.html" is generated.
   1.716 @@ -727,6 +1135,21 @@
   1.717                  AllClassesFrameWriter.OUTPUT_FILE_NAME_NOFRAMES,
   1.718              "", "", configuration.getText("doclet.All_Classes"), true);
   1.719      }
   1.720 +
   1.721 +    /**
   1.722 +     * Get link for generated index. If the user has used "-splitindex"
   1.723 +     * command line option, then link to file "index-files/index-1.html" is
   1.724 +     * generated otherwise link to file "index-all.html" is generated.
   1.725 +     *
   1.726 +     * @return a content tree for the link
   1.727 +     */
   1.728 +    protected Content getNavLinkClassIndex() {
   1.729 +        Content allClassesContent = getHyperLink(relativePath +
   1.730 +                AllClassesFrameWriter.OUTPUT_FILE_NAME_NOFRAMES, "",
   1.731 +                allclassesLabel, "", "");
   1.732 +        Content li = HtmlTree.LI(allClassesContent);
   1.733 +        return li;
   1.734 +    }
   1.735      /**
   1.736       * Print link for generated class index.
   1.737       */
   1.738 @@ -743,6 +1166,20 @@
   1.739      }
   1.740  
   1.741      /**
   1.742 +     * Get link for generated class index.
   1.743 +     *
   1.744 +     * @return a content tree for the link
   1.745 +     */
   1.746 +    protected Content getNavLinkIndex() {
   1.747 +        Content linkContent = getHyperLink(relativePath +(configuration.splitindex?
   1.748 +            DirectoryManager.getPath("index-files") + fileseparator: "") +
   1.749 +            (configuration.splitindex?"index-1.html" : "index-all.html"), "",
   1.750 +            indexLabel, "", "");
   1.751 +        Content li = HtmlTree.LI(linkContent);
   1.752 +        return li;
   1.753 +    }
   1.754 +
   1.755 +    /**
   1.756       * Print help file link. If user has provided a help file, then generate a
   1.757       * link to the user given file, which is already copied to current or
   1.758       * destination directory.
   1.759 @@ -764,6 +1201,29 @@
   1.760      }
   1.761  
   1.762      /**
   1.763 +     * Get help file link. If user has provided a help file, then generate a
   1.764 +     * link to the user given file, which is already copied to current or
   1.765 +     * destination directory.
   1.766 +     *
   1.767 +     * @return a content tree for the link
   1.768 +     */
   1.769 +    protected Content getNavLinkHelp() {
   1.770 +        String helpfilenm = configuration.helpfile;
   1.771 +        if (helpfilenm.equals("")) {
   1.772 +            helpfilenm = "help-doc.html";
   1.773 +        } else {
   1.774 +            int lastsep;
   1.775 +            if ((lastsep = helpfilenm.lastIndexOf(File.separatorChar)) != -1) {
   1.776 +                helpfilenm = helpfilenm.substring(lastsep + 1);
   1.777 +            }
   1.778 +        }
   1.779 +        Content linkContent = getHyperLink(relativePath + helpfilenm, "",
   1.780 +                helpLabel, "", "");
   1.781 +        Content li = HtmlTree.LI(linkContent);
   1.782 +        return li;
   1.783 +    }
   1.784 +
   1.785 +    /**
   1.786       * Print the word "Detail" in the navigation bar. No link is available.
   1.787       */
   1.788      protected void navDetail() {
   1.789 @@ -845,6 +1305,96 @@
   1.790      }
   1.791  
   1.792      /**
   1.793 +     * Get summary table header.
   1.794 +     *
   1.795 +     * @param header the header for the table
   1.796 +     * @param scope the scope of the headers
   1.797 +     * @return a content tree for the header
   1.798 +     */
   1.799 +    public Content getSummaryTableHeader(String[] header, String scope) {
   1.800 +        Content tr = new HtmlTree(HtmlTag.TR);
   1.801 +        int size = header.length;
   1.802 +        Content tableHeader;
   1.803 +        if (size == 1) {
   1.804 +            tableHeader = new StringContent(header[0]);
   1.805 +            tr.addContent(HtmlTree.TH(HtmlStyle.colOne, scope, tableHeader));
   1.806 +            return tr;
   1.807 +        }
   1.808 +        for (int i = 0; i < size; i++) {
   1.809 +            tableHeader = new StringContent(header[i]);
   1.810 +            if(i == 0)
   1.811 +                tr.addContent(HtmlTree.TH(HtmlStyle.colFirst, scope, tableHeader));
   1.812 +            else if(i == (size - 1))
   1.813 +                tr.addContent(HtmlTree.TH(HtmlStyle.colLast, scope, tableHeader));
   1.814 +            else
   1.815 +                tr.addContent(HtmlTree.TH(scope, tableHeader));
   1.816 +        }
   1.817 +        return tr;
   1.818 +    }
   1.819 +
   1.820 +    /**
   1.821 +     * Get table caption.
   1.822 +     *
   1.823 +     * @param rawText the caption for the table which could be raw Html
   1.824 +     * @return a content tree for the caption
   1.825 +     */
   1.826 +    public Content getTableCaption(String rawText) {
   1.827 +        Content title = new RawHtml(rawText);
   1.828 +        Content captionSpan = HtmlTree.SPAN(title);
   1.829 +        Content space = getSpace();
   1.830 +        Content tabSpan = HtmlTree.SPAN(HtmlStyle.tabEnd, space);
   1.831 +        Content caption = HtmlTree.CAPTION(captionSpan);
   1.832 +        caption.addContent(tabSpan);
   1.833 +        return caption;
   1.834 +    }
   1.835 +
   1.836 +    /**
   1.837 +     * Get the marker anchor which will be added to the documentation tree.
   1.838 +     *
   1.839 +     * @param anchorName the anchor name attribute
   1.840 +     * @return a content tree for the marker anchor
   1.841 +     */
   1.842 +    public Content getMarkerAnchor(String anchorName) {
   1.843 +        return getMarkerAnchor(anchorName, null);
   1.844 +    }
   1.845 +
   1.846 +    /**
   1.847 +     * Get the marker anchor which will be added to the documentation tree.
   1.848 +     *
   1.849 +     * @param anchorName the anchor name attribute
   1.850 +     * @param anchorContent the content that should be added to the anchor
   1.851 +     * @return a content tree for the marker anchor
   1.852 +     */
   1.853 +    public Content getMarkerAnchor(String anchorName, Content anchorContent) {
   1.854 +        if (anchorContent == null)
   1.855 +            anchorContent = new Comment(" ");
   1.856 +        Content markerAnchor = HtmlTree.A_NAME(anchorName, anchorContent);
   1.857 +        return markerAnchor;
   1.858 +    }
   1.859 +
   1.860 +    /**
   1.861 +     * Returns a packagename content.
   1.862 +     *
   1.863 +     * @param packageDoc the package to check
   1.864 +     * @return package name content
   1.865 +     */
   1.866 +    public Content getPackageName(PackageDoc packageDoc) {
   1.867 +        return packageDoc == null || packageDoc.name().length() == 0 ?
   1.868 +            defaultPackageLabel :
   1.869 +            getPackageLabel(packageDoc.name());
   1.870 +    }
   1.871 +
   1.872 +    /**
   1.873 +     * Returns a package name label.
   1.874 +     *
   1.875 +     * @param parsedName the package name
   1.876 +     * @return the package name content
   1.877 +     */
   1.878 +    public Content getPackageLabel(String packageName) {
   1.879 +        return new StringContent(packageName);
   1.880 +    }
   1.881 +
   1.882 +    /**
   1.883       * Prine table header information about color, column span and the font.
   1.884       *
   1.885       * @param color Background color.
   1.886 @@ -1028,7 +1578,7 @@
   1.887       * @param isStrong true if the label should be strong.
   1.888       */
   1.889      public void printPackageLink(PackageDoc pkg, String label, boolean isStrong) {
   1.890 -        print(getPackageLink(pkg, label, isStrong));
   1.891 +        print(getPackageLinkString(pkg, label, isStrong));
   1.892      }
   1.893  
   1.894      /**
   1.895 @@ -1041,7 +1591,7 @@
   1.896       */
   1.897      public void printPackageLink(PackageDoc pkg, String label, boolean isStrong,
   1.898              String style) {
   1.899 -        print(getPackageLink(pkg, label, isStrong, style));
   1.900 +        print(getPackageLinkString(pkg, label, isStrong, style));
   1.901      }
   1.902  
   1.903      /**
   1.904 @@ -1052,9 +1602,9 @@
   1.905       * @param isStrong true if the label should be strong.
   1.906       * @return the link to the given package.
   1.907       */
   1.908 -    public String getPackageLink(PackageDoc pkg, String label,
   1.909 +    public String getPackageLinkString(PackageDoc pkg, String label,
   1.910                                   boolean isStrong) {
   1.911 -        return getPackageLink(pkg, label, isStrong, "");
   1.912 +        return getPackageLinkString(pkg, label, isStrong, "");
   1.913      }
   1.914  
   1.915      /**
   1.916 @@ -1066,7 +1616,7 @@
   1.917       * @param style  the font of the package link label.
   1.918       * @return the link to the given package.
   1.919       */
   1.920 -    public String getPackageLink(PackageDoc pkg, String label, boolean isStrong,
   1.921 +    public String getPackageLinkString(PackageDoc pkg, String label, boolean isStrong,
   1.922              String style) {
   1.923          boolean included = pkg != null && pkg.isIncluded();
   1.924          if (! included) {
   1.925 @@ -1079,12 +1629,43 @@
   1.926              }
   1.927          }
   1.928          if (included || pkg == null) {
   1.929 -            return getHyperLink(pathString(pkg, "package-summary.html"),
   1.930 +            return getHyperLinkString(pathString(pkg, "package-summary.html"),
   1.931                                  "", label, isStrong, style);
   1.932          } else {
   1.933              String crossPkgLink = getCrossPackageLink(Util.getPackageName(pkg));
   1.934              if (crossPkgLink != null) {
   1.935 -                return getHyperLink(crossPkgLink, "", label, isStrong, style);
   1.936 +                return getHyperLinkString(crossPkgLink, "", label, isStrong, style);
   1.937 +            } else {
   1.938 +                return label;
   1.939 +            }
   1.940 +        }
   1.941 +    }
   1.942 +
   1.943 +    /**
   1.944 +     * Return the link to the given package.
   1.945 +     *
   1.946 +     * @param pkg the package to link to.
   1.947 +     * @param label the label for the link.
   1.948 +     * @return a content tree for the package link.
   1.949 +     */
   1.950 +    public Content getPackageLink(PackageDoc pkg, Content label) {
   1.951 +        boolean included = pkg != null && pkg.isIncluded();
   1.952 +        if (! included) {
   1.953 +            PackageDoc[] packages = configuration.packages;
   1.954 +            for (int i = 0; i < packages.length; i++) {
   1.955 +                if (packages[i].equals(pkg)) {
   1.956 +                    included = true;
   1.957 +                    break;
   1.958 +                }
   1.959 +            }
   1.960 +        }
   1.961 +        if (included || pkg == null) {
   1.962 +            return getHyperLink(pathString(pkg, "package-summary.html"),
   1.963 +                                "", label);
   1.964 +        } else {
   1.965 +            String crossPkgLink = getCrossPackageLink(Util.getPackageName(pkg));
   1.966 +            if (crossPkgLink != null) {
   1.967 +                return getHyperLink(crossPkgLink, "", label);
   1.968              } else {
   1.969                  return label;
   1.970              }
   1.971 @@ -1112,6 +1693,29 @@
   1.972      }
   1.973  
   1.974      /**
   1.975 +     * Add the link to the content tree.
   1.976 +     *
   1.977 +     * @param doc program element doc for which the link will be added
   1.978 +     * @param label label for the link
   1.979 +     * @param htmltree the content tree to which the link will be added
   1.980 +     */
   1.981 +    public void addSrcLink(ProgramElementDoc doc, Content label, Content htmltree) {
   1.982 +        if (doc == null) {
   1.983 +            return;
   1.984 +        }
   1.985 +        ClassDoc cd = doc.containingClass();
   1.986 +        if (cd == null) {
   1.987 +            //d must be a class doc since in has no containing class.
   1.988 +            cd = (ClassDoc) doc;
   1.989 +        }
   1.990 +        String href = relativePath + DocletConstants.SOURCE_OUTPUT_DIR_NAME
   1.991 +                + DirectoryManager.getDirectoryPath(cd.containingPackage())
   1.992 +                + cd.name() + ".html#" + SourceToHTMLConverter.getAnchorName(doc);
   1.993 +        Content linkContent = getHyperLink(href, "", label, "", "");
   1.994 +        htmltree.addContent(linkContent);
   1.995 +    }
   1.996 +
   1.997 +    /**
   1.998       * Return the link to the given class.
   1.999       *
  1.1000       * @param linkInfo the information about the link.
  1.1001 @@ -1175,7 +1779,7 @@
  1.1002                  //the -link option.  There are ways to determine if an external package
  1.1003                  //exists, but no way to determine if the external class exists.  We just
  1.1004                  //have to assume that it does.
  1.1005 -                return getHyperLink(
  1.1006 +                return getHyperLinkString(
  1.1007                      configuration.extern.getExternalLink(packageName, relativePath,
  1.1008                                  className + ".html?is-external=true"),
  1.1009                      refMemName == null ? "" : refMemName,
  1.1010 @@ -1200,17 +1804,27 @@
  1.1011              "package-summary.html?is-external=true");
  1.1012      }
  1.1013  
  1.1014 -    public void printQualifiedClassLink(int context, ClassDoc cd) {
  1.1015 -        printLink(new LinkInfoImpl(context, cd,
  1.1016 -            configuration.getClassName(cd), ""));
  1.1017 +    /**
  1.1018 +     * Get the class link.
  1.1019 +     *
  1.1020 +     * @param context the id of the context where the link will be added
  1.1021 +     * @param cd the class doc to link to
  1.1022 +     * @return a content tree for the link
  1.1023 +     */
  1.1024 +    public Content getQualifiedClassLink(int context, ClassDoc cd) {
  1.1025 +        return new RawHtml(getLink(new LinkInfoImpl(context, cd,
  1.1026 +                configuration.getClassName(cd), "")));
  1.1027      }
  1.1028  
  1.1029      /**
  1.1030 -     * Print Class link, with only class name as the link and prefixing
  1.1031 -     * plain package name.
  1.1032 +     * Add the class link.
  1.1033 +     *
  1.1034 +     * @param context the id of the context where the link will be added
  1.1035 +     * @param cd the class doc to link to
  1.1036 +     * @param contentTree the content tree to which the link will be added
  1.1037       */
  1.1038 -    public void printPreQualifiedClassLink(int context, ClassDoc cd) {
  1.1039 -        print(getPreQualifiedClassLink(context, cd, false));
  1.1040 +    public void addPreQualifiedClassLink(int context, ClassDoc cd, Content contentTree) {
  1.1041 +        addPreQualifiedClassLink(context, cd, false, contentTree);
  1.1042      }
  1.1043  
  1.1044      /**
  1.1045 @@ -1233,13 +1847,36 @@
  1.1046          return classlink;
  1.1047      }
  1.1048  
  1.1049 +    /**
  1.1050 +     * Add the class link with the package portion of the label in
  1.1051 +     * plain text. If the qualifier is excluded, it will not be included in the
  1.1052 +     * link label.
  1.1053 +     *
  1.1054 +     * @param context the id of the context where the link will be added
  1.1055 +     * @param cd the class to link to
  1.1056 +     * @param isStrong true if the link should be strong
  1.1057 +     * @param contentTree the content tree to which the link with be added
  1.1058 +     */
  1.1059 +    public void addPreQualifiedClassLink(int context,
  1.1060 +            ClassDoc cd, boolean isStrong, Content contentTree) {
  1.1061 +        PackageDoc pd = cd.containingPackage();
  1.1062 +        if(pd != null && ! configuration.shouldExcludeQualifier(pd.name())) {
  1.1063 +            contentTree.addContent(getPkgName(cd));
  1.1064 +        }
  1.1065 +        contentTree.addContent(new RawHtml(getLink(new LinkInfoImpl(
  1.1066 +                context, cd, cd.name(), isStrong))));
  1.1067 +    }
  1.1068  
  1.1069      /**
  1.1070 -     * Print Class link, with only class name as the strong link and prefixing
  1.1071 +     * Add the class link, with only class name as the strong link and prefixing
  1.1072       * plain package name.
  1.1073 +     *
  1.1074 +     * @param context the id of the context where the link will be added
  1.1075 +     * @param cd the class to link to
  1.1076 +     * @param contentTree the content tree to which the link with be added
  1.1077       */
  1.1078 -    public void printPreQualifiedStrongClassLink(int context, ClassDoc cd) {
  1.1079 -        print(getPreQualifiedClassLink(context, cd, true));
  1.1080 +    public void addPreQualifiedStrongClassLink(int context, ClassDoc cd, Content contentTree) {
  1.1081 +        addPreQualifiedClassLink(context, cd, true, contentTree);
  1.1082      }
  1.1083  
  1.1084      public void printText(String key) {
  1.1085 @@ -1267,16 +1904,15 @@
  1.1086      }
  1.1087  
  1.1088      /**
  1.1089 -     * Print the link for the given member.
  1.1090 +     * Get the link for the given member.
  1.1091       *
  1.1092 -     * @param context the id of the context where the link will be printed.
  1.1093 -     * @param doc the member being linked to.
  1.1094 -     * @param label the label for the link.
  1.1095 -     * @param strong true if the link should be strong.
  1.1096 +     * @param context the id of the context where the link will be added
  1.1097 +     * @param doc the member being linked to
  1.1098 +     * @param label the label for the link
  1.1099 +     * @return a content tree for the doc link
  1.1100       */
  1.1101 -    public void printDocLink(int context, MemberDoc doc, String label,
  1.1102 -            boolean strong) {
  1.1103 -        print(getDocLink(context, doc, label, strong));
  1.1104 +    public Content getDocLink(int context, MemberDoc doc, String label) {
  1.1105 +        return getDocLink(context, doc.containingClass(), doc, label);
  1.1106      }
  1.1107  
  1.1108      /**
  1.1109 @@ -1338,6 +1974,34 @@
  1.1110          }
  1.1111      }
  1.1112  
  1.1113 +    /**
  1.1114 +     * Return the link for the given member.
  1.1115 +     *
  1.1116 +     * @param context the id of the context where the link will be added
  1.1117 +     * @param classDoc the classDoc that we should link to.  This is not
  1.1118 +     *                 necessarily equal to doc.containingClass().  We may be
  1.1119 +     *                 inheriting comments
  1.1120 +     * @param doc the member being linked to
  1.1121 +     * @param label the label for the link
  1.1122 +     * @return the link for the given member
  1.1123 +     */
  1.1124 +    public Content getDocLink(int context, ClassDoc classDoc, MemberDoc doc,
  1.1125 +        String label) {
  1.1126 +        if (! (doc.isIncluded() ||
  1.1127 +            Util.isLinkable(classDoc, configuration()))) {
  1.1128 +            return new StringContent(label);
  1.1129 +        } else if (doc instanceof ExecutableMemberDoc) {
  1.1130 +            ExecutableMemberDoc emd = (ExecutableMemberDoc)doc;
  1.1131 +            return new RawHtml(getLink(new LinkInfoImpl(context, classDoc,
  1.1132 +                getAnchor(emd), label, false)));
  1.1133 +        } else if (doc instanceof MemberDoc) {
  1.1134 +            return new RawHtml(getLink(new LinkInfoImpl(context, classDoc,
  1.1135 +                doc.name(), label, false)));
  1.1136 +        } else {
  1.1137 +            return new StringContent(label);
  1.1138 +        }
  1.1139 +    }
  1.1140 +
  1.1141      public void anchor(ExecutableMemberDoc emd) {
  1.1142          anchor(getAnchor(emd));
  1.1143      }
  1.1144 @@ -1392,14 +2056,14 @@
  1.1145                  //@see is referencing an included package
  1.1146                  String packageName = isplaintext ? refPackage.name() :
  1.1147                      getCode() + refPackage.name() + getCodeEnd();
  1.1148 -                result.append(getPackageLink(refPackage,
  1.1149 +                result.append(getPackageLinkString(refPackage,
  1.1150                      label.length() == 0 ? packageName : label, false));
  1.1151              } else {
  1.1152                  //@see is not referencing an included class or package.  Check for cross links.
  1.1153                  String classCrossLink, packageCrossLink = getCrossPackageLink(refClassName);
  1.1154                  if (packageCrossLink != null) {
  1.1155                      //Package cross link found
  1.1156 -                    result.append(getHyperLink(packageCrossLink, "",
  1.1157 +                    result.append(getHyperLinkString(packageCrossLink, "",
  1.1158                          (label.length() == 0)? text : label, false));
  1.1159                  } else if ((classCrossLink = getCrossClassLink(refClassName,
  1.1160                          refMemName, label, false, "", ! isplaintext)) != null) {
  1.1161 @@ -1468,18 +2132,61 @@
  1.1162          printCommentTags(doc, tag.inlineTags(), false, false);
  1.1163      }
  1.1164  
  1.1165 +    /**
  1.1166 +     * Add the inline comment.
  1.1167 +     *
  1.1168 +     * @param doc the doc for which the inline comment will be added
  1.1169 +     * @param tag the inline tag to be added
  1.1170 +     * @param htmltree the content tree to which the comment will be added
  1.1171 +     */
  1.1172 +    public void addInlineComment(Doc doc, Tag tag, Content htmltree) {
  1.1173 +        addCommentTags(doc, tag.inlineTags(), false, false, htmltree);
  1.1174 +    }
  1.1175 +
  1.1176      public void printInlineDeprecatedComment(Doc doc, Tag tag) {
  1.1177          printCommentTags(doc, tag.inlineTags(), true, false);
  1.1178      }
  1.1179  
  1.1180 +    /**
  1.1181 +     * Add the inline deprecated comment.
  1.1182 +     *
  1.1183 +     * @param doc the doc for which the inline deprecated comment will be added
  1.1184 +     * @param tag the inline tag to be added
  1.1185 +     * @param htmltree the content tree to which the comment will be added
  1.1186 +     */
  1.1187 +    public void addInlineDeprecatedComment(Doc doc, Tag tag, Content htmltree) {
  1.1188 +        addCommentTags(doc, tag.inlineTags(), true, false, htmltree);
  1.1189 +    }
  1.1190 +
  1.1191      public void printSummaryComment(Doc doc) {
  1.1192          printSummaryComment(doc, doc.firstSentenceTags());
  1.1193      }
  1.1194  
  1.1195 +    /**
  1.1196 +     * Adds the summary content.
  1.1197 +     *
  1.1198 +     * @param doc the doc for which the summary will be generated
  1.1199 +     * @param htmltree the documentation tree to which the summary will be added
  1.1200 +     */
  1.1201 +    public void addSummaryComment(Doc doc, Content htmltree) {
  1.1202 +        addSummaryComment(doc, doc.firstSentenceTags(), htmltree);
  1.1203 +    }
  1.1204 +
  1.1205      public void printSummaryComment(Doc doc, Tag[] firstSentenceTags) {
  1.1206          printCommentTags(doc, firstSentenceTags, false, true);
  1.1207      }
  1.1208  
  1.1209 +    /**
  1.1210 +     * Adds the summary content.
  1.1211 +     *
  1.1212 +     * @param doc the doc for which the summary will be generated
  1.1213 +     * @param firstSentenceTags the first sentence tags for the doc
  1.1214 +     * @param htmltree the documentation tree to which the summary will be added
  1.1215 +     */
  1.1216 +    public void addSummaryComment(Doc doc, Tag[] firstSentenceTags, Content htmltree) {
  1.1217 +        addCommentTags(doc, firstSentenceTags, false, true, htmltree);
  1.1218 +    }
  1.1219 +
  1.1220      public void printSummaryDeprecatedComment(Doc doc) {
  1.1221          printCommentTags(doc, doc.firstSentenceTags(), true, true);
  1.1222      }
  1.1223 @@ -1488,11 +2195,25 @@
  1.1224          printCommentTags(doc, tag.firstSentenceTags(), true, true);
  1.1225      }
  1.1226  
  1.1227 +    public void addSummaryDeprecatedComment(Doc doc, Tag tag, Content htmltree) {
  1.1228 +        addCommentTags(doc, tag.firstSentenceTags(), true, true, htmltree);
  1.1229 +    }
  1.1230 +
  1.1231      public void printInlineComment(Doc doc) {
  1.1232          printCommentTags(doc, doc.inlineTags(), false, false);
  1.1233          p();
  1.1234      }
  1.1235  
  1.1236 +    /**
  1.1237 +     * Adds the inline comment.
  1.1238 +     *
  1.1239 +     * @param doc the doc for which the inline comments will be generated
  1.1240 +     * @param htmltree the documentation tree to which the inline comments will be added
  1.1241 +     */
  1.1242 +    public void addInlineComment(Doc doc, Content htmltree) {
  1.1243 +        addCommentTags(doc, doc.inlineTags(), false, false, htmltree);
  1.1244 +    }
  1.1245 +
  1.1246      public void printInlineDeprecatedComment(Doc doc) {
  1.1247          printCommentTags(doc, doc.inlineTags(), true, false);
  1.1248      }
  1.1249 @@ -1515,6 +2236,36 @@
  1.1250      }
  1.1251  
  1.1252      /**
  1.1253 +     * Adds the comment tags.
  1.1254 +     *
  1.1255 +     * @param doc the doc for which the comment tags will be generated
  1.1256 +     * @param tags the first sentence tags for the doc
  1.1257 +     * @param depr true if it is deprecated
  1.1258 +     * @param first true if the first sentenge tags should be added
  1.1259 +     * @param htmltree the documentation tree to which the comment tags will be added
  1.1260 +     */
  1.1261 +    private void addCommentTags(Doc doc, Tag[] tags, boolean depr,
  1.1262 +            boolean first, Content htmltree) {
  1.1263 +        if(configuration.nocomment){
  1.1264 +            return;
  1.1265 +        }
  1.1266 +        Content div;
  1.1267 +        Content result = new RawHtml(commentTagsToString(null, doc, tags, first));
  1.1268 +        if (depr) {
  1.1269 +            Content italic = HtmlTree.I(result);
  1.1270 +            div = HtmlTree.DIV(HtmlStyle.block, italic);
  1.1271 +            htmltree.addContent(div);
  1.1272 +        }
  1.1273 +        else {
  1.1274 +            div = HtmlTree.DIV(HtmlStyle.block, result);
  1.1275 +            htmltree.addContent(div);
  1.1276 +        }
  1.1277 +        if (tags.length == 0) {
  1.1278 +            htmltree.addContent(getSpace());
  1.1279 +        }
  1.1280 +    }
  1.1281 +
  1.1282 +    /**
  1.1283       * Converts inline tags and text to text strings, expanding the
  1.1284       * inline tags along the way.  Called wherever text can contain
  1.1285       * an inline tag, such as in comments or in free-form text arguments
  1.1286 @@ -1624,8 +2375,8 @@
  1.1287              return text;
  1.1288          }
  1.1289  
  1.1290 -        if (! redirectPathFromRoot.endsWith(DirectoryManager.URL_FILE_SEPERATOR)) {
  1.1291 -            redirectPathFromRoot += DirectoryManager.URL_FILE_SEPERATOR;
  1.1292 +        if (! redirectPathFromRoot.endsWith(DirectoryManager.URL_FILE_SEPARATOR)) {
  1.1293 +            redirectPathFromRoot += DirectoryManager.URL_FILE_SEPARATOR;
  1.1294          }
  1.1295  
  1.1296          //Redirect all relative links.
  1.1297 @@ -1751,6 +2502,27 @@
  1.1298      }
  1.1299  
  1.1300      /**
  1.1301 +     * Returns a link to the stylesheet file.
  1.1302 +     *
  1.1303 +     * @return an HtmlTree for the lINK tag which provides the stylesheet location
  1.1304 +     */
  1.1305 +    public HtmlTree getStyleSheetProperties() {
  1.1306 +        String filename = configuration.stylesheetfile;
  1.1307 +        if (filename.length() > 0) {
  1.1308 +            File stylefile = new File(filename);
  1.1309 +            String parent = stylefile.getParent();
  1.1310 +            filename = (parent == null)?
  1.1311 +                filename:
  1.1312 +                filename.substring(parent.length() + 1);
  1.1313 +        } else {
  1.1314 +            filename = "stylesheet.css";
  1.1315 +        }
  1.1316 +        filename = relativePath + filename;
  1.1317 +        HtmlTree link = HtmlTree.LINK("stylesheet", "text/css", filename, "Style");
  1.1318 +        return link;
  1.1319 +    }
  1.1320 +
  1.1321 +    /**
  1.1322       * According to the Java Language Specifications, all the outer classes
  1.1323       * and static nested classes are core classes.
  1.1324       */
  1.1325 @@ -1768,6 +2540,17 @@
  1.1326      }
  1.1327  
  1.1328      /**
  1.1329 +     * Adds the annotatation types for the given packageDoc.
  1.1330 +     *
  1.1331 +     * @param packageDoc the package to write annotations for.
  1.1332 +     * @param htmltree the documentation tree to which the annotation info will be
  1.1333 +     *        added
  1.1334 +     */
  1.1335 +    public void addAnnotationInfo(PackageDoc packageDoc, Content htmltree) {
  1.1336 +        addAnnotationInfo(packageDoc, packageDoc.annotations(), htmltree);
  1.1337 +    }
  1.1338 +
  1.1339 +    /**
  1.1340       * Write the annotatation types for the given doc.
  1.1341       *
  1.1342       * @param doc the doc to write annotations for.
  1.1343 @@ -1777,6 +2560,16 @@
  1.1344      }
  1.1345  
  1.1346      /**
  1.1347 +     * Adds the annotatation types for the given doc.
  1.1348 +     *
  1.1349 +     * @param packageDoc the package to write annotations for
  1.1350 +     * @param htmltree the content tree to which the annotation types will be added
  1.1351 +     */
  1.1352 +    public void addAnnotationInfo(ProgramElementDoc doc, Content htmltree) {
  1.1353 +        addAnnotationInfo(doc, doc.annotations(), htmltree);
  1.1354 +    }
  1.1355 +
  1.1356 +    /**
  1.1357       * Write the annotatation types for the given doc and parameter.
  1.1358       *
  1.1359       * @param indent the number of spaced to indent the parameters.
  1.1360 @@ -1788,6 +2581,19 @@
  1.1361      }
  1.1362  
  1.1363      /**
  1.1364 +     * Add the annotatation types for the given doc and parameter.
  1.1365 +     *
  1.1366 +     * @param indent the number of spaces to indent the parameters.
  1.1367 +     * @param doc the doc to write annotations for.
  1.1368 +     * @param param the parameter to write annotations for.
  1.1369 +     * @param tree the content tree to which the annotation types will be added
  1.1370 +     */
  1.1371 +    public boolean addAnnotationInfo(int indent, Doc doc, Parameter param,
  1.1372 +            Content tree) {
  1.1373 +        return addAnnotationInfo(indent, doc, param.annotations(), false, tree);
  1.1374 +    }
  1.1375 +
  1.1376 +    /**
  1.1377       * Write the annotatation types for the given doc.
  1.1378       *
  1.1379       * @param doc the doc to write annotations for.
  1.1380 @@ -1798,6 +2604,19 @@
  1.1381      }
  1.1382  
  1.1383      /**
  1.1384 +     * Adds the annotatation types for the given doc.
  1.1385 +     *
  1.1386 +     * @param doc the doc to write annotations for.
  1.1387 +     * @param descList the array of {@link AnnotationDesc}.
  1.1388 +     * @param htmltree the documentation tree to which the annotation info will be
  1.1389 +     *        added
  1.1390 +     */
  1.1391 +    private void addAnnotationInfo(Doc doc, AnnotationDesc[] descList,
  1.1392 +            Content htmltree) {
  1.1393 +        addAnnotationInfo(0, doc, descList, true, htmltree);
  1.1394 +    }
  1.1395 +
  1.1396 +    /**
  1.1397       * Write the annotatation types for the given doc.
  1.1398       *
  1.1399       * @param indent the number of extra spaces to indent the annotations.
  1.1400 @@ -1818,6 +2637,29 @@
  1.1401      }
  1.1402  
  1.1403      /**
  1.1404 +     * Adds the annotatation types for the given doc.
  1.1405 +     *
  1.1406 +     * @param indent the number of extra spaces to indent the annotations.
  1.1407 +     * @param doc the doc to write annotations for.
  1.1408 +     * @param descList the array of {@link AnnotationDesc}.
  1.1409 +     * @param htmltree the documentation tree to which the annotation info will be
  1.1410 +     *        added
  1.1411 +     */
  1.1412 +    private boolean addAnnotationInfo(int indent, Doc doc,
  1.1413 +            AnnotationDesc[] descList, boolean lineBreak, Content htmltree) {
  1.1414 +        List<String> annotations = getAnnotations(indent, descList, lineBreak);
  1.1415 +        if (annotations.size() == 0) {
  1.1416 +            return false;
  1.1417 +        }
  1.1418 +        Content annotationContent;
  1.1419 +        for (Iterator<String> iter = annotations.iterator(); iter.hasNext();) {
  1.1420 +            annotationContent = new RawHtml(iter.next());
  1.1421 +            htmltree.addContent(annotationContent);
  1.1422 +        }
  1.1423 +        return true;
  1.1424 +    }
  1.1425 +
  1.1426 +   /**
  1.1427       * Return the string representations of the annotation types for
  1.1428       * the given doc.
  1.1429       *

mercurial