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

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

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

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

     1 /*
     2  * Copyright (c) 1997, 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 property 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 Robert Field
    44  * @author Atul M Dambalkar
    45  * @author Jamie Ho (rewrite)
    46  * @author Bhavesh Patel (Modified)
    47  */
    48 public class PropertyWriterImpl extends AbstractMemberWriter
    49     implements PropertyWriter, MemberSummaryWriter {
    51     public PropertyWriterImpl(SubWriterHolderWriter writer, ClassDoc classdoc) {
    52         super(writer, classdoc);
    53     }
    55     /**
    56      * {@inheritDoc}
    57      */
    58     public Content getMemberSummaryHeader(ClassDoc classDoc,
    59             Content memberSummaryTree) {
    60         memberSummaryTree.addContent(HtmlConstants.START_OF_PROPERTY_SUMMARY);
    61         Content memberTree = writer.getMemberTreeHeader();
    62         writer.addSummaryHeader(this, classDoc, memberTree);
    63         return memberTree;
    64     }
    66     /**
    67      * {@inheritDoc}
    68      */
    69     public Content getPropertyDetailsTreeHeader(ClassDoc classDoc,
    70             Content memberDetailsTree) {
    71         memberDetailsTree.addContent(HtmlConstants.START_OF_PROPERTY_DETAILS);
    72         Content propertyDetailsTree = writer.getMemberTreeHeader();
    73         propertyDetailsTree.addContent(writer.getMarkerAnchor("property_detail"));
    74         Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING,
    75                 writer.propertyDetailsLabel);
    76         propertyDetailsTree.addContent(heading);
    77         return propertyDetailsTree;
    78     }
    80     /**
    81      * {@inheritDoc}
    82      */
    83     public Content getPropertyDocTreeHeader(MethodDoc property,
    84             Content propertyDetailsTree) {
    85         propertyDetailsTree.addContent(
    86                 writer.getMarkerAnchor(property.name()));
    87         Content propertyDocTree = writer.getMemberTreeHeader();
    88         Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING);
    89         heading.addContent(property.name().substring(0, property.name().lastIndexOf("Property")));
    90         propertyDocTree.addContent(heading);
    91         return propertyDocTree;
    92     }
    94     /**
    95      * {@inheritDoc}
    96      */
    97     public Content getSignature(MethodDoc property) {
    98         Content pre = new HtmlTree(HtmlTag.PRE);
    99         writer.addAnnotationInfo(property, pre);
   100         addModifiers(property, pre);
   101         Content propertylink = writer.getLink(new LinkInfoImpl(
   102                 configuration, LinkInfoImpl.Kind.MEMBER,
   103                 property.returnType()));
   104         pre.addContent(propertylink);
   105         pre.addContent(" ");
   106         if (configuration.linksource) {
   107             Content propertyName = new StringContent(property.name());
   108             writer.addSrcLink(property, propertyName, pre);
   109         } else {
   110             addName(property.name(), pre);
   111         }
   112         return pre;
   113     }
   115     /**
   116      * {@inheritDoc}
   117      */
   118     public void addDeprecated(MethodDoc property, Content propertyDocTree) {
   119     }
   121     /**
   122      * {@inheritDoc}
   123      */
   124     public void addComments(MethodDoc property, Content propertyDocTree) {
   125         ClassDoc holder = property.containingClass();
   126         if (property.inlineTags().length > 0) {
   127             if (holder.equals(classdoc) ||
   128                     (! (holder.isPublic() || Util.isLinkable(holder, configuration)))) {
   129                 writer.addInlineComment(property, propertyDocTree);
   130             } else {
   131                 Content link =
   132                         writer.getDocLink(LinkInfoImpl.Kind.PROPERTY_DOC_COPY,
   133                         holder, property,
   134                         holder.isIncluded() ?
   135                             holder.typeName() : holder.qualifiedTypeName(),
   136                             false);
   137                 Content codeLink = HtmlTree.CODE(link);
   138                 Content strong = HtmlTree.STRONG(holder.isClass()?
   139                    writer.descfrmClassLabel : writer.descfrmInterfaceLabel);
   140                 strong.addContent(writer.getSpace());
   141                 strong.addContent(codeLink);
   142                 propertyDocTree.addContent(HtmlTree.DIV(HtmlStyle.block, strong));
   143                 writer.addInlineComment(property, propertyDocTree);
   144             }
   145         }
   146     }
   148     /**
   149      * {@inheritDoc}
   150      */
   151     public void addTags(MethodDoc property, Content propertyDocTree) {
   152         writer.addTagsInfo(property, propertyDocTree);
   153     }
   155     /**
   156      * {@inheritDoc}
   157      */
   158     public Content getPropertyDetails(Content propertyDetailsTree) {
   159         return getMemberTree(propertyDetailsTree);
   160     }
   162     /**
   163      * {@inheritDoc}
   164      */
   165     public Content getPropertyDoc(Content propertyDocTree,
   166             boolean isLastContent) {
   167         return getMemberTree(propertyDocTree, isLastContent);
   168     }
   170     /**
   171      * Close the writer.
   172      */
   173     public void close() throws IOException {
   174         writer.close();
   175     }
   177     public int getMemberKind() {
   178         return VisibleMemberMap.PROPERTIES;
   179     }
   181     /**
   182      * {@inheritDoc}
   183      */
   184     public void addSummaryLabel(Content memberTree) {
   185         Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
   186                 writer.getResource("doclet.Property_Summary"));
   187         memberTree.addContent(label);
   188     }
   190     /**
   191      * {@inheritDoc}
   192      */
   193     public String getTableSummary() {
   194         return configuration.getText("doclet.Member_Table_Summary",
   195                 configuration.getText("doclet.Property_Summary"),
   196                 configuration.getText("doclet.properties"));
   197     }
   199     /**
   200      * {@inheritDoc}
   201      */
   202     public Content getCaption() {
   203         return configuration.getResource("doclet.Properties");
   204     }
   206     /**
   207      * {@inheritDoc}
   208      */
   209     public String[] getSummaryTableHeader(ProgramElementDoc member) {
   210         String[] header = new String[] {
   211             configuration.getText("doclet.Type"),
   212             configuration.getText("doclet.0_and_1",
   213                     configuration.getText("doclet.Property"),
   214                     configuration.getText("doclet.Description"))
   215         };
   216         return header;
   217     }
   219     /**
   220      * {@inheritDoc}
   221      */
   222     public void addSummaryAnchor(ClassDoc cd, Content memberTree) {
   223         memberTree.addContent(writer.getMarkerAnchor("property_summary"));
   224     }
   226     /**
   227      * {@inheritDoc}
   228      */
   229     public void addInheritedSummaryAnchor(ClassDoc cd, Content inheritedTree) {
   230         inheritedTree.addContent(writer.getMarkerAnchor(
   231                 "properties_inherited_from_class_" + configuration.getClassName(cd)));
   232     }
   234     /**
   235      * {@inheritDoc}
   236      */
   237     public void addInheritedSummaryLabel(ClassDoc cd, Content inheritedTree) {
   238         Content classLink = writer.getPreQualifiedClassLink(
   239                 LinkInfoImpl.Kind.MEMBER, cd, false);
   240         Content label = new StringContent(cd.isClass() ?
   241             configuration.getText("doclet.Properties_Inherited_From_Class") :
   242             configuration.getText("doclet.Properties_Inherited_From_Interface"));
   243         Content labelHeading = HtmlTree.HEADING(HtmlConstants.INHERITED_SUMMARY_HEADING,
   244                 label);
   245         labelHeading.addContent(writer.getSpace());
   246         labelHeading.addContent(classLink);
   247         inheritedTree.addContent(labelHeading);
   248     }
   250     /**
   251      * {@inheritDoc}
   252      */
   253     protected void addSummaryLink(LinkInfoImpl.Kind context, ClassDoc cd, ProgramElementDoc member,
   254             Content tdSummary) {
   255         Content strong = HtmlTree.STRONG(
   256                 writer.getDocLink(context,
   257                         cd,
   258                         (MemberDoc) member,
   259                         member.name().substring(0, member.name().lastIndexOf("Property")),
   260                         false,
   261                         true));
   263         Content code = HtmlTree.CODE(strong);
   264         tdSummary.addContent(code);
   265     }
   267     /**
   268      * {@inheritDoc}
   269      */
   270     protected void addInheritedSummaryLink(ClassDoc cd,
   271             ProgramElementDoc member, Content linksTree) {
   272         linksTree.addContent(
   273                 writer.getDocLink(LinkInfoImpl.Kind.MEMBER, cd, (MemberDoc)member,
   274                 ((member.name().lastIndexOf("Property") != -1) && configuration.javafx)
   275                         ? member.name().substring(0, member.name().length() - "Property".length())
   276                         : member.name(),
   277                 false, true));
   278     }
   280     /**
   281      * {@inheritDoc}
   282      */
   283     protected void addSummaryType(ProgramElementDoc member, Content tdSummaryType) {
   284         MethodDoc property = (MethodDoc)member;
   285         addModifierAndType(property, property.returnType(), tdSummaryType);
   286     }
   288     /**
   289      * {@inheritDoc}
   290      */
   291     protected Content getDeprecatedLink(ProgramElementDoc member) {
   292         return writer.getDocLink(LinkInfoImpl.Kind.MEMBER,
   293                 (MemberDoc) member, ((MethodDoc)member).qualifiedName());
   294     }
   296     /**
   297      * {@inheritDoc}
   298      */
   299     protected Content getNavSummaryLink(ClassDoc cd, boolean link) {
   300         if (link) {
   301             return writer.getHyperLink((cd == null)?
   302                 "property_summary":
   303                 "properties_inherited_from_class_" +
   304                 configuration.getClassName(cd),
   305                 writer.getResource("doclet.navProperty"));
   306         } else {
   307             return writer.getResource("doclet.navProperty");
   308         }
   309     }
   311     /**
   312      * {@inheritDoc}
   313      */
   314     protected void addNavDetailLink(boolean link, Content liNav) {
   315         if (link) {
   316             liNav.addContent(writer.getHyperLink("property_detail",
   317                     writer.getResource("doclet.navProperty")));
   318         } else {
   319             liNav.addContent(writer.getResource("doclet.navProperty"));
   320         }
   321     }
   322 }

mercurial