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

Tue, 28 Dec 2010 15:54:52 -0800

author
ohair
date
Tue, 28 Dec 2010 15:54:52 -0800
changeset 798
4868a36f6fd8
parent 766
90af8d87741f
child 1359
25e14ad23cef
permissions
-rw-r--r--

6962318: Update copyright year
Reviewed-by: xdono

     1 /*
     2  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. 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.  Oracle designates this
     8  * particular file as subject to the "Classpath" exception as provided
     9  * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    22  * or visit www.oracle.com if you need additional information or have any
    23  * 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.formats.html.markup.*;
    32 import com.sun.tools.doclets.internal.toolkit.*;
    33 import com.sun.tools.doclets.internal.toolkit.util.*;
    35 /**
    36  * Writes enum constant documentation in HTML format.
    37  *
    38  * @author Jamie Ho
    39  * @author Bhavesh Patel (Modified)
    40  */
    41 public class EnumConstantWriterImpl extends AbstractMemberWriter
    42     implements EnumConstantWriter, MemberSummaryWriter {
    44     public EnumConstantWriterImpl(SubWriterHolderWriter writer,
    45         ClassDoc classdoc) {
    46         super(writer, classdoc);
    47     }
    49     public EnumConstantWriterImpl(SubWriterHolderWriter writer) {
    50         super(writer);
    51     }
    53     /**
    54      * {@inheritDoc}
    55      */
    56     public Content getMemberSummaryHeader(ClassDoc classDoc,
    57             Content memberSummaryTree) {
    58         memberSummaryTree.addContent(HtmlConstants.START_OF_ENUM_CONSTANT_SUMMARY);
    59         Content memberTree = writer.getMemberTreeHeader();
    60         writer.addSummaryHeader(this, classDoc, memberTree);
    61         return memberTree;
    62     }
    64     /**
    65      * {@inheritDoc}
    66      */
    67     public Content getEnumConstantsDetailsTreeHeader(ClassDoc classDoc,
    68             Content memberDetailsTree) {
    69         memberDetailsTree.addContent(HtmlConstants.START_OF_ENUM_CONSTANT_DETAILS);
    70         Content enumConstantsDetailsTree = writer.getMemberTreeHeader();
    71         enumConstantsDetailsTree.addContent(writer.getMarkerAnchor("enum_constant_detail"));
    72         Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING,
    73                 writer.enumConstantsDetailsLabel);
    74         enumConstantsDetailsTree.addContent(heading);
    75         return enumConstantsDetailsTree;
    76     }
    78     /**
    79      * {@inheritDoc}
    80      */
    81     public Content getEnumConstantsTreeHeader(FieldDoc enumConstant,
    82             Content enumConstantsDetailsTree) {
    83         enumConstantsDetailsTree.addContent(
    84                 writer.getMarkerAnchor(enumConstant.name()));
    85         Content enumConstantsTree = writer.getMemberTreeHeader();
    86         Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING);
    87         heading.addContent(enumConstant.name());
    88         enumConstantsTree.addContent(heading);
    89         return enumConstantsTree;
    90     }
    92     /**
    93      * {@inheritDoc}
    94      */
    95     public Content getSignature(FieldDoc enumConstant) {
    96         Content pre = new HtmlTree(HtmlTag.PRE);
    97         writer.addAnnotationInfo(enumConstant, pre);
    98         addModifiers(enumConstant, pre);
    99         Content enumConstantLink = new RawHtml(writer.getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER,
   100                 enumConstant.type())));
   101         pre.addContent(enumConstantLink);
   102         pre.addContent(" ");
   103         if (configuration().linksource) {
   104             Content enumConstantName = new StringContent(enumConstant.name());
   105             writer.addSrcLink(enumConstant, enumConstantName, pre);
   106         } else {
   107             addName(enumConstant.name(), pre);
   108         }
   109         return pre;
   110     }
   112     /**
   113      * {@inheritDoc}
   114      */
   115     public void addDeprecated(FieldDoc enumConstant, Content enumConstantsTree) {
   116         addDeprecatedInfo(enumConstant, enumConstantsTree);
   117     }
   119     /**
   120      * {@inheritDoc}
   121      */
   122     public void addComments(FieldDoc enumConstant, Content enumConstantsTree) {
   123         addComment(enumConstant, enumConstantsTree);
   124     }
   126     /**
   127      * {@inheritDoc}
   128      */
   129     public void addTags(FieldDoc enumConstant, Content enumConstantsTree) {
   130         writer.addTagsInfo(enumConstant, enumConstantsTree);
   131     }
   133     /**
   134      * {@inheritDoc}
   135      */
   136     public Content getEnumConstantsDetails(Content enumConstantsDetailsTree) {
   137         return getMemberTree(enumConstantsDetailsTree);
   138     }
   140     /**
   141      * {@inheritDoc}
   142      */
   143     public Content getEnumConstants(Content enumConstantsTree,
   144             boolean isLastContent) {
   145         return getMemberTree(enumConstantsTree, isLastContent);
   146     }
   148     /**
   149      * {@inheritDoc}
   150      */
   151     public void close() throws IOException {
   152         writer.close();
   153     }
   155     public int getMemberKind() {
   156         return VisibleMemberMap.ENUM_CONSTANTS;
   157     }
   159     /**
   160      * {@inheritDoc}
   161      */
   162     public void addSummaryLabel(Content memberTree) {
   163         Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
   164                 writer.getResource("doclet.Enum_Constant_Summary"));
   165         memberTree.addContent(label);
   166     }
   168     /**
   169      * {@inheritDoc}
   170      */
   171     public String getTableSummary() {
   172         return configuration().getText("doclet.Member_Table_Summary",
   173                 configuration().getText("doclet.Enum_Constant_Summary"),
   174                 configuration().getText("doclet.enum_constants"));
   175     }
   177     /**
   178      * {@inheritDoc}
   179      */
   180     public String getCaption() {
   181         return configuration().getText("doclet.Enum_Constants");
   182     }
   184     /**
   185      * {@inheritDoc}
   186      */
   187     public String[] getSummaryTableHeader(ProgramElementDoc member) {
   188         String[] header = new String[] {
   189             configuration().getText("doclet.0_and_1",
   190                     configuration().getText("doclet.Enum_Constant"),
   191                     configuration().getText("doclet.Description"))
   192         };
   193         return header;
   194     }
   196     /**
   197      * {@inheritDoc}
   198      */
   199     public void addSummaryAnchor(ClassDoc cd, Content memberTree) {
   200         memberTree.addContent(writer.getMarkerAnchor("enum_constant_summary"));
   201     }
   203     /**
   204      * {@inheritDoc}
   205      */
   206     public void addInheritedSummaryAnchor(ClassDoc cd, Content inheritedTree) {
   207     }
   209     /**
   210      * {@inheritDoc}
   211      */
   212     public void addInheritedSummaryLabel(ClassDoc cd, Content inheritedTree) {
   213     }
   215     /**
   216      * {@inheritDoc}
   217      */
   218     protected void addSummaryLink(int context, ClassDoc cd, ProgramElementDoc member,
   219             Content tdSummary) {
   220         Content strong = HtmlTree.STRONG(new RawHtml(
   221                 writer.getDocLink(context, (MemberDoc) member, member.name(), false)));
   222         Content code = HtmlTree.CODE(strong);
   223         tdSummary.addContent(code);
   224     }
   226     /**
   227      * {@inheritDoc}
   228      */
   229     @Override
   230     public void setSummaryColumnStyle(HtmlTree tdTree) {
   231         tdTree.addStyle(HtmlStyle.colOne);
   232     }
   234     /**
   235      * {@inheritDoc}
   236      */
   237     protected void addInheritedSummaryLink(ClassDoc cd,
   238             ProgramElementDoc member, Content linksTree) {
   239     }
   241     /**
   242      * {@inheritDoc}
   243      */
   244     protected void addSummaryType(ProgramElementDoc member, Content tdSummaryType) {
   245         //Not applicable.
   246     }
   248     /**
   249      * {@inheritDoc}
   250      */
   251     protected Content getDeprecatedLink(ProgramElementDoc member) {
   252         return writer.getDocLink(LinkInfoImpl.CONTEXT_MEMBER,
   253                 (MemberDoc) member, ((FieldDoc)member).qualifiedName());
   254     }
   256     /**
   257      * {@inheritDoc}
   258      */
   259     protected Content getNavSummaryLink(ClassDoc cd, boolean link) {
   260         if (link) {
   261             return writer.getHyperLink("", (cd == null)?
   262                 "enum_constant_summary":
   263                 "enum_constants_inherited_from_class_" +
   264                 configuration().getClassName(cd),
   265                 writer.getResource("doclet.navEnum"));
   266         } else {
   267             return writer.getResource("doclet.navEnum");
   268         }
   269     }
   271     /**
   272      * {@inheritDoc}
   273      */
   274     protected void addNavDetailLink(boolean link, Content liNav) {
   275         if (link) {
   276             liNav.addContent(writer.getHyperLink("", "enum_constant_detail",
   277                     writer.getResource("doclet.navEnum")));
   278         } else {
   279             liNav.addContent(writer.getResource("doclet.navEnum"));
   280         }
   281     }
   282 }

mercurial