src/share/classes/com/sun/tools/doclets/formats/html/FieldWriterImpl.java

Fri, 27 Feb 2009 18:57:17 -0800

author
bpatel
date
Fri, 27 Feb 2009 18:57:17 -0800
changeset 233
5240b1120530
parent 182
47a62d8d98b4
child 243
edd944553131
permissions
-rw-r--r--

6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
Reviewed-by: jjg

duke@1 1 /*
duke@1 2 * Copyright 1997-2004 Sun Microsystems, Inc. All Rights Reserved.
duke@1 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@1 4 *
duke@1 5 * This code is free software; you can redistribute it and/or modify it
duke@1 6 * under the terms of the GNU General Public License version 2 only, as
duke@1 7 * published by the Free Software Foundation. Sun designates this
duke@1 8 * particular file as subject to the "Classpath" exception as provided
duke@1 9 * by Sun in the LICENSE file that accompanied this code.
duke@1 10 *
duke@1 11 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@1 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@1 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@1 14 * version 2 for more details (a copy is included in the LICENSE file that
duke@1 15 * accompanied this code).
duke@1 16 *
duke@1 17 * You should have received a copy of the GNU General Public License version
duke@1 18 * 2 along with this work; if not, write to the Free Software Foundation,
duke@1 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@1 20 *
duke@1 21 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@1 22 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@1 23 * have any questions.
duke@1 24 */
duke@1 25
duke@1 26 package com.sun.tools.doclets.formats.html;
duke@1 27
bpatel@233 28 import java.io.*;
bpatel@233 29
bpatel@233 30 import com.sun.javadoc.*;
duke@1 31 import com.sun.tools.doclets.internal.toolkit.*;
duke@1 32 import com.sun.tools.doclets.internal.toolkit.util.*;
duke@1 33
duke@1 34 /**
duke@1 35 * Writes field documentation in HTML format.
duke@1 36 *
duke@1 37 * @author Robert Field
duke@1 38 * @author Atul M Dambalkar
duke@1 39 * @author Jamie Ho (rewrite)
duke@1 40 */
duke@1 41 public class FieldWriterImpl extends AbstractMemberWriter
duke@1 42 implements FieldWriter, MemberSummaryWriter {
duke@1 43
duke@1 44 private boolean printedSummaryHeader = false;
duke@1 45
duke@1 46 public FieldWriterImpl(SubWriterHolderWriter writer, ClassDoc classdoc) {
duke@1 47 super(writer, classdoc);
duke@1 48 }
duke@1 49
duke@1 50 public FieldWriterImpl(SubWriterHolderWriter writer) {
duke@1 51 super(writer);
duke@1 52 }
duke@1 53
duke@1 54 /**
duke@1 55 * Write the fields summary header for the given class.
duke@1 56 *
duke@1 57 * @param classDoc the class the summary belongs to.
duke@1 58 */
duke@1 59 public void writeMemberSummaryHeader(ClassDoc classDoc) {
duke@1 60 printedSummaryHeader = true;
duke@1 61 writer.println("<!-- =========== FIELD SUMMARY =========== -->");
duke@1 62 writer.println();
duke@1 63 writer.printSummaryHeader(this, classDoc);
duke@1 64 }
duke@1 65
duke@1 66 /**
duke@1 67 * Write the fields summary footer for the given class.
duke@1 68 *
duke@1 69 * @param classDoc the class the summary belongs to.
duke@1 70 */
duke@1 71 public void writeMemberSummaryFooter(ClassDoc classDoc) {
duke@1 72 writer.tableEnd();
duke@1 73 writer.space();
duke@1 74 }
duke@1 75
duke@1 76 /**
duke@1 77 * Write the inherited fields summary header for the given class.
duke@1 78 *
duke@1 79 * @param classDoc the class the summary belongs to.
duke@1 80 */
duke@1 81 public void writeInheritedMemberSummaryHeader(ClassDoc classDoc) {
duke@1 82 if(! printedSummaryHeader){
duke@1 83 //We don't want inherited summary to not be under heading.
duke@1 84 writeMemberSummaryHeader(classDoc);
duke@1 85 writeMemberSummaryFooter(classDoc);
duke@1 86 printedSummaryHeader = true;
duke@1 87 }
duke@1 88 writer.printInheritedSummaryHeader(this, classDoc);
duke@1 89 }
duke@1 90
duke@1 91 /**
duke@1 92 * {@inheritDoc}
duke@1 93 */
duke@1 94 public void writeInheritedMemberSummary(ClassDoc classDoc,
duke@1 95 ProgramElementDoc field, boolean isFirst, boolean isLast) {
duke@1 96 writer.printInheritedSummaryMember(this, classDoc, field, isFirst);
duke@1 97 }
duke@1 98
duke@1 99 /**
duke@1 100 * Write the inherited fields summary footer for the given class.
duke@1 101 *
duke@1 102 * @param classDoc the class the summary belongs to.
duke@1 103 */
duke@1 104 public void writeInheritedMemberSummaryFooter(ClassDoc classDoc) {
duke@1 105 writer.printInheritedSummaryFooter(this, classDoc);
duke@1 106 }
duke@1 107
duke@1 108 /**
duke@1 109 * Write the header for the field documentation.
duke@1 110 *
duke@1 111 * @param classDoc the class that the fields belong to.
duke@1 112 */
duke@1 113 public void writeHeader(ClassDoc classDoc, String header) {
duke@1 114 writer.println();
duke@1 115 writer.println("<!-- ============ FIELD DETAIL =========== -->");
duke@1 116 writer.println();
duke@1 117 writer.anchor("field_detail");
duke@1 118 writer.printTableHeadingBackground(header);
duke@1 119 writer.println();
duke@1 120 }
duke@1 121
duke@1 122 /**
duke@1 123 * Write the field header for the given field.
duke@1 124 *
duke@1 125 * @param field the field being documented.
duke@1 126 * @param isFirst the flag to indicate whether or not the field is the
duke@1 127 * first to be documented.
duke@1 128 */
duke@1 129 public void writeFieldHeader(FieldDoc field, boolean isFirst) {
duke@1 130 if (! isFirst) {
duke@1 131 writer.printMemberHeader();
duke@1 132 writer.println("");
duke@1 133 }
duke@1 134 writer.anchor(field.name());
duke@1 135 writer.h3();
duke@1 136 writer.print(field.name());
duke@1 137 writer.h3End();
duke@1 138 }
duke@1 139
duke@1 140 /**
duke@1 141 * Write the signature for the given field.
duke@1 142 *
duke@1 143 * @param field the field being documented.
duke@1 144 */
duke@1 145 public void writeSignature(FieldDoc field) {
duke@1 146 writer.pre();
duke@1 147 writer.writeAnnotationInfo(field);
duke@1 148 printModifiers(field);
duke@1 149 writer.printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER,
duke@1 150 field.type()));
duke@1 151 print(' ');
duke@1 152 if (configuration().linksource) {
duke@1 153 writer.printSrcLink(field, field.name());
duke@1 154 } else {
bpatel@182 155 strong(field.name());
duke@1 156 }
duke@1 157 writer.preEnd();
bpatel@233 158 assert !writer.getMemberDetailsListPrinted();
duke@1 159 }
duke@1 160
duke@1 161 /**
duke@1 162 * Write the deprecated output for the given field.
duke@1 163 *
duke@1 164 * @param field the field being documented.
duke@1 165 */
duke@1 166 public void writeDeprecated(FieldDoc field) {
bpatel@233 167 printDeprecated(field);
duke@1 168 }
duke@1 169
duke@1 170 /**
duke@1 171 * Write the comments for the given field.
duke@1 172 *
duke@1 173 * @param field the field being documented.
duke@1 174 */
duke@1 175 public void writeComments(FieldDoc field) {
duke@1 176 ClassDoc holder = field.containingClass();
duke@1 177 if (field.inlineTags().length > 0) {
bpatel@233 178 writer.printMemberDetailsListStartTag();
duke@1 179 if (holder.equals(classdoc) ||
duke@1 180 (! (holder.isPublic() || Util.isLinkable(holder, configuration())))) {
duke@1 181 writer.dd();
duke@1 182 writer.printInlineComment(field);
bpatel@233 183 writer.ddEnd();
duke@1 184 } else {
duke@1 185 String classlink = writer.codeText(
duke@1 186 writer.getDocLink(LinkInfoImpl.CONTEXT_FIELD_DOC_COPY,
duke@1 187 holder, field,
duke@1 188 holder.isIncluded() ?
duke@1 189 holder.typeName() : holder.qualifiedTypeName(),
duke@1 190 false));
duke@1 191 writer.dd();
bpatel@182 192 writer.strong(configuration().getText(holder.isClass()?
duke@1 193 "doclet.Description_From_Class" :
duke@1 194 "doclet.Description_From_Interface", classlink));
duke@1 195 writer.ddEnd();
duke@1 196 writer.dd();
duke@1 197 writer.printInlineComment(field);
bpatel@233 198 writer.ddEnd();
duke@1 199 }
duke@1 200 }
duke@1 201 }
duke@1 202
duke@1 203 /**
duke@1 204 * Write the tag output for the given field.
duke@1 205 *
duke@1 206 * @param field the field being documented.
duke@1 207 */
duke@1 208 public void writeTags(FieldDoc field) {
duke@1 209 writer.printTags(field);
duke@1 210 }
duke@1 211
duke@1 212 /**
duke@1 213 * Write the field footer.
duke@1 214 */
duke@1 215 public void writeFieldFooter() {
bpatel@233 216 printMemberFooter();
duke@1 217 }
duke@1 218
duke@1 219 /**
duke@1 220 * Write the footer for the field documentation.
duke@1 221 *
duke@1 222 * @param classDoc the class that the fields belong to.
duke@1 223 */
duke@1 224 public void writeFooter(ClassDoc classDoc) {
duke@1 225 //No footer to write for field documentation
duke@1 226 }
duke@1 227
duke@1 228 /**
duke@1 229 * Close the writer.
duke@1 230 */
duke@1 231 public void close() throws IOException {
duke@1 232 writer.close();
duke@1 233 }
duke@1 234
duke@1 235 public int getMemberKind() {
duke@1 236 return VisibleMemberMap.FIELDS;
duke@1 237 }
duke@1 238
duke@1 239 public void printSummaryLabel(ClassDoc cd) {
bpatel@182 240 writer.strongText("doclet.Field_Summary");
duke@1 241 }
duke@1 242
duke@1 243 public void printSummaryAnchor(ClassDoc cd) {
duke@1 244 writer.anchor("field_summary");
duke@1 245 }
duke@1 246
duke@1 247 public void printInheritedSummaryAnchor(ClassDoc cd) {
duke@1 248 writer.anchor("fields_inherited_from_class_" + configuration().getClassName(cd));
duke@1 249 }
duke@1 250
duke@1 251 public void printInheritedSummaryLabel(ClassDoc cd) {
duke@1 252 String classlink = writer.getPreQualifiedClassLink(
duke@1 253 LinkInfoImpl.CONTEXT_MEMBER, cd, false);
bpatel@182 254 writer.strong();
duke@1 255 String key = cd.isClass()?
duke@1 256 "doclet.Fields_Inherited_From_Class" :
duke@1 257 "doclet.Fields_Inherited_From_Interface";
duke@1 258 writer.printText(key, classlink);
bpatel@182 259 writer.strongEnd();
duke@1 260 }
duke@1 261
duke@1 262 protected void writeSummaryLink(int context, ClassDoc cd, ProgramElementDoc member) {
bpatel@182 263 writer.strong();
duke@1 264 writer.printDocLink(context, cd , (MemberDoc) member, member.name(), false);
bpatel@182 265 writer.strongEnd();
duke@1 266 }
duke@1 267
duke@1 268 protected void writeInheritedSummaryLink(ClassDoc cd,
duke@1 269 ProgramElementDoc member) {
duke@1 270 writer.printDocLink(LinkInfoImpl.CONTEXT_MEMBER, cd, (MemberDoc)member,
duke@1 271 member.name(), false);
duke@1 272 }
duke@1 273
duke@1 274 protected void printSummaryType(ProgramElementDoc member) {
duke@1 275 FieldDoc field = (FieldDoc)member;
duke@1 276 printModifierAndType(field, field.type());
duke@1 277 }
duke@1 278
duke@1 279 protected void writeDeprecatedLink(ProgramElementDoc member) {
duke@1 280 writer.printDocLink(LinkInfoImpl.CONTEXT_MEMBER,
duke@1 281 (MemberDoc) member, ((FieldDoc)member).qualifiedName(), false);
duke@1 282 }
duke@1 283
duke@1 284 protected void printNavSummaryLink(ClassDoc cd, boolean link) {
duke@1 285 if (link) {
duke@1 286 writer.printHyperLink("", (cd == null)?
duke@1 287 "field_summary":
duke@1 288 "fields_inherited_from_class_" +
duke@1 289 configuration().getClassName(cd),
duke@1 290 configuration().getText("doclet.navField"));
duke@1 291 } else {
duke@1 292 writer.printText("doclet.navField");
duke@1 293 }
duke@1 294 }
duke@1 295
duke@1 296 protected void printNavDetailLink(boolean link) {
duke@1 297 if (link) {
duke@1 298 writer.printHyperLink("", "field_detail",
duke@1 299 configuration().getText("doclet.navField"));
duke@1 300 } else {
duke@1 301 writer.printText("doclet.navField");
duke@1 302 }
duke@1 303 }
duke@1 304 }

mercurial