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

Wed, 18 Feb 2009 13:47:27 -0800

author
bpatel
date
Wed, 18 Feb 2009 13:47:27 -0800
changeset 222
d424ed561993
parent 182
47a62d8d98b4
child 233
5240b1120530
permissions
-rw-r--r--

6802694: Javadoc doclet does not display deprecated information with -nocomment option for serialized form
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 com.sun.tools.doclets.internal.toolkit.*;
    29 import com.sun.tools.doclets.internal.toolkit.taglets.*;
    30 import com.sun.tools.doclets.internal.toolkit.util.*;
    31 import com.sun.javadoc.*;
    33 import java.io.*;
    35 /**
    36  * Writes enum constant documentation in HTML format.
    37  *
    38  * @author Jamie Ho
    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         writer.dl();
   150     }
   152     /**
   153      * {@inheritDoc}
   154      */
   155     public void writeDeprecated(FieldDoc enumConstant) {
   156         print(((TagletOutputImpl)
   157             (new DeprecatedTaglet()).getTagletOutput(enumConstant,
   158             writer.getTagletWriterInstance(false))).toString());
   159     }
   161     /**
   162      * {@inheritDoc}
   163      */
   164     public void writeComments(FieldDoc enumConstant) {
   165         if (enumConstant.inlineTags().length > 0) {
   166             writer.dd();
   167             writer.printInlineComment(enumConstant);
   168         }
   169     }
   171     /**
   172      * {@inheritDoc}
   173      */
   174     public void writeTags(FieldDoc enumConstant) {
   175         writer.printTags(enumConstant);
   176     }
   178     /**
   179      * {@inheritDoc}
   180      */
   181     public void writeEnumConstantFooter() {
   182         writer.dlEnd();
   183     }
   185     /**
   186      * {@inheritDoc}
   187      */
   188     public void writeFooter(ClassDoc classDoc) {
   189         //No footer to write for enum constant documentation
   190     }
   192     /**
   193      * {@inheritDoc}
   194      */
   195     public void close() throws IOException {
   196         writer.close();
   197     }
   199     public int getMemberKind() {
   200         return VisibleMemberMap.ENUM_CONSTANTS;
   201     }
   203     public void printSummaryLabel(ClassDoc cd) {
   204         writer.strongText("doclet.Enum_Constant_Summary");
   205     }
   207     public void printSummaryAnchor(ClassDoc cd) {
   208         writer.anchor("enum_constant_summary");
   209     }
   211     public void printInheritedSummaryAnchor(ClassDoc cd) {
   212     }   // no such
   214     public void printInheritedSummaryLabel(ClassDoc cd) {
   215         // no such
   216     }
   218     protected void writeSummaryLink(int context, ClassDoc cd, ProgramElementDoc member) {
   219         writer.strong();
   220         writer.printDocLink(context, (MemberDoc) member, member.name(), false);
   221         writer.strongEnd();
   222     }
   224     protected void writeInheritedSummaryLink(ClassDoc cd,
   225             ProgramElementDoc member) {
   226         writer.printDocLink(LinkInfoImpl.CONTEXT_MEMBER, (MemberDoc)member,
   227             member.name(), false);
   228     }
   230     protected void printSummaryType(ProgramElementDoc member) {
   231         //Not applicable.
   232     }
   234     protected void writeDeprecatedLink(ProgramElementDoc member) {
   235         writer.printDocLink(LinkInfoImpl.CONTEXT_MEMBER,
   236             (MemberDoc) member, ((FieldDoc)member).qualifiedName(), false);
   237     }
   239     protected void printNavSummaryLink(ClassDoc cd, boolean link) {
   240         if (link) {
   241             writer.printHyperLink("", (cd == null)?
   242                         "enum_constant_summary":
   243                         "enum_constants_inherited_from_class_" +
   244                         configuration().getClassName(cd),
   245                     configuration().getText("doclet.navEnum"));
   246         } else {
   247             writer.printText("doclet.navEnum");
   248         }
   249     }
   251     protected void printNavDetailLink(boolean link) {
   252         if (link) {
   253             writer.printHyperLink("", "enum_constant_detail",
   254                 configuration().getText("doclet.navEnum"));
   255         } else {
   256             writer.printText("doclet.navEnum");
   257         }
   258     }
   259 }

mercurial