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

Fri, 04 Mar 2011 19:53:03 -0800

author
jjg
date
Fri, 04 Mar 2011 19:53:03 -0800
changeset 910
ebf7c13df6c0
parent 798
4868a36f6fd8
child 1359
25e14ad23cef
permissions
-rw-r--r--

6866185: Util.getPackageSourcePath should use lastIndexOf not indexOf and related cleanup
Reviewed-by: bpatel

     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 optional member documentation in HTML format.
    36  *
    37  * @author Jamie Ho
    38  * @author Bhavesh Patel (Modified)
    39  */
    40 public class AnnotationTypeOptionalMemberWriterImpl extends
    41         AnnotationTypeRequiredMemberWriterImpl
    42     implements AnnotationTypeOptionalMemberWriter, MemberSummaryWriter {
    44     /**
    45      * Construct a new AnnotationTypeOptionalMemberWriterImpl.
    46      *
    47      * @param writer         the writer that will write the output.
    48      * @param annotationType the AnnotationType that holds this member.
    49      */
    50     public AnnotationTypeOptionalMemberWriterImpl(SubWriterHolderWriter writer,
    51         AnnotationTypeDoc annotationType) {
    52         super(writer, annotationType);
    53     }
    55     /**
    56      * {@inheritDoc}
    57      */
    58     public Content getMemberSummaryHeader(ClassDoc classDoc,
    59             Content memberSummaryTree) {
    60         memberSummaryTree.addContent(
    61                 HtmlConstants.START_OF_ANNOTATION_TYPE_OPTIONAL_MEMBER_SUMMARY);
    62         Content memberTree = writer.getMemberTreeHeader();
    63         writer.addSummaryHeader(this, classDoc, memberTree);
    64         return memberTree;
    65     }
    67     /**
    68      * {@inheritDoc}
    69      */
    70     public void addDefaultValueInfo(MemberDoc member, Content annotationDocTree) {
    71         if (((AnnotationTypeElementDoc) member).defaultValue() != null) {
    72             Content dt = HtmlTree.DT(writer.getResource("doclet.Default"));
    73             Content dl = HtmlTree.DL(dt);
    74             Content dd = HtmlTree.DD(new StringContent(
    75                     ((AnnotationTypeElementDoc) member).defaultValue().toString()));
    76             dl.addContent(dd);
    77             annotationDocTree.addContent(dl);
    78         }
    79     }
    81     /**
    82      * {@inheritDoc}
    83      */
    84     public void close() throws IOException {
    85         writer.close();
    86     }
    88     /**
    89      * {@inheritDoc}
    90      */
    91     public void addSummaryLabel(Content memberTree) {
    92         Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
    93                 writer.getResource("doclet.Annotation_Type_Optional_Member_Summary"));
    94         memberTree.addContent(label);
    95     }
    97     /**
    98      * {@inheritDoc}
    99      */
   100     public String getTableSummary() {
   101         return configuration().getText("doclet.Member_Table_Summary",
   102                 configuration().getText("doclet.Annotation_Type_Optional_Member_Summary"),
   103                 configuration().getText("doclet.annotation_type_optional_members"));
   104     }
   106     /**
   107      * {@inheritDoc}
   108      */
   109     public String getCaption() {
   110         return configuration().getText("doclet.Annotation_Type_Optional_Members");
   111     }
   113     /**
   114      * {@inheritDoc}
   115      */
   116     public String[] getSummaryTableHeader(ProgramElementDoc member) {
   117         String[] header = new String[] {
   118             writer.getModifierTypeHeader(),
   119             configuration().getText("doclet.0_and_1",
   120                     configuration().getText("doclet.Annotation_Type_Optional_Member"),
   121                     configuration().getText("doclet.Description"))
   122         };
   123         return header;
   124     }
   126     /**
   127      * {@inheritDoc}
   128      */
   129     public void addSummaryAnchor(ClassDoc cd, Content memberTree) {
   130         memberTree.addContent(writer.getMarkerAnchor(
   131                 "annotation_type_optional_element_summary"));
   132     }
   134     /**
   135      * {@inheritDoc}
   136      */
   137     protected Content getNavSummaryLink(ClassDoc cd, boolean link) {
   138         if (link) {
   139             return writer.getHyperLink("", "annotation_type_optional_element_summary",
   140                     writer.getResource("doclet.navAnnotationTypeOptionalMember"));
   141         } else {
   142             return writer.getResource("doclet.navAnnotationTypeOptionalMember");
   143         }
   144     }
   145 }

mercurial