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

Tue, 09 Oct 2012 19:10:00 -0700

author
jjg
date
Tue, 09 Oct 2012 19:10:00 -0700
changeset 1357
c75be5bc5283
parent 798
4868a36f6fd8
child 1359
25e14ad23cef
permissions
-rw-r--r--

8000663: clean up langtools imports
Reviewed-by: darcy

     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.*;
    34 /**
    35  * Writes annotation type required member documentation in HTML format.
    36  *
    37  * @author Jamie Ho
    38  * @author Bhavesh Patel (Modified)
    39  */
    40 public class AnnotationTypeRequiredMemberWriterImpl extends AbstractMemberWriter
    41     implements AnnotationTypeRequiredMemberWriter, MemberSummaryWriter {
    43     /**
    44      * Construct a new AnnotationTypeRequiredMemberWriterImpl.
    45      *
    46      * @param writer         the writer that will write the output.
    47      * @param annotationType the AnnotationType that holds this member.
    48      */
    49     public AnnotationTypeRequiredMemberWriterImpl(SubWriterHolderWriter writer,
    50         AnnotationTypeDoc annotationType) {
    51         super(writer, annotationType);
    52     }
    54     /**
    55      * {@inheritDoc}
    56      */
    57     public Content getMemberSummaryHeader(ClassDoc classDoc,
    58             Content memberSummaryTree) {
    59         memberSummaryTree.addContent(
    60                 HtmlConstants.START_OF_ANNOTATION_TYPE_REQUIRED_MEMBER_SUMMARY);
    61         Content memberTree = writer.getMemberTreeHeader();
    62         writer.addSummaryHeader(this, classDoc, memberTree);
    63         return memberTree;
    64     }
    66     /**
    67      * {@inheritDoc}
    68      */
    69     public void addAnnotationDetailsTreeHeader(ClassDoc classDoc,
    70             Content memberDetailsTree) {
    71         if (!writer.printedAnnotationHeading) {
    72             memberDetailsTree.addContent(writer.getMarkerAnchor(
    73                     "annotation_type_element_detail"));
    74             Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING,
    75                     writer.annotationTypeDetailsLabel);
    76             memberDetailsTree.addContent(heading);
    77             writer.printedAnnotationHeading = true;
    78         }
    79     }
    81     /**
    82      * {@inheritDoc}
    83      */
    84     public Content getAnnotationDocTreeHeader(MemberDoc member,
    85             Content annotationDetailsTree) {
    86         annotationDetailsTree.addContent(
    87                 writer.getMarkerAnchor(member.name() +
    88                 ((ExecutableMemberDoc) member).signature()));
    89         Content annotationDocTree = writer.getMemberTreeHeader();
    90         Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING);
    91         heading.addContent(member.name());
    92         annotationDocTree.addContent(heading);
    93         return annotationDocTree;
    94     }
    96     /**
    97      * {@inheritDoc}
    98      */
    99     public Content getSignature(MemberDoc member) {
   100         Content pre = new HtmlTree(HtmlTag.PRE);
   101         writer.addAnnotationInfo(member, pre);
   102         addModifiers(member, pre);
   103         Content link = new RawHtml(
   104                 writer.getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER,
   105                 getType(member))));
   106         pre.addContent(link);
   107         pre.addContent(writer.getSpace());
   108         if (configuration().linksource) {
   109             Content memberName = new StringContent(member.name());
   110             writer.addSrcLink(member, memberName, pre);
   111         } else {
   112             addName(member.name(), pre);
   113         }
   114         return pre;
   115     }
   117     /**
   118      * {@inheritDoc}
   119      */
   120     public void addDeprecated(MemberDoc member, Content annotationDocTree) {
   121         addDeprecatedInfo(member, annotationDocTree);
   122     }
   124     /**
   125      * {@inheritDoc}
   126      */
   127     public void addComments(MemberDoc member, Content annotationDocTree) {
   128         addComment(member, annotationDocTree);
   129     }
   131     /**
   132      * {@inheritDoc}
   133      */
   134     public void addTags(MemberDoc member, Content annotationDocTree) {
   135         writer.addTagsInfo(member, annotationDocTree);
   136     }
   138     /**
   139      * {@inheritDoc}
   140      */
   141     public Content getAnnotationDetails(Content annotationDetailsTree) {
   142         return getMemberTree(annotationDetailsTree);
   143     }
   145     /**
   146      * {@inheritDoc}
   147      */
   148     public Content getAnnotationDoc(Content annotationDocTree,
   149             boolean isLastContent) {
   150         return getMemberTree(annotationDocTree, isLastContent);
   151     }
   153     /**
   154      * Close the writer.
   155      */
   156     public void close() throws IOException {
   157         writer.close();
   158     }
   160     /**
   161      * {@inheritDoc}
   162      */
   163     public void addSummaryLabel(Content memberTree) {
   164         Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
   165                 writer.getResource("doclet.Annotation_Type_Required_Member_Summary"));
   166         memberTree.addContent(label);
   167     }
   169     /**
   170      * {@inheritDoc}
   171      */
   172     public String getTableSummary() {
   173         return configuration().getText("doclet.Member_Table_Summary",
   174                 configuration().getText("doclet.Annotation_Type_Required_Member_Summary"),
   175                 configuration().getText("doclet.annotation_type_required_members"));
   176     }
   178     /**
   179      * {@inheritDoc}
   180      */
   181     public String getCaption() {
   182         return configuration().getText("doclet.Annotation_Type_Required_Members");
   183     }
   185     /**
   186      * {@inheritDoc}
   187      */
   188     public String[] getSummaryTableHeader(ProgramElementDoc member) {
   189         String[] header = new String[] {
   190             writer.getModifierTypeHeader(),
   191             configuration().getText("doclet.0_and_1",
   192                     configuration().getText("doclet.Annotation_Type_Required_Member"),
   193                     configuration().getText("doclet.Description"))
   194         };
   195         return header;
   196     }
   198     /**
   199      * {@inheritDoc}
   200      */
   201     public void addSummaryAnchor(ClassDoc cd, Content memberTree) {
   202         memberTree.addContent(writer.getMarkerAnchor(
   203                 "annotation_type_required_element_summary"));
   204     }
   206     /**
   207      * {@inheritDoc}
   208      */
   209     public void addInheritedSummaryAnchor(ClassDoc cd, Content inheritedTree) {
   210     }
   212     /**
   213      * {@inheritDoc}
   214      */
   215     public void addInheritedSummaryLabel(ClassDoc cd, Content inheritedTree) {
   216     }
   218     /**
   219      * {@inheritDoc}
   220      */
   221     protected void addSummaryLink(int context, ClassDoc cd, ProgramElementDoc member,
   222             Content tdSummary) {
   223         Content strong = HtmlTree.STRONG(new RawHtml(
   224                 writer.getDocLink(context, (MemberDoc) member, member.name(), false)));
   225         Content code = HtmlTree.CODE(strong);
   226         tdSummary.addContent(code);
   227     }
   229     /**
   230      * {@inheritDoc}
   231      */
   232     protected void addInheritedSummaryLink(ClassDoc cd,
   233             ProgramElementDoc member, Content linksTree) {
   234         //Not applicable.
   235     }
   237     /**
   238      * {@inheritDoc}
   239      */
   240     protected void addSummaryType(ProgramElementDoc member, Content tdSummaryType) {
   241         MemberDoc m = (MemberDoc)member;
   242         addModifierAndType(m, getType(m), tdSummaryType);
   243     }
   245     /**
   246      * {@inheritDoc}
   247      */
   248     protected Content getDeprecatedLink(ProgramElementDoc member) {
   249         return writer.getDocLink(LinkInfoImpl.CONTEXT_MEMBER,
   250                 (MemberDoc) member, ((MemberDoc)member).qualifiedName());
   251     }
   253     /**
   254      * {@inheritDoc}
   255      */
   256     protected Content getNavSummaryLink(ClassDoc cd, boolean link) {
   257         if (link) {
   258             return writer.getHyperLink("", "annotation_type_required_element_summary",
   259                     writer.getResource("doclet.navAnnotationTypeRequiredMember"));
   260         } else {
   261             return writer.getResource("doclet.navAnnotationTypeRequiredMember");
   262         }
   263     }
   265     /**
   266      * {@inheritDoc}
   267      */
   268     protected void addNavDetailLink(boolean link, Content liNav) {
   269         if (link) {
   270             liNav.addContent(writer.getHyperLink("", "annotation_type_element_detail",
   271                     writer.getResource("doclet.navAnnotationTypeMember")));
   272         } else {
   273             liNav.addContent(writer.getResource("doclet.navAnnotationTypeMember"));
   274         }
   275     }
   277     private Type getType(MemberDoc member) {
   278         if (member instanceof FieldDoc) {
   279             return ((FieldDoc) member).type();
   280         } else {
   281             return ((MethodDoc) member).returnType();
   282         }
   283     }
   284 }

mercurial