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.formats.html.markup.*;
31 import com.sun.tools.doclets.internal.toolkit.*;
33 /**
34 * Generate the Serialized Form Information Page.
35 *
36 * @author Atul M Dambalkar
37 */
38 public class SerializedFormWriterImpl extends SubWriterHolderWriter
39 implements com.sun.tools.doclets.internal.toolkit.SerializedFormWriter {
41 private static final String FILE_NAME = "serialized-form.html";
43 /**
44 * @throws IOException
45 * @throws DocletAbortException
46 */
47 public SerializedFormWriterImpl() throws IOException {
48 super(ConfigurationImpl.getInstance(), FILE_NAME);
49 }
51 /**
52 * Writes the given header.
53 *
54 * @param header the header to write.
55 */
56 public void writeHeader(String header) {
57 printHtmlHeader(header, null, true);
58 printTop();
59 navLinks(true);
60 hr();
61 center();
62 h1();
63 print(header);
64 h1End();
65 centerEnd();
66 }
68 /**
69 * Get the given header.
70 *
71 * @param header the header to write
72 * @return the body content tree
73 */
74 public Content getHeader(String header) {
75 Content bodyTree = getBody(true, getWindowTitle(header));
76 addTop(bodyTree);
77 addNavLinks(true, bodyTree);
78 Content h1Content = new StringContent(header);
79 Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
80 HtmlStyle.title, h1Content);
81 Content div = HtmlTree.DIV(HtmlStyle.header, heading);
82 bodyTree.addContent(div);
83 return bodyTree;
84 }
86 /**
87 * Get the serialized form summaries header.
88 *
89 * @return the serialized form summary header tree
90 */
91 public Content getSerializedSummariesHeader() {
92 HtmlTree ul = new HtmlTree(HtmlTag.UL);
93 ul.addStyle(HtmlStyle.blockList);
94 return ul;
95 }
97 /**
98 * Get the package serialized form header.
99 *
100 * @return the package serialized form header tree
101 */
102 public Content getPackageSerializedHeader() {
103 HtmlTree li = new HtmlTree(HtmlTag.LI);
104 li.addStyle(HtmlStyle.blockList);
105 return li;
106 }
108 /**
109 * Get the given package header.
110 *
111 * @param packageName the package header to write
112 * @return a content tree for the package header
113 */
114 public Content getPackageHeader(String packageName) {
115 Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true,
116 packageLabel);
117 heading.addContent(getSpace());
118 heading.addContent(packageName);
119 return heading;
120 }
122 /**
123 * Get the serialized class header.
124 *
125 * @return a content tree for the serialized class header
126 */
127 public Content getClassSerializedHeader() {
128 HtmlTree ul = new HtmlTree(HtmlTag.UL);
129 ul.addStyle(HtmlStyle.blockList);
130 return ul;
131 }
133 /**
134 * Get the serializable class heading.
135 *
136 * @param classDoc the class being processed
137 * @return a content tree for the class header
138 */
139 public Content getClassHeader(ClassDoc classDoc) {
140 String classLink = (classDoc.isPublic() || classDoc.isProtected())?
141 getLink(new LinkInfoImpl(classDoc,
142 configuration.getClassName(classDoc))):
143 classDoc.qualifiedName();
144 Content li = HtmlTree.LI(HtmlStyle.blockList, getMarkerAnchor(
145 classDoc.qualifiedName()));
146 String superClassLink =
147 classDoc.superclassType() != null ?
148 getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_SERIALIZED_FORM,
149 classDoc.superclassType())) :
150 null;
152 //Print the heading.
153 String className = superClassLink == null ?
154 configuration.getText(
155 "doclet.Class_0_implements_serializable", classLink) :
156 configuration.getText(
157 "doclet.Class_0_extends_implements_serializable", classLink,
158 superClassLink);
159 Content classNameContent = new RawHtml(className);
160 li.addContent(HtmlTree.HEADING(HtmlConstants.SERIALIZED_MEMBER_HEADING,
161 classNameContent));
162 return li;
163 }
165 /**
166 * Get the serial UID info header.
167 *
168 * @return a content tree for the serial uid info header
169 */
170 public Content getSerialUIDInfoHeader() {
171 HtmlTree dl = new HtmlTree(HtmlTag.DL);
172 dl.addStyle(HtmlStyle.nameValue);
173 return dl;
174 }
176 /**
177 * Adds the serial UID info.
178 *
179 * @param header the header that will show up before the UID.
180 * @param serialUID the serial UID to print.
181 * @param serialUidTree the serial UID content tree to which the serial UID
182 * content will be added
183 */
184 public void addSerialUIDInfo(String header, String serialUID,
185 Content serialUidTree) {
186 Content headerContent = new StringContent(header);
187 serialUidTree.addContent(HtmlTree.DT(headerContent));
188 Content serialContent = new StringContent(serialUID);
189 serialUidTree.addContent(HtmlTree.DD(serialContent));
190 }
192 /**
193 * Get the class serialize content header.
194 *
195 * @return a content tree for the class serialize content header
196 */
197 public Content getClassContentHeader() {
198 HtmlTree ul = new HtmlTree(HtmlTag.UL);
199 ul.addStyle(HtmlStyle.blockList);
200 return ul;
201 }
203 /**
204 * Get the serialized content tree section.
205 *
206 * @param serializedTreeContent the serialized content tree to be added
207 * @return a div content tree
208 */
209 public Content getSerializedContent(Content serializedTreeContent) {
210 Content divContent = HtmlTree.DIV(HtmlStyle.serializedFormContainer,
211 serializedTreeContent);
212 return divContent;
213 }
215 /**
216 * Add the footer.
217 *
218 * @param serializedTree the serialized tree to be added
219 */
220 public void addFooter(Content serializedTree) {
221 addNavLinks(false, serializedTree);
222 addBottom(serializedTree);
223 }
225 /**
226 * {@inheritDoc}
227 */
228 public void printDocument(Content serializedTree) {
229 printHtmlDocument(null, true, serializedTree);
230 }
232 private void tableHeader() {
233 tableIndexSummary();
234 trBgcolorStyle("#CCCCFF", "TableSubHeadingColor");
235 }
237 private void tableFooter() {
238 fontEnd();
239 thEnd(); trEnd(); tableEnd();
240 }
242 /**
243 * Return an instance of a SerialFieldWriter.
244 *
245 * @return an instance of a SerialFieldWriter.
246 */
247 public SerialFieldWriter getSerialFieldWriter(ClassDoc classDoc) {
248 return new HtmlSerialFieldWriter(this, classDoc);
249 }
251 /**
252 * Return an instance of a SerialMethodWriter.
253 *
254 * @return an instance of a SerialMethodWriter.
255 */
256 public SerialMethodWriter getSerialMethodWriter(ClassDoc classDoc) {
257 return new HtmlSerialMethodWriter(this, classDoc);
258 }
259 }