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

Thu, 19 Mar 2009 19:00:54 -0700

author
bpatel
date
Thu, 19 Mar 2009 19:00:54 -0700
changeset 243
edd944553131
parent 233
5240b1120530
child 554
9d9f26857129
permissions
-rw-r--r--

6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
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  * @author Bhavesh Patel (Modified)
    39  */
    40 public class EnumConstantWriterImpl extends AbstractMemberWriter
    41     implements EnumConstantWriter, MemberSummaryWriter {
    43     private boolean printedSummaryHeader = false;
    45     public EnumConstantWriterImpl(SubWriterHolderWriter writer,
    46         ClassDoc classdoc) {
    47         super(writer, classdoc);
    48     }
    50     public EnumConstantWriterImpl(SubWriterHolderWriter writer) {
    51         super(writer);
    52     }
    54     /**
    55      * Write the enum constant summary header for the given class.
    56      *
    57      * @param classDoc the class the summary belongs to.
    58      */
    59     public void writeMemberSummaryHeader(ClassDoc classDoc) {
    60         printedSummaryHeader = true;
    61         writer.println("<!-- =========== ENUM CONSTANT SUMMARY =========== -->");
    62         writer.println();
    63         writer.printSummaryHeader(this, classDoc);
    64     }
    66     /**
    67      * Write the enum constant summary footer for the given class.
    68      *
    69      * @param classDoc the class the summary belongs to.
    70      */
    71     public void writeMemberSummaryFooter(ClassDoc classDoc) {
    72         writer.printSummaryFooter(this, classDoc);
    73     }
    75     /**
    76      * Write the inherited enum constant summary header for the given class.
    77      *
    78      * @param classDoc the class the summary belongs to.
    79      */
    80     public void writeInheritedMemberSummaryHeader(ClassDoc classDoc) {
    81         if(! printedSummaryHeader){
    82             //We don't want inherited summary to not be under heading.
    83             writeMemberSummaryHeader(classDoc);
    84             writeMemberSummaryFooter(classDoc);
    85             printedSummaryHeader = true;
    86         }
    87         writer.printInheritedSummaryHeader(this, classDoc);
    88     }
    90     /**
    91      * {@inheritDoc}
    92      */
    93     public void writeInheritedMemberSummary(ClassDoc classDoc,
    94         ProgramElementDoc enumConstant, boolean isFirst, boolean isLast) {
    95         writer.printInheritedSummaryMember(this, classDoc, enumConstant, isFirst);
    96     }
    98     /**
    99      * Write the inherited enum constant summary footer for the given class.
   100      *
   101      * @param classDoc the class the summary belongs to.
   102      */
   103     public void writeInheritedMemberSummaryFooter(ClassDoc classDoc) {
   104         writer.printInheritedSummaryFooter(this, classDoc);
   105     }
   107     /**
   108      * {@inheritDoc}
   109      */
   110     public void writeHeader(ClassDoc classDoc, String header) {
   111         writer.println();
   112         writer.println("<!-- ============ ENUM CONSTANT DETAIL =========== -->");
   113         writer.println();
   114         writer.anchor("enum_constant_detail");
   115         writer.printTableHeadingBackground(header);
   116         writer.println();
   117     }
   119     /**
   120      * {@inheritDoc}
   121      */
   122     public void writeEnumConstantHeader(FieldDoc enumConstant, boolean isFirst) {
   123         if (! isFirst) {
   124             writer.printMemberHeader();
   125             writer.println("");
   126         }
   127         writer.anchor(enumConstant.name());
   128         writer.h3();
   129         writer.print(enumConstant.name());
   130         writer.h3End();
   131     }
   133     /**
   134      * {@inheritDoc}
   135      */
   136     public void writeSignature(FieldDoc enumConstant) {
   137         writer.pre();
   138         writer.writeAnnotationInfo(enumConstant);
   139         printModifiers(enumConstant);
   140         writer.printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER,
   141             enumConstant.type()));
   142         print(' ');
   143         if (configuration().linksource) {
   144             writer.printSrcLink(enumConstant, enumConstant.name());
   145         } else {
   146             strong(enumConstant.name());
   147         }
   148         writer.preEnd();
   149         assert !writer.getMemberDetailsListPrinted();
   150     }
   152     /**
   153      * {@inheritDoc}
   154      */
   155     public void writeDeprecated(FieldDoc enumConstant) {
   156         printDeprecated(enumConstant);
   157     }
   159     /**
   160      * {@inheritDoc}
   161      */
   162     public void writeComments(FieldDoc enumConstant) {
   163         printComment(enumConstant);
   164     }
   166     /**
   167      * {@inheritDoc}
   168      */
   169     public void writeTags(FieldDoc enumConstant) {
   170         writer.printTags(enumConstant);
   171     }
   173     /**
   174      * {@inheritDoc}
   175      */
   176     public void writeEnumConstantFooter() {
   177         printMemberFooter();
   178     }
   180     /**
   181      * {@inheritDoc}
   182      */
   183     public void writeFooter(ClassDoc classDoc) {
   184         //No footer to write for enum constant documentation
   185     }
   187     /**
   188      * {@inheritDoc}
   189      */
   190     public void close() throws IOException {
   191         writer.close();
   192     }
   194     public int getMemberKind() {
   195         return VisibleMemberMap.ENUM_CONSTANTS;
   196     }
   198     public void printSummaryLabel() {
   199         writer.printText("doclet.Enum_Constant_Summary");
   200     }
   202     public void printTableSummary() {
   203         writer.tableIndexSummary(configuration().getText("doclet.Member_Table_Summary",
   204                 configuration().getText("doclet.Enum_Constant_Summary"),
   205                 configuration().getText("doclet.enum_constants")));
   206     }
   208     public void printSummaryTableHeader(ProgramElementDoc member) {
   209         String[] header = new String[] {
   210             configuration().getText("doclet.0_and_1",
   211                     configuration().getText("doclet.Enum_Constant"),
   212                     configuration().getText("doclet.Description"))
   213         };
   214         writer.summaryTableHeader(header, "col");
   215     }
   217     public void printSummaryAnchor(ClassDoc cd) {
   218         writer.anchor("enum_constant_summary");
   219     }
   221     public void printInheritedSummaryAnchor(ClassDoc cd) {
   222     }   // no such
   224     public void printInheritedSummaryLabel(ClassDoc cd) {
   225         // no such
   226     }
   228     protected void writeSummaryLink(int context, ClassDoc cd, ProgramElementDoc member) {
   229         writer.strong();
   230         writer.printDocLink(context, (MemberDoc) member, member.name(), false);
   231         writer.strongEnd();
   232     }
   234     protected void writeInheritedSummaryLink(ClassDoc cd,
   235             ProgramElementDoc member) {
   236         writer.printDocLink(LinkInfoImpl.CONTEXT_MEMBER, (MemberDoc)member,
   237             member.name(), false);
   238     }
   240     protected void printSummaryType(ProgramElementDoc member) {
   241         //Not applicable.
   242     }
   244     protected void writeDeprecatedLink(ProgramElementDoc member) {
   245         writer.printDocLink(LinkInfoImpl.CONTEXT_MEMBER,
   246             (MemberDoc) member, ((FieldDoc)member).qualifiedName(), false);
   247     }
   249     protected void printNavSummaryLink(ClassDoc cd, boolean link) {
   250         if (link) {
   251             writer.printHyperLink("", (cd == null)?
   252                         "enum_constant_summary":
   253                         "enum_constants_inherited_from_class_" +
   254                         configuration().getClassName(cd),
   255                     configuration().getText("doclet.navEnum"));
   256         } else {
   257             writer.printText("doclet.navEnum");
   258         }
   259     }
   261     protected void printNavDetailLink(boolean link) {
   262         if (link) {
   263             writer.printHyperLink("", "enum_constant_detail",
   264                 configuration().getText("doclet.navEnum"));
   265         } else {
   266             writer.printText("doclet.navEnum");
   267         }
   268     }
   269 }

mercurial