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) 1997, 2004, 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 |
||
2216
b124d5c924eb
6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents:
1787
diff
changeset
|
28 |
import java.io.*; |
b124d5c924eb
6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents:
1787
diff
changeset
|
29 |
|
b124d5c924eb
6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents:
1787
diff
changeset
|
30 |
import com.sun.javadoc.*; |
10 | 31 |
import com.sun.tools.doclets.internal.toolkit.*; |
32 |
import com.sun.tools.doclets.internal.toolkit.util.*; |
|
33 |
||
34 |
/** |
|
35 |
* Writes field documentation in HTML format. |
|
36 |
* |
|
37 |
* @author Robert Field |
|
38 |
* @author Atul M Dambalkar |
|
39 |
* @author Jamie Ho (rewrite) |
|
2320
5b8c377175f4
6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents:
2216
diff
changeset
|
40 |
* @author Bhavesh Patel (Modified) |
10 | 41 |
*/ |
42 |
public class FieldWriterImpl extends AbstractMemberWriter |
|
43 |
implements FieldWriter, MemberSummaryWriter { |
|
44 |
||
45 |
private boolean printedSummaryHeader = false; |
|
46 |
||
47 |
public FieldWriterImpl(SubWriterHolderWriter writer, ClassDoc classdoc) { |
|
48 |
super(writer, classdoc); |
|
49 |
} |
|
50 |
||
51 |
public FieldWriterImpl(SubWriterHolderWriter writer) { |
|
52 |
super(writer); |
|
53 |
} |
|
54 |
||
55 |
/** |
|
56 |
* Write the fields summary header for the given class. |
|
57 |
* |
|
58 |
* @param classDoc the class the summary belongs to. |
|
59 |
*/ |
|
60 |
public void writeMemberSummaryHeader(ClassDoc classDoc) { |
|
61 |
printedSummaryHeader = true; |
|
62 |
writer.println("<!-- =========== FIELD SUMMARY =========== -->"); |
|
63 |
writer.println(); |
|
64 |
writer.printSummaryHeader(this, classDoc); |
|
65 |
} |
|
66 |
||
67 |
/** |
|
68 |
* Write the fields summary footer for the given class. |
|
69 |
* |
|
70 |
* @param classDoc the class the summary belongs to. |
|
71 |
*/ |
|
72 |
public void writeMemberSummaryFooter(ClassDoc classDoc) { |
|
73 |
writer.tableEnd(); |
|
74 |
writer.space(); |
|
75 |
} |
|
76 |
||
77 |
/** |
|
78 |
* Write the inherited fields summary header for the given class. |
|
79 |
* |
|
80 |
* @param classDoc the class the summary belongs to. |
|
81 |
*/ |
|
82 |
public void writeInheritedMemberSummaryHeader(ClassDoc classDoc) { |
|
83 |
if(! printedSummaryHeader){ |
|
84 |
//We don't want inherited summary to not be under heading. |
|
85 |
writeMemberSummaryHeader(classDoc); |
|
86 |
writeMemberSummaryFooter(classDoc); |
|
87 |
printedSummaryHeader = true; |
|
88 |
} |
|
89 |
writer.printInheritedSummaryHeader(this, classDoc); |
|
90 |
} |
|
91 |
||
92 |
/** |
|
93 |
* {@inheritDoc} |
|
94 |
*/ |
|
95 |
public void writeInheritedMemberSummary(ClassDoc classDoc, |
|
96 |
ProgramElementDoc field, boolean isFirst, boolean isLast) { |
|
97 |
writer.printInheritedSummaryMember(this, classDoc, field, isFirst); |
|
98 |
} |
|
99 |
||
100 |
/** |
|
101 |
* Write the inherited fields summary footer for the given class. |
|
102 |
* |
|
103 |
* @param classDoc the class the summary belongs to. |
|
104 |
*/ |
|
105 |
public void writeInheritedMemberSummaryFooter(ClassDoc classDoc) { |
|
106 |
writer.printInheritedSummaryFooter(this, classDoc); |
|
107 |
} |
|
108 |
||
109 |
/** |
|
110 |
* Write the header for the field documentation. |
|
111 |
* |
|
112 |
* @param classDoc the class that the fields belong to. |
|
113 |
*/ |
|
114 |
public void writeHeader(ClassDoc classDoc, String header) { |
|
115 |
writer.println(); |
|
116 |
writer.println("<!-- ============ FIELD DETAIL =========== -->"); |
|
117 |
writer.println(); |
|
118 |
writer.anchor("field_detail"); |
|
119 |
writer.printTableHeadingBackground(header); |
|
120 |
writer.println(); |
|
121 |
} |
|
122 |
||
123 |
/** |
|
124 |
* Write the field header for the given field. |
|
125 |
* |
|
126 |
* @param field the field being documented. |
|
127 |
* @param isFirst the flag to indicate whether or not the field is the |
|
128 |
* first to be documented. |
|
129 |
*/ |
|
130 |
public void writeFieldHeader(FieldDoc field, boolean isFirst) { |
|
131 |
if (! isFirst) { |
|
132 |
writer.printMemberHeader(); |
|
133 |
writer.println(""); |
|
134 |
} |
|
135 |
writer.anchor(field.name()); |
|
136 |
writer.h3(); |
|
137 |
writer.print(field.name()); |
|
138 |
writer.h3End(); |
|
139 |
} |
|
140 |
||
141 |
/** |
|
142 |
* Write the signature for the given field. |
|
143 |
* |
|
144 |
* @param field the field being documented. |
|
145 |
*/ |
|
146 |
public void writeSignature(FieldDoc field) { |
|
147 |
writer.pre(); |
|
148 |
writer.writeAnnotationInfo(field); |
|
149 |
printModifiers(field); |
|
150 |
writer.printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER, |
|
151 |
field.type())); |
|
152 |
print(' '); |
|
153 |
if (configuration().linksource) { |
|
154 |
writer.printSrcLink(field, field.name()); |
|
155 |
} else { |
|
1787
1aa079321cd2
6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents:
10
diff
changeset
|
156 |
strong(field.name()); |
10 | 157 |
} |
158 |
writer.preEnd(); |
|
2216
b124d5c924eb
6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents:
1787
diff
changeset
|
159 |
assert !writer.getMemberDetailsListPrinted(); |
10 | 160 |
} |
161 |
||
162 |
/** |
|
163 |
* Write the deprecated output for the given field. |
|
164 |
* |
|
165 |
* @param field the field being documented. |
|
166 |
*/ |
|
167 |
public void writeDeprecated(FieldDoc field) { |
|
2216
b124d5c924eb
6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents:
1787
diff
changeset
|
168 |
printDeprecated(field); |
10 | 169 |
} |
170 |
||
171 |
/** |
|
172 |
* Write the comments for the given field. |
|
173 |
* |
|
174 |
* @param field the field being documented. |
|
175 |
*/ |
|
176 |
public void writeComments(FieldDoc field) { |
|
177 |
ClassDoc holder = field.containingClass(); |
|
178 |
if (field.inlineTags().length > 0) { |
|
2216
b124d5c924eb
6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents:
1787
diff
changeset
|
179 |
writer.printMemberDetailsListStartTag(); |
10 | 180 |
if (holder.equals(classdoc) || |
181 |
(! (holder.isPublic() || Util.isLinkable(holder, configuration())))) { |
|
182 |
writer.dd(); |
|
183 |
writer.printInlineComment(field); |
|
2216
b124d5c924eb
6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents:
1787
diff
changeset
|
184 |
writer.ddEnd(); |
10 | 185 |
} else { |
186 |
String classlink = writer.codeText( |
|
187 |
writer.getDocLink(LinkInfoImpl.CONTEXT_FIELD_DOC_COPY, |
|
188 |
holder, field, |
|
189 |
holder.isIncluded() ? |
|
190 |
holder.typeName() : holder.qualifiedTypeName(), |
|
191 |
false)); |
|
192 |
writer.dd(); |
|
1787
1aa079321cd2
6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents:
10
diff
changeset
|
193 |
writer.strong(configuration().getText(holder.isClass()? |
10 | 194 |
"doclet.Description_From_Class" : |
195 |
"doclet.Description_From_Interface", classlink)); |
|
196 |
writer.ddEnd(); |
|
197 |
writer.dd(); |
|
198 |
writer.printInlineComment(field); |
|
2216
b124d5c924eb
6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents:
1787
diff
changeset
|
199 |
writer.ddEnd(); |
10 | 200 |
} |
201 |
} |
|
202 |
} |
|
203 |
||
204 |
/** |
|
205 |
* Write the tag output for the given field. |
|
206 |
* |
|
207 |
* @param field the field being documented. |
|
208 |
*/ |
|
209 |
public void writeTags(FieldDoc field) { |
|
210 |
writer.printTags(field); |
|
211 |
} |
|
212 |
||
213 |
/** |
|
214 |
* Write the field footer. |
|
215 |
*/ |
|
216 |
public void writeFieldFooter() { |
|
2216
b124d5c924eb
6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents:
1787
diff
changeset
|
217 |
printMemberFooter(); |
10 | 218 |
} |
219 |
||
220 |
/** |
|
221 |
* Write the footer for the field documentation. |
|
222 |
* |
|
223 |
* @param classDoc the class that the fields belong to. |
|
224 |
*/ |
|
225 |
public void writeFooter(ClassDoc classDoc) { |
|
226 |
//No footer to write for field documentation |
|
227 |
} |
|
228 |
||
229 |
/** |
|
230 |
* Close the writer. |
|
231 |
*/ |
|
232 |
public void close() throws IOException { |
|
233 |
writer.close(); |
|
234 |
} |
|
235 |
||
236 |
public int getMemberKind() { |
|
237 |
return VisibleMemberMap.FIELDS; |
|
238 |
} |
|
239 |
||
2320
5b8c377175f4
6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents:
2216
diff
changeset
|
240 |
public void printSummaryLabel() { |
5b8c377175f4
6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents:
2216
diff
changeset
|
241 |
writer.printText("doclet.Field_Summary"); |
5b8c377175f4
6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents:
2216
diff
changeset
|
242 |
} |
5b8c377175f4
6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents:
2216
diff
changeset
|
243 |
|
5b8c377175f4
6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents:
2216
diff
changeset
|
244 |
public void printTableSummary() { |
5b8c377175f4
6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents:
2216
diff
changeset
|
245 |
writer.tableIndexSummary(configuration().getText("doclet.Member_Table_Summary", |
5b8c377175f4
6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents:
2216
diff
changeset
|
246 |
configuration().getText("doclet.Field_Summary"), |
5b8c377175f4
6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents:
2216
diff
changeset
|
247 |
configuration().getText("doclet.fields"))); |
5b8c377175f4
6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents:
2216
diff
changeset
|
248 |
} |
5b8c377175f4
6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents:
2216
diff
changeset
|
249 |
|
5b8c377175f4
6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents:
2216
diff
changeset
|
250 |
public void printSummaryTableHeader(ProgramElementDoc member) { |
5b8c377175f4
6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents:
2216
diff
changeset
|
251 |
String[] header = new String[] { |
5b8c377175f4
6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents:
2216
diff
changeset
|
252 |
writer.getModifierTypeHeader(), |
5b8c377175f4
6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents:
2216
diff
changeset
|
253 |
configuration().getText("doclet.0_and_1", |
5b8c377175f4
6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents:
2216
diff
changeset
|
254 |
configuration().getText("doclet.Field"), |
5b8c377175f4
6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents:
2216
diff
changeset
|
255 |
configuration().getText("doclet.Description")) |
5b8c377175f4
6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents:
2216
diff
changeset
|
256 |
}; |
5b8c377175f4
6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents:
2216
diff
changeset
|
257 |
writer.summaryTableHeader(header, "col"); |
10 | 258 |
} |
259 |
||
260 |
public void printSummaryAnchor(ClassDoc cd) { |
|
261 |
writer.anchor("field_summary"); |
|
262 |
} |
|
263 |
||
264 |
public void printInheritedSummaryAnchor(ClassDoc cd) { |
|
265 |
writer.anchor("fields_inherited_from_class_" + configuration().getClassName(cd)); |
|
266 |
} |
|
267 |
||
268 |
public void printInheritedSummaryLabel(ClassDoc cd) { |
|
269 |
String classlink = writer.getPreQualifiedClassLink( |
|
270 |
LinkInfoImpl.CONTEXT_MEMBER, cd, false); |
|
1787
1aa079321cd2
6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents:
10
diff
changeset
|
271 |
writer.strong(); |
10 | 272 |
String key = cd.isClass()? |
273 |
"doclet.Fields_Inherited_From_Class" : |
|
274 |
"doclet.Fields_Inherited_From_Interface"; |
|
275 |
writer.printText(key, classlink); |
|
1787
1aa079321cd2
6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents:
10
diff
changeset
|
276 |
writer.strongEnd(); |
10 | 277 |
} |
278 |
||
279 |
protected void writeSummaryLink(int context, ClassDoc cd, ProgramElementDoc member) { |
|
1787
1aa079321cd2
6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents:
10
diff
changeset
|
280 |
writer.strong(); |
10 | 281 |
writer.printDocLink(context, cd , (MemberDoc) member, member.name(), false); |
1787
1aa079321cd2
6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents:
10
diff
changeset
|
282 |
writer.strongEnd(); |
10 | 283 |
} |
284 |
||
285 |
protected void writeInheritedSummaryLink(ClassDoc cd, |
|
286 |
ProgramElementDoc member) { |
|
287 |
writer.printDocLink(LinkInfoImpl.CONTEXT_MEMBER, cd, (MemberDoc)member, |
|
288 |
member.name(), false); |
|
289 |
} |
|
290 |
||
291 |
protected void printSummaryType(ProgramElementDoc member) { |
|
292 |
FieldDoc field = (FieldDoc)member; |
|
293 |
printModifierAndType(field, field.type()); |
|
294 |
} |
|
295 |
||
296 |
protected void writeDeprecatedLink(ProgramElementDoc member) { |
|
297 |
writer.printDocLink(LinkInfoImpl.CONTEXT_MEMBER, |
|
298 |
(MemberDoc) member, ((FieldDoc)member).qualifiedName(), false); |
|
299 |
} |
|
300 |
||
301 |
protected void printNavSummaryLink(ClassDoc cd, boolean link) { |
|
302 |
if (link) { |
|
303 |
writer.printHyperLink("", (cd == null)? |
|
304 |
"field_summary": |
|
305 |
"fields_inherited_from_class_" + |
|
306 |
configuration().getClassName(cd), |
|
307 |
configuration().getText("doclet.navField")); |
|
308 |
} else { |
|
309 |
writer.printText("doclet.navField"); |
|
310 |
} |
|
311 |
} |
|
312 |
||
313 |
protected void printNavDetailLink(boolean link) { |
|
314 |
if (link) { |
|
315 |
writer.printHyperLink("", "field_detail", |
|
316 |
configuration().getText("doclet.navField")); |
|
317 |
} else { |
|
318 |
writer.printText("doclet.navField"); |
|
319 |
} |
|
320 |
} |
|
321 |
} |