Fri, 27 Feb 2009 18:57:17 -0800
6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
Reviewed-by: jjg
1 /*
2 * Copyright 2003-2004 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 java.io.*;
30 import com.sun.javadoc.*;
31 import com.sun.tools.doclets.internal.toolkit.*;
33 /**
34 * Writes annotation type required member documentation in HTML format.
35 *
36 * @author Jamie Ho
37 */
38 public class AnnotationTypeRequiredMemberWriterImpl extends AbstractMemberWriter
39 implements AnnotationTypeRequiredMemberWriter, MemberSummaryWriter {
41 /**
42 * Construct a new AnnotationTypeRequiredMemberWriterImpl.
43 *
44 * @param writer the writer that will write the output.
45 * @param annotationType the AnnotationType that holds this member.
46 */
47 public AnnotationTypeRequiredMemberWriterImpl(SubWriterHolderWriter writer,
48 AnnotationTypeDoc annotationType) {
49 super(writer, annotationType);
50 }
52 /**
53 * Write the annotation type member summary header for the given class.
54 *
55 * @param classDoc the class the summary belongs to.
56 */
57 public void writeMemberSummaryHeader(ClassDoc classDoc) {
58 writer.println("<!-- =========== ANNOTATION TYPE REQUIRED MEMBER SUMMARY =========== -->");
59 writer.println();
60 writer.printSummaryHeader(this, classDoc);
61 }
63 /**
64 * Write the annotation type member summary footer for the given class.
65 *
66 * @param classDoc the class the summary belongs to.
67 */
68 public void writeMemberSummaryFooter(ClassDoc classDoc) {
69 writer.printSummaryFooter(this, classDoc);
70 }
72 /**
73 * {@inheritDoc}
74 */
75 public void writeInheritedMemberSummaryHeader(ClassDoc classDoc) {
76 //Not appliable.
77 }
79 /**
80 * {@inheritDoc}
81 */
82 public void writeInheritedMemberSummary(ClassDoc classDoc,
83 ProgramElementDoc member, boolean isFirst, boolean isLast) {
84 //Not appliable.
85 }
87 /**
88 * {@inheritDoc}
89 */
90 public void writeInheritedMemberSummaryFooter(ClassDoc classDoc) {
91 //Not appliable.
92 }
94 /**
95 * {@inheritDoc}
96 */
97 public void writeHeader(ClassDoc classDoc, String header) {
98 writer.println();
99 writer.println("<!-- ============ ANNOTATION TYPE MEMBER DETAIL =========== -->");
100 writer.println();
101 writer.anchor("annotation_type_element_detail");
102 writer.printTableHeadingBackground(header);
103 writer.println();
104 }
106 /**
107 * {@inheritDoc}
108 */
109 public void writeMemberHeader(MemberDoc member, boolean isFirst) {
110 if (! isFirst) {
111 writer.printMemberHeader();
112 writer.println("");
113 }
114 writer.anchor(member.name() + ((ExecutableMemberDoc) member).signature());
115 writer.h3();
116 writer.print(member.name());
117 writer.h3End();
118 }
120 /**
121 * {@inheritDoc}
122 */
123 public void writeSignature(MemberDoc member) {
124 writer.pre();
125 writer.writeAnnotationInfo(member);
126 printModifiers(member);
127 writer.printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER,
128 getType(member)));
129 print(' ');
130 if (configuration().linksource) {
131 writer.printSrcLink(member, member.name());
132 } else {
133 strong(member.name());
134 }
135 writer.preEnd();
136 assert !writer.getMemberDetailsListPrinted();
137 }
139 /**
140 * {@inheritDoc}
141 */
142 public void writeComments(MemberDoc member) {
143 printComment(member);
144 }
146 /**
147 * Write the tag output for the given member.
148 *
149 * @param member the member being documented.
150 */
151 public void writeTags(MemberDoc member) {
152 writer.printTags(member);
153 }
155 /**
156 * Write the annotation type member footer.
157 */
158 public void writeMemberFooter() {
159 printMemberFooter();
160 }
162 /**
163 * Write the footer for the annotation type member documentation.
164 *
165 * @param classDoc the class that the annotation type member belong to.
166 */
167 public void writeFooter(ClassDoc classDoc) {
168 //No footer to write for annotation type member documentation
169 }
171 /**
172 * Close the writer.
173 */
174 public void close() throws IOException {
175 writer.close();
176 }
178 /**
179 * {@inheritDoc}
180 */
181 public void printSummaryLabel(ClassDoc cd) {
182 writer.strongText("doclet.Annotation_Type_Required_Member_Summary");
183 }
185 /**
186 * {@inheritDoc}
187 */
188 public void printSummaryAnchor(ClassDoc cd) {
189 writer.anchor("annotation_type_required_element_summary");
190 }
192 /**
193 * {@inheritDoc}
194 */
195 public void printInheritedSummaryAnchor(ClassDoc cd) {
196 } // no such
198 /**
199 * {@inheritDoc}
200 */
201 public void printInheritedSummaryLabel(ClassDoc cd) {
202 // no such
203 }
205 /**
206 * {@inheritDoc}
207 */
208 protected void writeSummaryLink(int context, ClassDoc cd, ProgramElementDoc member) {
209 writer.strong();
210 writer.printDocLink(context, (MemberDoc) member, member.name(), false);
211 writer.strongEnd();
212 }
214 /**
215 * {@inheritDoc}
216 */
217 protected void writeInheritedSummaryLink(ClassDoc cd,
218 ProgramElementDoc member) {
219 //Not applicable.
220 }
222 /**
223 * {@inheritDoc}
224 */
225 protected void printSummaryType(ProgramElementDoc member) {
226 MemberDoc m = (MemberDoc)member;
227 printModifierAndType(m, getType(m));
228 }
230 /**
231 * {@inheritDoc}
232 */
233 protected void writeDeprecatedLink(ProgramElementDoc member) {
234 writer.printDocLink(LinkInfoImpl.CONTEXT_MEMBER,
235 (MemberDoc) member, ((MemberDoc)member).qualifiedName(), false);
236 }
238 /**
239 * {@inheritDoc}
240 */
241 protected void printNavSummaryLink(ClassDoc cd, boolean link) {
242 if (link) {
243 writer.printHyperLink("", "annotation_type_required_element_summary",
244 configuration().getText("doclet.navAnnotationTypeRequiredMember"));
245 } else {
246 writer.printText("doclet.navAnnotationTypeRequiredMember");
247 }
248 }
250 /**
251 * {@inheritDoc}
252 */
253 protected void printNavDetailLink(boolean link) {
254 if (link) {
255 writer.printHyperLink("", "annotation_type_element_detail",
256 configuration().getText("doclet.navAnnotationTypeMember"));
257 } else {
258 writer.printText("doclet.navAnnotationTypeMember");
259 }
260 }
262 /**
263 * {@inheritDoc}
264 */
265 public void writeDeprecated(MemberDoc member) {
266 printDeprecated(member);
267 }
269 private Type getType(MemberDoc member) {
270 if (member instanceof FieldDoc) {
271 return ((FieldDoc) member).type();
272 } else {
273 return ((MethodDoc) member).returnType();
274 }
275 }
276 }