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

Tue, 14 May 2013 10:14:55 -0700

author
jjg
date
Tue, 14 May 2013 10:14:55 -0700
changeset 1747
df4f44800923
parent 1736
74cd21f2c2fe
child 1935
8c55df2442c1
permissions
-rw-r--r--

8012183: replace some uses of Configuration.getText with Configuration.getResource
Reviewed-by: darcy

     1 /*
     2  * Copyright (c) 2003, 2013, 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  *  <p><b>This is NOT part of any supported API.
    39  *  If you write code that depends on this, you do so at your own risk.
    40  *  This code and its internal interfaces are subject to change or
    41  *  deletion without notice.</b>
    42  *
    43  * @author Jamie Ho
    44  * @author Bhavesh Patel (Modified)
    45  */
    46 public class EnumConstantWriterImpl extends AbstractMemberWriter
    47     implements EnumConstantWriter, MemberSummaryWriter {
    49     public EnumConstantWriterImpl(SubWriterHolderWriter writer,
    50         ClassDoc classdoc) {
    51         super(writer, classdoc);
    52     }
    54     public EnumConstantWriterImpl(SubWriterHolderWriter writer) {
    55         super(writer);
    56     }
    58     /**
    59      * {@inheritDoc}
    60      */
    61     public Content getMemberSummaryHeader(ClassDoc classDoc,
    62             Content memberSummaryTree) {
    63         memberSummaryTree.addContent(HtmlConstants.START_OF_ENUM_CONSTANT_SUMMARY);
    64         Content memberTree = writer.getMemberTreeHeader();
    65         writer.addSummaryHeader(this, classDoc, memberTree);
    66         return memberTree;
    67     }
    69     /**
    70      * {@inheritDoc}
    71      */
    72     public Content getEnumConstantsDetailsTreeHeader(ClassDoc classDoc,
    73             Content memberDetailsTree) {
    74         memberDetailsTree.addContent(HtmlConstants.START_OF_ENUM_CONSTANT_DETAILS);
    75         Content enumConstantsDetailsTree = writer.getMemberTreeHeader();
    76         enumConstantsDetailsTree.addContent(writer.getMarkerAnchor("enum_constant_detail"));
    77         Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING,
    78                 writer.enumConstantsDetailsLabel);
    79         enumConstantsDetailsTree.addContent(heading);
    80         return enumConstantsDetailsTree;
    81     }
    83     /**
    84      * {@inheritDoc}
    85      */
    86     public Content getEnumConstantsTreeHeader(FieldDoc enumConstant,
    87             Content enumConstantsDetailsTree) {
    88         enumConstantsDetailsTree.addContent(
    89                 writer.getMarkerAnchor(enumConstant.name()));
    90         Content enumConstantsTree = writer.getMemberTreeHeader();
    91         Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING);
    92         heading.addContent(enumConstant.name());
    93         enumConstantsTree.addContent(heading);
    94         return enumConstantsTree;
    95     }
    97     /**
    98      * {@inheritDoc}
    99      */
   100     public Content getSignature(FieldDoc enumConstant) {
   101         Content pre = new HtmlTree(HtmlTag.PRE);
   102         writer.addAnnotationInfo(enumConstant, pre);
   103         addModifiers(enumConstant, pre);
   104         Content enumConstantLink = writer.getLink(new LinkInfoImpl(
   105                 configuration, LinkInfoImpl.Kind.MEMBER, enumConstant.type()));
   106         pre.addContent(enumConstantLink);
   107         pre.addContent(" ");
   108         if (configuration.linksource) {
   109             Content enumConstantName = new StringContent(enumConstant.name());
   110             writer.addSrcLink(enumConstant, enumConstantName, pre);
   111         } else {
   112             addName(enumConstant.name(), pre);
   113         }
   114         return pre;
   115     }
   117     /**
   118      * {@inheritDoc}
   119      */
   120     public void addDeprecated(FieldDoc enumConstant, Content enumConstantsTree) {
   121         addDeprecatedInfo(enumConstant, enumConstantsTree);
   122     }
   124     /**
   125      * {@inheritDoc}
   126      */
   127     public void addComments(FieldDoc enumConstant, Content enumConstantsTree) {
   128         addComment(enumConstant, enumConstantsTree);
   129     }
   131     /**
   132      * {@inheritDoc}
   133      */
   134     public void addTags(FieldDoc enumConstant, Content enumConstantsTree) {
   135         writer.addTagsInfo(enumConstant, enumConstantsTree);
   136     }
   138     /**
   139      * {@inheritDoc}
   140      */
   141     public Content getEnumConstantsDetails(Content enumConstantsDetailsTree) {
   142         return getMemberTree(enumConstantsDetailsTree);
   143     }
   145     /**
   146      * {@inheritDoc}
   147      */
   148     public Content getEnumConstants(Content enumConstantsTree,
   149             boolean isLastContent) {
   150         return getMemberTree(enumConstantsTree, isLastContent);
   151     }
   153     /**
   154      * {@inheritDoc}
   155      */
   156     public void close() throws IOException {
   157         writer.close();
   158     }
   160     public int getMemberKind() {
   161         return VisibleMemberMap.ENUM_CONSTANTS;
   162     }
   164     /**
   165      * {@inheritDoc}
   166      */
   167     public void addSummaryLabel(Content memberTree) {
   168         Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
   169                 writer.getResource("doclet.Enum_Constant_Summary"));
   170         memberTree.addContent(label);
   171     }
   173     /**
   174      * {@inheritDoc}
   175      */
   176     public String getTableSummary() {
   177         return configuration.getText("doclet.Member_Table_Summary",
   178                 configuration.getText("doclet.Enum_Constant_Summary"),
   179                 configuration.getText("doclet.enum_constants"));
   180     }
   182     /**
   183      * {@inheritDoc}
   184      */
   185     public Content getCaption() {
   186         return configuration.getResource("doclet.Enum_Constants");
   187     }
   189     /**
   190      * {@inheritDoc}
   191      */
   192     public String[] getSummaryTableHeader(ProgramElementDoc member) {
   193         String[] header = new String[] {
   194             configuration.getText("doclet.0_and_1",
   195                     configuration.getText("doclet.Enum_Constant"),
   196                     configuration.getText("doclet.Description"))
   197         };
   198         return header;
   199     }
   201     /**
   202      * {@inheritDoc}
   203      */
   204     public void addSummaryAnchor(ClassDoc cd, Content memberTree) {
   205         memberTree.addContent(writer.getMarkerAnchor("enum_constant_summary"));
   206     }
   208     /**
   209      * {@inheritDoc}
   210      */
   211     public void addInheritedSummaryAnchor(ClassDoc cd, Content inheritedTree) {
   212     }
   214     /**
   215      * {@inheritDoc}
   216      */
   217     public void addInheritedSummaryLabel(ClassDoc cd, Content inheritedTree) {
   218     }
   220     /**
   221      * {@inheritDoc}
   222      */
   223     protected void addSummaryLink(LinkInfoImpl.Kind context, ClassDoc cd, ProgramElementDoc member,
   224             Content tdSummary) {
   225         Content strong = HtmlTree.STRONG(
   226                 writer.getDocLink(context, (MemberDoc) member, member.name(), false));
   227         Content code = HtmlTree.CODE(strong);
   228         tdSummary.addContent(code);
   229     }
   231     /**
   232      * {@inheritDoc}
   233      */
   234     @Override
   235     public void setSummaryColumnStyle(HtmlTree tdTree) {
   236         tdTree.addStyle(HtmlStyle.colOne);
   237     }
   239     /**
   240      * {@inheritDoc}
   241      */
   242     protected void addInheritedSummaryLink(ClassDoc cd,
   243             ProgramElementDoc member, Content linksTree) {
   244     }
   246     /**
   247      * {@inheritDoc}
   248      */
   249     protected void addSummaryType(ProgramElementDoc member, Content tdSummaryType) {
   250         //Not applicable.
   251     }
   253     /**
   254      * {@inheritDoc}
   255      */
   256     protected Content getDeprecatedLink(ProgramElementDoc member) {
   257         return writer.getDocLink(LinkInfoImpl.Kind.MEMBER,
   258                 (MemberDoc) member, ((FieldDoc)member).qualifiedName());
   259     }
   261     /**
   262      * {@inheritDoc}
   263      */
   264     protected Content getNavSummaryLink(ClassDoc cd, boolean link) {
   265         if (link) {
   266             return writer.getHyperLink((cd == null)?
   267                 "enum_constant_summary":
   268                 "enum_constants_inherited_from_class_" +
   269                 configuration.getClassName(cd),
   270                 writer.getResource("doclet.navEnum"));
   271         } else {
   272             return writer.getResource("doclet.navEnum");
   273         }
   274     }
   276     /**
   277      * {@inheritDoc}
   278      */
   279     protected void addNavDetailLink(boolean link, Content liNav) {
   280         if (link) {
   281             liNav.addContent(writer.getHyperLink("enum_constant_detail",
   282                     writer.getResource("doclet.navEnum")));
   283         } else {
   284             liNav.addContent(writer.getResource("doclet.navEnum"));
   285         }
   286     }
   287 }

mercurial