Sun, 11 Apr 2010 23:24:24 -0700
6875904: Java 7 message synchronization 1
Reviewed-by: ogino, faryad
1 /*
2 * Copyright 2001-2008 Sun Microsystems, Inc. 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. Sun designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 * have any questions.
24 */
26 package com.sun.tools.doclets.formats.html;
28 import com.sun.tools.doclets.internal.toolkit.*;
29 import com.sun.tools.doclets.internal.toolkit.util.*;
30 import com.sun.javadoc.*;
31 import java.io.*;
32 import java.util.*;
34 /**
35 * Write the Constants Summary Page in HTML format.
36 *
37 * @author Jamie Ho
38 * @author Bhavesh Patel (Modified)
39 * @since 1.4
40 */
41 public class ConstantsSummaryWriterImpl extends HtmlDocletWriter
42 implements ConstantsSummaryWriter {
44 /**
45 * The configuration used in this run of the standard doclet.
46 */
47 ConfigurationImpl configuration;
49 /**
50 * The current class being documented.
51 */
52 private ClassDoc currentClassDoc;
54 private final String constantsTableSummary;
56 private final String[] constantsTableHeader;
58 /**
59 * Construct a ConstantsSummaryWriter.
60 * @param configuration the configuration used in this run
61 * of the standard doclet.
62 */
63 public ConstantsSummaryWriterImpl(ConfigurationImpl configuration)
64 throws IOException {
65 super(configuration, ConfigurationImpl.CONSTANTS_FILE_NAME);
66 this.configuration = configuration;
67 constantsTableSummary = configuration.getText("doclet.Constants_Table_Summary",
68 configuration.getText("doclet.Constants_Summary"));
69 constantsTableHeader = new String[] {
70 getModifierTypeHeader(),
71 configuration.getText("doclet.ConstantField"),
72 configuration.getText("doclet.Value")
73 };
74 }
76 /**
77 * {@inheritDoc}
78 */
79 public void writeHeader() {
80 printHtmlHeader(configuration.getText("doclet.Constants_Summary"),
81 null, true);
82 printTop();
83 navLinks(true);
84 hr();
86 center();
87 h1(); printText("doclet.Constants_Summary"); h1End();
88 centerEnd();
90 hr(4, "noshade");
91 }
93 /**
94 * {@inheritDoc}
95 */
96 public void writeFooter() {
97 hr();
98 navLinks(false);
99 printBottom();
100 printBodyHtmlEnd();
101 }
103 /**
104 * {@inheritDoc}
105 */
106 public void writeContentsHeader() {
107 strong(configuration.getText("doclet.Contents"));
108 ul();
109 }
111 /**
112 * {@inheritDoc}
113 */
114 public void writeContentsFooter() {
115 ulEnd();
116 println();
117 }
119 /**
120 * {@inheritDoc}
121 */
122 public void writeLinkToPackageContent(PackageDoc pkg, String parsedPackageName, Set<String> printedPackageHeaders) {
123 String packageName = pkg.name();
124 //add link to summary
125 li();
126 if (packageName.length() == 0) {
127 printHyperLink("#" + DocletConstants.UNNAMED_PACKAGE_ANCHOR,
128 DocletConstants.DEFAULT_PACKAGE_NAME);
129 } else {
130 printHyperLink("#" + parsedPackageName, parsedPackageName + ".*");
131 printedPackageHeaders.add(parsedPackageName);
132 }
133 println();
134 }
136 /**
137 * {@inheritDoc}
138 */
139 public void writeConstantMembersHeader(ClassDoc cd) {
140 //generate links backward only to public classes.
141 String classlink = (cd.isPublic() || cd.isProtected())?
142 getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CONSTANT_SUMMARY, cd,
143 false)) :
144 cd.qualifiedName();
145 String name = cd.containingPackage().name();
146 if (name.length() > 0) {
147 writeClassName(name + "." + classlink);
148 } else {
149 writeClassName(classlink);
150 }
151 }
153 /**
154 * {@inheritDoc}
155 */
156 public void writeConstantMembersFooter(ClassDoc cd) {
157 tableFooter(false);
158 p();
159 }
161 /**
162 * Print the class name in the table heading.
163 * @param classStr the heading to print.
164 */
165 protected void writeClassName(String classStr) {
166 table(1, 3, 0, constantsTableSummary);
167 tableSubCaptionStart();
168 write(classStr);
169 tableCaptionEnd();
170 summaryTableHeader(constantsTableHeader, "col");
171 }
173 private void tableFooter(boolean isHeader) {
174 fontEnd();
175 if (isHeader) {
176 thEnd();
177 } else {
178 tdEnd();
179 }
180 trEnd();
181 tableEnd();
182 p();
183 }
185 /**
186 * {@inheritDoc}
187 */
188 public void writePackageName(PackageDoc pkg, String parsedPackageName) {
189 String pkgname;
190 if (parsedPackageName.length() == 0) {
191 anchor(DocletConstants.UNNAMED_PACKAGE_ANCHOR);
192 pkgname = DocletConstants.DEFAULT_PACKAGE_NAME;
193 } else {
194 anchor(parsedPackageName);
195 pkgname = parsedPackageName;
196 }
197 table(1, "100%", 3, 0);
198 trBgcolorStyle("#CCCCFF", "TableHeadingColor");
199 thAlign("left");
200 font("+2");
201 write(pkgname + ".*");
202 tableFooter(true);
203 }
205 /**
206 * {@inheritDoc}
207 */
208 public void writeConstantMembers(ClassDoc cd, List<FieldDoc> fields) {
209 currentClassDoc = cd;
210 for (int i = 0; i < fields.size(); ++i) {
211 writeConstantMember(fields.get(i));
212 }
213 }
215 private void writeConstantMember(FieldDoc member) {
216 trBgcolorStyle("white", "TableRowColor");
217 anchor(currentClassDoc.qualifiedName() + "." + member.name());
218 writeTypeColumn(member);
219 writeNameColumn(member);
220 writeValue(member);
221 trEnd();
222 }
224 private void writeTypeColumn(FieldDoc member) {
225 tdAlign("right");
226 font("-1");
227 code();
228 StringTokenizer mods = new StringTokenizer(member.modifiers());
229 while(mods.hasMoreTokens()) {
230 print(mods.nextToken() + " ");
231 }
232 printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CONSTANT_SUMMARY,
233 member.type()));
234 codeEnd();
235 fontEnd();
236 tdEnd();
237 }
239 private void writeNameColumn(FieldDoc member) {
240 tdAlign("left");
241 code();
242 printDocLink(LinkInfoImpl.CONTEXT_CONSTANT_SUMMARY, member,
243 member.name(), false);
244 codeEnd();
245 tdEnd();
246 }
248 private void writeValue(FieldDoc member) {
249 tdAlign("right");
250 code();
251 print(Util.escapeHtmlChars(member.constantValueExpression()));
252 codeEnd();
253 tdEnd();
254 }
255 }