Thu, 13 Jan 2011 21:28:38 -0800
7010528: javadoc performance regression
Reviewed-by: jjg
1 /*
2 * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
26 package com.sun.tools.doclets.formats.html;
28 import java.io.*;
29 import com.sun.javadoc.*;
30 import com.sun.tools.doclets.internal.toolkit.*;
31 import com.sun.tools.doclets.internal.toolkit.util.*;
32 import com.sun.tools.doclets.formats.html.markup.*;
34 /**
35 * Generate the package index for the left-hand frame in the generated output.
36 * A click on the package name in this frame will update the page in the bottom
37 * left hand frame with the listing of contents of the clicked package.
38 *
39 * @author Atul M Dambalkar
40 */
41 public class PackageIndexFrameWriter extends AbstractPackageIndexWriter {
43 /**
44 * Construct the PackageIndexFrameWriter object.
45 *
46 * @param filename Name of the package index file to be generated.
47 */
48 public PackageIndexFrameWriter(ConfigurationImpl configuration,
49 String filename) throws IOException {
50 super(configuration, filename);
51 }
53 /**
54 * Generate the package index file named "overview-frame.html".
55 * @throws DocletAbortException
56 */
57 public static void generate(ConfigurationImpl configuration) {
58 PackageIndexFrameWriter packgen;
59 String filename = "overview-frame.html";
60 try {
61 packgen = new PackageIndexFrameWriter(configuration, filename);
62 packgen.buildPackageIndexFile("doclet.Window_Overview", false);
63 packgen.close();
64 } catch (IOException exc) {
65 configuration.standardmessage.error(
66 "doclet.exception_encountered",
67 exc.toString(), filename);
68 throw new DocletAbortException();
69 }
70 }
72 /**
73 * {@inheritDoc}
74 */
75 protected void addPackagesList(PackageDoc[] packages, String text,
76 String tableSummary, Content body) {
77 Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true,
78 packagesLabel);
79 Content div = HtmlTree.DIV(HtmlStyle.indexContainer, heading);
80 HtmlTree ul = new HtmlTree(HtmlTag.UL);
81 ul.addAttr(HtmlAttr.TITLE, packagesLabel.toString());
82 for(int i = 0; i < packages.length; i++) {
83 if (packages[i] != null) {
84 ul.addContent(getPackage(packages[i]));
85 }
86 }
87 div.addContent(ul);
88 body.addContent(div);
89 }
91 /**
92 * Gets each package name as a separate link.
93 *
94 * @param pd PackageDoc
95 * @return content for the package link
96 */
97 protected Content getPackage(PackageDoc pd) {
98 Content packageLinkContent;
99 Content packageLabel;
100 if (pd.name().length() > 0) {
101 packageLabel = getPackageLabel(pd.name());
102 packageLinkContent = getHyperLink(pathString(pd,
103 "package-frame.html"), "", packageLabel, "",
104 "packageFrame");
105 } else {
106 packageLabel = new RawHtml("<unnamed package>");
107 packageLinkContent = getHyperLink("package-frame.html",
108 "", packageLabel, "", "packageFrame");
109 }
110 Content li = HtmlTree.LI(packageLinkContent);
111 return li;
112 }
114 /**
115 * {@inheritDoc}
116 */
117 protected void addNavigationBarHeader(Content body) {
118 Content headerContent;
119 if (configuration.packagesheader.length() > 0) {
120 headerContent = new RawHtml(replaceDocRootDir(configuration.packagesheader));
121 } else {
122 headerContent = new RawHtml(replaceDocRootDir(configuration.header));
123 }
124 Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
125 HtmlStyle.bar, headerContent);
126 body.addContent(heading);
127 }
129 /**
130 * Do nothing as there is no overview information in this page.
131 */
132 protected void addOverviewHeader(Content body) {
133 }
135 /**
136 * Adds "All Classes" link for the top of the left-hand frame page to the
137 * documentation tree.
138 *
139 * @param body the Content object to which the all classes link should be added
140 */
141 protected void addAllClassesLink(Content body) {
142 Content linkContent = getHyperLink("allclasses-frame.html", "",
143 allclassesLabel, "", "packageFrame");
144 Content div = HtmlTree.DIV(HtmlStyle.indexHeader, linkContent);
145 body.addContent(div);
146 }
148 /**
149 * {@inheritDoc}
150 */
151 protected void addNavigationBarFooter(Content body) {
152 Content p = HtmlTree.P(getSpace());
153 body.addContent(p);
154 }
155 }