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.*;
32 import com.sun.tools.doclets.internal.toolkit.util.*;
34 /**
35 * Writes enum constant documentation in HTML format.
36 *
37 * @author Jamie Ho
38 */
39 public class EnumConstantWriterImpl extends AbstractMemberWriter
40 implements EnumConstantWriter, MemberSummaryWriter {
42 private boolean printedSummaryHeader = false;
44 public EnumConstantWriterImpl(SubWriterHolderWriter writer,
45 ClassDoc classdoc) {
46 super(writer, classdoc);
47 }
49 public EnumConstantWriterImpl(SubWriterHolderWriter writer) {
50 super(writer);
51 }
53 /**
54 * Write the enum constant summary header for the given class.
55 *
56 * @param classDoc the class the summary belongs to.
57 */
58 public void writeMemberSummaryHeader(ClassDoc classDoc) {
59 printedSummaryHeader = true;
60 writer.println("<!-- =========== ENUM CONSTANT SUMMARY =========== -->");
61 writer.println();
62 writer.printSummaryHeader(this, classDoc);
63 }
65 /**
66 * Write the enum constant summary footer for the given class.
67 *
68 * @param classDoc the class the summary belongs to.
69 */
70 public void writeMemberSummaryFooter(ClassDoc classDoc) {
71 writer.printSummaryFooter(this, classDoc);
72 }
74 /**
75 * Write the inherited enum constant summary header for the given class.
76 *
77 * @param classDoc the class the summary belongs to.
78 */
79 public void writeInheritedMemberSummaryHeader(ClassDoc classDoc) {
80 if(! printedSummaryHeader){
81 //We don't want inherited summary to not be under heading.
82 writeMemberSummaryHeader(classDoc);
83 writeMemberSummaryFooter(classDoc);
84 printedSummaryHeader = true;
85 }
86 writer.printInheritedSummaryHeader(this, classDoc);
87 }
89 /**
90 * {@inheritDoc}
91 */
92 public void writeInheritedMemberSummary(ClassDoc classDoc,
93 ProgramElementDoc enumConstant, boolean isFirst, boolean isLast) {
94 writer.printInheritedSummaryMember(this, classDoc, enumConstant, isFirst);
95 }
97 /**
98 * Write the inherited enum constant summary footer for the given class.
99 *
100 * @param classDoc the class the summary belongs to.
101 */
102 public void writeInheritedMemberSummaryFooter(ClassDoc classDoc) {
103 writer.printInheritedSummaryFooter(this, classDoc);
104 }
106 /**
107 * {@inheritDoc}
108 */
109 public void writeHeader(ClassDoc classDoc, String header) {
110 writer.println();
111 writer.println("<!-- ============ ENUM CONSTANT DETAIL =========== -->");
112 writer.println();
113 writer.anchor("enum_constant_detail");
114 writer.printTableHeadingBackground(header);
115 writer.println();
116 }
118 /**
119 * {@inheritDoc}
120 */
121 public void writeEnumConstantHeader(FieldDoc enumConstant, boolean isFirst) {
122 if (! isFirst) {
123 writer.printMemberHeader();
124 writer.println("");
125 }
126 writer.anchor(enumConstant.name());
127 writer.h3();
128 writer.print(enumConstant.name());
129 writer.h3End();
130 }
132 /**
133 * {@inheritDoc}
134 */
135 public void writeSignature(FieldDoc enumConstant) {
136 writer.pre();
137 writer.writeAnnotationInfo(enumConstant);
138 printModifiers(enumConstant);
139 writer.printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER,
140 enumConstant.type()));
141 print(' ');
142 if (configuration().linksource) {
143 writer.printSrcLink(enumConstant, enumConstant.name());
144 } else {
145 strong(enumConstant.name());
146 }
147 writer.preEnd();
148 assert !writer.getMemberDetailsListPrinted();
149 }
151 /**
152 * {@inheritDoc}
153 */
154 public void writeDeprecated(FieldDoc enumConstant) {
155 printDeprecated(enumConstant);
156 }
158 /**
159 * {@inheritDoc}
160 */
161 public void writeComments(FieldDoc enumConstant) {
162 printComment(enumConstant);
163 }
165 /**
166 * {@inheritDoc}
167 */
168 public void writeTags(FieldDoc enumConstant) {
169 writer.printTags(enumConstant);
170 }
172 /**
173 * {@inheritDoc}
174 */
175 public void writeEnumConstantFooter() {
176 printMemberFooter();
177 }
179 /**
180 * {@inheritDoc}
181 */
182 public void writeFooter(ClassDoc classDoc) {
183 //No footer to write for enum constant documentation
184 }
186 /**
187 * {@inheritDoc}
188 */
189 public void close() throws IOException {
190 writer.close();
191 }
193 public int getMemberKind() {
194 return VisibleMemberMap.ENUM_CONSTANTS;
195 }
197 public void printSummaryLabel(ClassDoc cd) {
198 writer.strongText("doclet.Enum_Constant_Summary");
199 }
201 public void printSummaryAnchor(ClassDoc cd) {
202 writer.anchor("enum_constant_summary");
203 }
205 public void printInheritedSummaryAnchor(ClassDoc cd) {
206 } // no such
208 public void printInheritedSummaryLabel(ClassDoc cd) {
209 // no such
210 }
212 protected void writeSummaryLink(int context, ClassDoc cd, ProgramElementDoc member) {
213 writer.strong();
214 writer.printDocLink(context, (MemberDoc) member, member.name(), false);
215 writer.strongEnd();
216 }
218 protected void writeInheritedSummaryLink(ClassDoc cd,
219 ProgramElementDoc member) {
220 writer.printDocLink(LinkInfoImpl.CONTEXT_MEMBER, (MemberDoc)member,
221 member.name(), false);
222 }
224 protected void printSummaryType(ProgramElementDoc member) {
225 //Not applicable.
226 }
228 protected void writeDeprecatedLink(ProgramElementDoc member) {
229 writer.printDocLink(LinkInfoImpl.CONTEXT_MEMBER,
230 (MemberDoc) member, ((FieldDoc)member).qualifiedName(), false);
231 }
233 protected void printNavSummaryLink(ClassDoc cd, boolean link) {
234 if (link) {
235 writer.printHyperLink("", (cd == null)?
236 "enum_constant_summary":
237 "enum_constants_inherited_from_class_" +
238 configuration().getClassName(cd),
239 configuration().getText("doclet.navEnum"));
240 } else {
241 writer.printText("doclet.navEnum");
242 }
243 }
245 protected void printNavDetailLink(boolean link) {
246 if (link) {
247 writer.printHyperLink("", "enum_constant_detail",
248 configuration().getText("doclet.navEnum"));
249 } else {
250 writer.printText("doclet.navEnum");
251 }
252 }
253 }