author | ohair |
Tue, 25 May 2010 15:54:51 -0700 | |
changeset 5520 | 86e4b9a9da40 |
parent 2320 | 5b8c377175f4 |
child 7614 | cfadc977ca75 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
5520 | 2 |
* Copyright (c) 2001, 2008, Oracle and/or its affiliates. All rights reserved. |
10 | 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 |
|
5520 | 7 |
* published by the Free Software Foundation. Oracle designates this |
10 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5520 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
10 | 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 |
* |
|
5520 | 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. |
|
10 | 24 |
*/ |
25 |
||
26 |
package com.sun.tools.doclets.formats.html; |
|
27 |
||
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.*; |
|
33 |
||
34 |
/** |
|
35 |
* Write the Constants Summary Page in HTML format. |
|
36 |
* |
|
37 |
* @author Jamie Ho |
|
2320
5b8c377175f4
6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents:
1789
diff
changeset
|
38 |
* @author Bhavesh Patel (Modified) |
10 | 39 |
* @since 1.4 |
40 |
*/ |
|
41 |
public class ConstantsSummaryWriterImpl extends HtmlDocletWriter |
|
42 |
implements ConstantsSummaryWriter { |
|
43 |
||
44 |
/** |
|
45 |
* The configuration used in this run of the standard doclet. |
|
46 |
*/ |
|
47 |
ConfigurationImpl configuration; |
|
48 |
||
49 |
/** |
|
50 |
* The current class being documented. |
|
51 |
*/ |
|
52 |
private ClassDoc currentClassDoc; |
|
53 |
||
2320
5b8c377175f4
6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents:
1789
diff
changeset
|
54 |
private final String constantsTableSummary; |
5b8c377175f4
6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents:
1789
diff
changeset
|
55 |
|
5b8c377175f4
6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents:
1789
diff
changeset
|
56 |
private final String[] constantsTableHeader; |
5b8c377175f4
6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents:
1789
diff
changeset
|
57 |
|
10 | 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; |
|
2320
5b8c377175f4
6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents:
1789
diff
changeset
|
67 |
constantsTableSummary = configuration.getText("doclet.Constants_Table_Summary", |
5b8c377175f4
6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents:
1789
diff
changeset
|
68 |
configuration.getText("doclet.Constants_Summary")); |
5b8c377175f4
6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents:
1789
diff
changeset
|
69 |
constantsTableHeader = new String[] { |
5b8c377175f4
6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents:
1789
diff
changeset
|
70 |
getModifierTypeHeader(), |
5b8c377175f4
6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents:
1789
diff
changeset
|
71 |
configuration.getText("doclet.ConstantField"), |
5b8c377175f4
6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents:
1789
diff
changeset
|
72 |
configuration.getText("doclet.Value") |
5b8c377175f4
6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents:
1789
diff
changeset
|
73 |
}; |
10 | 74 |
} |
75 |
||
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(); |
|
85 |
||
86 |
center(); |
|
87 |
h1(); printText("doclet.Constants_Summary"); h1End(); |
|
88 |
centerEnd(); |
|
89 |
||
90 |
hr(4, "noshade"); |
|
91 |
} |
|
92 |
||
93 |
/** |
|
94 |
* {@inheritDoc} |
|
95 |
*/ |
|
96 |
public void writeFooter() { |
|
97 |
hr(); |
|
98 |
navLinks(false); |
|
99 |
printBottom(); |
|
100 |
printBodyHtmlEnd(); |
|
101 |
} |
|
102 |
||
103 |
/** |
|
104 |
* {@inheritDoc} |
|
105 |
*/ |
|
106 |
public void writeContentsHeader() { |
|
1787
1aa079321cd2
6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents:
1264
diff
changeset
|
107 |
strong(configuration.getText("doclet.Contents")); |
10 | 108 |
ul(); |
109 |
} |
|
110 |
||
111 |
/** |
|
112 |
* {@inheritDoc} |
|
113 |
*/ |
|
114 |
public void writeContentsFooter() { |
|
115 |
ulEnd(); |
|
116 |
println(); |
|
117 |
} |
|
118 |
||
119 |
/** |
|
120 |
* {@inheritDoc} |
|
121 |
*/ |
|
868 | 122 |
public void writeLinkToPackageContent(PackageDoc pkg, String parsedPackageName, Set<String> printedPackageHeaders) { |
10 | 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 |
} |
|
135 |
||
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 |
} |
|
152 |
||
153 |
/** |
|
154 |
* {@inheritDoc} |
|
155 |
*/ |
|
156 |
public void writeConstantMembersFooter(ClassDoc cd) { |
|
157 |
tableFooter(false); |
|
158 |
p(); |
|
159 |
} |
|
160 |
||
161 |
/** |
|
162 |
* Print the class name in the table heading. |
|
163 |
* @param classStr the heading to print. |
|
164 |
*/ |
|
165 |
protected void writeClassName(String classStr) { |
|
2320
5b8c377175f4
6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents:
1789
diff
changeset
|
166 |
table(1, 3, 0, constantsTableSummary); |
5b8c377175f4
6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents:
1789
diff
changeset
|
167 |
tableSubCaptionStart(); |
10 | 168 |
write(classStr); |
2320
5b8c377175f4
6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents:
1789
diff
changeset
|
169 |
tableCaptionEnd(); |
5b8c377175f4
6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents:
1789
diff
changeset
|
170 |
summaryTableHeader(constantsTableHeader, "col"); |
10 | 171 |
} |
172 |
||
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 |
} |
|
184 |
||
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 |
} |
|
204 |
||
205 |
/** |
|
206 |
* {@inheritDoc} |
|
207 |
*/ |
|
1789
7ac8c0815000
6765045: Remove rawtypes warnings from langtools
mcimadamore
parents:
1787
diff
changeset
|
208 |
public void writeConstantMembers(ClassDoc cd, List<FieldDoc> fields) { |
10 | 209 |
currentClassDoc = cd; |
210 |
for (int i = 0; i < fields.size(); ++i) { |
|
1789
7ac8c0815000
6765045: Remove rawtypes warnings from langtools
mcimadamore
parents:
1787
diff
changeset
|
211 |
writeConstantMember(fields.get(i)); |
10 | 212 |
} |
213 |
} |
|
214 |
||
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 |
} |
|
223 |
||
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 |
} |
|
238 |
||
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 |
} |
|
247 |
||
248 |
private void writeValue(FieldDoc member) { |
|
249 |
tdAlign("right"); |
|
250 |
code(); |
|
251 |
print(Util.escapeHtmlChars(member.constantValueExpression())); |
|
252 |
codeEnd(); |
|
253 |
tdEnd(); |
|
254 |
} |
|
255 |
} |