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

changeset 1606
ccbe7ffdd867
child 1735
8ea30d59ac41
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/PropertyWriterImpl.java	Sun Feb 24 11:36:58 2013 -0800
     1.3 @@ -0,0 +1,322 @@
     1.4 +/*
     1.5 + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.  Oracle designates this
    1.11 + * particular file as subject to the "Classpath" exception as provided
    1.12 + * by Oracle in the LICENSE file that accompanied this code.
    1.13 + *
    1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.17 + * version 2 for more details (a copy is included in the LICENSE file that
    1.18 + * accompanied this code).
    1.19 + *
    1.20 + * You should have received a copy of the GNU General Public License version
    1.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.23 + *
    1.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.25 + * or visit www.oracle.com if you need additional information or have any
    1.26 + * questions.
    1.27 + */
    1.28 +
    1.29 +package com.sun.tools.doclets.formats.html;
    1.30 +
    1.31 +import java.io.*;
    1.32 +
    1.33 +import com.sun.javadoc.*;
    1.34 +import com.sun.tools.doclets.formats.html.markup.*;
    1.35 +import com.sun.tools.doclets.internal.toolkit.*;
    1.36 +import com.sun.tools.doclets.internal.toolkit.util.*;
    1.37 +
    1.38 +/**
    1.39 + * Writes property documentation in HTML format.
    1.40 + *
    1.41 + *  <p><b>This is NOT part of any supported API.
    1.42 + *  If you write code that depends on this, you do so at your own risk.
    1.43 + *  This code and its internal interfaces are subject to change or
    1.44 + *  deletion without notice.</b>
    1.45 + *
    1.46 + * @author Robert Field
    1.47 + * @author Atul M Dambalkar
    1.48 + * @author Jamie Ho (rewrite)
    1.49 + * @author Bhavesh Patel (Modified)
    1.50 + */
    1.51 +public class PropertyWriterImpl extends AbstractMemberWriter
    1.52 +    implements PropertyWriter, MemberSummaryWriter {
    1.53 +
    1.54 +    public PropertyWriterImpl(SubWriterHolderWriter writer, ClassDoc classdoc) {
    1.55 +        super(writer, classdoc);
    1.56 +    }
    1.57 +
    1.58 +    /**
    1.59 +     * {@inheritDoc}
    1.60 +     */
    1.61 +    public Content getMemberSummaryHeader(ClassDoc classDoc,
    1.62 +            Content memberSummaryTree) {
    1.63 +        memberSummaryTree.addContent(HtmlConstants.START_OF_PROPERTY_SUMMARY);
    1.64 +        Content memberTree = writer.getMemberTreeHeader();
    1.65 +        writer.addSummaryHeader(this, classDoc, memberTree);
    1.66 +        return memberTree;
    1.67 +    }
    1.68 +
    1.69 +    /**
    1.70 +     * {@inheritDoc}
    1.71 +     */
    1.72 +    public Content getPropertyDetailsTreeHeader(ClassDoc classDoc,
    1.73 +            Content memberDetailsTree) {
    1.74 +        memberDetailsTree.addContent(HtmlConstants.START_OF_PROPERTY_DETAILS);
    1.75 +        Content propertyDetailsTree = writer.getMemberTreeHeader();
    1.76 +        propertyDetailsTree.addContent(writer.getMarkerAnchor("property_detail"));
    1.77 +        Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING,
    1.78 +                writer.propertyDetailsLabel);
    1.79 +        propertyDetailsTree.addContent(heading);
    1.80 +        return propertyDetailsTree;
    1.81 +    }
    1.82 +
    1.83 +    /**
    1.84 +     * {@inheritDoc}
    1.85 +     */
    1.86 +    public Content getPropertyDocTreeHeader(MethodDoc property,
    1.87 +            Content propertyDetailsTree) {
    1.88 +        propertyDetailsTree.addContent(
    1.89 +                writer.getMarkerAnchor(property.name()));
    1.90 +        Content propertyDocTree = writer.getMemberTreeHeader();
    1.91 +        Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING);
    1.92 +        heading.addContent(property.name().substring(0, property.name().lastIndexOf("Property")));
    1.93 +        propertyDocTree.addContent(heading);
    1.94 +        return propertyDocTree;
    1.95 +    }
    1.96 +
    1.97 +    /**
    1.98 +     * {@inheritDoc}
    1.99 +     */
   1.100 +    public Content getSignature(MethodDoc property) {
   1.101 +        Content pre = new HtmlTree(HtmlTag.PRE);
   1.102 +        writer.addAnnotationInfo(property, pre);
   1.103 +        addModifiers(property, pre);
   1.104 +        Content propertylink = new RawHtml(writer.getLink(new LinkInfoImpl(
   1.105 +                configuration, LinkInfoImpl.CONTEXT_MEMBER,
   1.106 +                property.returnType())));
   1.107 +        pre.addContent(propertylink);
   1.108 +        pre.addContent(" ");
   1.109 +        if (configuration.linksource) {
   1.110 +            Content propertyName = new StringContent(property.name());
   1.111 +            writer.addSrcLink(property, propertyName, pre);
   1.112 +        } else {
   1.113 +            addName(property.name(), pre);
   1.114 +        }
   1.115 +        return pre;
   1.116 +    }
   1.117 +
   1.118 +    /**
   1.119 +     * {@inheritDoc}
   1.120 +     */
   1.121 +    public void addDeprecated(MethodDoc property, Content propertyDocTree) {
   1.122 +    }
   1.123 +
   1.124 +    /**
   1.125 +     * {@inheritDoc}
   1.126 +     */
   1.127 +    public void addComments(MethodDoc property, Content propertyDocTree) {
   1.128 +        ClassDoc holder = property.containingClass();
   1.129 +        if (property.inlineTags().length > 0) {
   1.130 +            if (holder.equals(classdoc) ||
   1.131 +                    (! (holder.isPublic() || Util.isLinkable(holder, configuration)))) {
   1.132 +                writer.addInlineComment(property, propertyDocTree);
   1.133 +            } else {
   1.134 +                Content link = new RawHtml(
   1.135 +                        writer.getDocLink(LinkInfoImpl.CONTEXT_PROPERTY_DOC_COPY,
   1.136 +                        holder, property,
   1.137 +                        holder.isIncluded() ?
   1.138 +                            holder.typeName() : holder.qualifiedTypeName(),
   1.139 +                            false));
   1.140 +                Content codeLink = HtmlTree.CODE(link);
   1.141 +                Content strong = HtmlTree.STRONG(holder.isClass()?
   1.142 +                   writer.descfrmClassLabel : writer.descfrmInterfaceLabel);
   1.143 +                strong.addContent(writer.getSpace());
   1.144 +                strong.addContent(codeLink);
   1.145 +                propertyDocTree.addContent(HtmlTree.DIV(HtmlStyle.block, strong));
   1.146 +                writer.addInlineComment(property, propertyDocTree);
   1.147 +            }
   1.148 +        }
   1.149 +    }
   1.150 +
   1.151 +    /**
   1.152 +     * {@inheritDoc}
   1.153 +     */
   1.154 +    public void addTags(MethodDoc property, Content propertyDocTree) {
   1.155 +        writer.addTagsInfo(property, propertyDocTree);
   1.156 +    }
   1.157 +
   1.158 +    /**
   1.159 +     * {@inheritDoc}
   1.160 +     */
   1.161 +    public Content getPropertyDetails(Content propertyDetailsTree) {
   1.162 +        return getMemberTree(propertyDetailsTree);
   1.163 +    }
   1.164 +
   1.165 +    /**
   1.166 +     * {@inheritDoc}
   1.167 +     */
   1.168 +    public Content getPropertyDoc(Content propertyDocTree,
   1.169 +            boolean isLastContent) {
   1.170 +        return getMemberTree(propertyDocTree, isLastContent);
   1.171 +    }
   1.172 +
   1.173 +    /**
   1.174 +     * Close the writer.
   1.175 +     */
   1.176 +    public void close() throws IOException {
   1.177 +        writer.close();
   1.178 +    }
   1.179 +
   1.180 +    public int getMemberKind() {
   1.181 +        return VisibleMemberMap.PROPERTIES;
   1.182 +    }
   1.183 +
   1.184 +    /**
   1.185 +     * {@inheritDoc}
   1.186 +     */
   1.187 +    public void addSummaryLabel(Content memberTree) {
   1.188 +        Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
   1.189 +                writer.getResource("doclet.Property_Summary"));
   1.190 +        memberTree.addContent(label);
   1.191 +    }
   1.192 +
   1.193 +    /**
   1.194 +     * {@inheritDoc}
   1.195 +     */
   1.196 +    public String getTableSummary() {
   1.197 +        return configuration.getText("doclet.Member_Table_Summary",
   1.198 +                configuration.getText("doclet.Property_Summary"),
   1.199 +                configuration.getText("doclet.properties"));
   1.200 +    }
   1.201 +
   1.202 +    /**
   1.203 +     * {@inheritDoc}
   1.204 +     */
   1.205 +    public String getCaption() {
   1.206 +        return configuration.getText("doclet.Properties");
   1.207 +    }
   1.208 +
   1.209 +    /**
   1.210 +     * {@inheritDoc}
   1.211 +     */
   1.212 +    public String[] getSummaryTableHeader(ProgramElementDoc member) {
   1.213 +        String[] header = new String[] {
   1.214 +            configuration.getText("doclet.Type"),
   1.215 +            configuration.getText("doclet.0_and_1",
   1.216 +                    configuration.getText("doclet.Property"),
   1.217 +                    configuration.getText("doclet.Description"))
   1.218 +        };
   1.219 +        return header;
   1.220 +    }
   1.221 +
   1.222 +    /**
   1.223 +     * {@inheritDoc}
   1.224 +     */
   1.225 +    public void addSummaryAnchor(ClassDoc cd, Content memberTree) {
   1.226 +        memberTree.addContent(writer.getMarkerAnchor("property_summary"));
   1.227 +    }
   1.228 +
   1.229 +    /**
   1.230 +     * {@inheritDoc}
   1.231 +     */
   1.232 +    public void addInheritedSummaryAnchor(ClassDoc cd, Content inheritedTree) {
   1.233 +        inheritedTree.addContent(writer.getMarkerAnchor(
   1.234 +                "properties_inherited_from_class_" + configuration.getClassName(cd)));
   1.235 +    }
   1.236 +
   1.237 +    /**
   1.238 +     * {@inheritDoc}
   1.239 +     */
   1.240 +    public void addInheritedSummaryLabel(ClassDoc cd, Content inheritedTree) {
   1.241 +        Content classLink = new RawHtml(writer.getPreQualifiedClassLink(
   1.242 +                LinkInfoImpl.CONTEXT_MEMBER, cd, false));
   1.243 +        Content label = new StringContent(cd.isClass() ?
   1.244 +            configuration.getText("doclet.Properties_Inherited_From_Class") :
   1.245 +            configuration.getText("doclet.Properties_Inherited_From_Interface"));
   1.246 +        Content labelHeading = HtmlTree.HEADING(HtmlConstants.INHERITED_SUMMARY_HEADING,
   1.247 +                label);
   1.248 +        labelHeading.addContent(writer.getSpace());
   1.249 +        labelHeading.addContent(classLink);
   1.250 +        inheritedTree.addContent(labelHeading);
   1.251 +    }
   1.252 +
   1.253 +    /**
   1.254 +     * {@inheritDoc}
   1.255 +     */
   1.256 +    protected void addSummaryLink(int context, ClassDoc cd, ProgramElementDoc member,
   1.257 +            Content tdSummary) {
   1.258 +        Content strong = HtmlTree.STRONG(new RawHtml(
   1.259 +                writer.getDocLink(context,
   1.260 +                        cd,
   1.261 +                        (MemberDoc) member,
   1.262 +                        member.name().substring(0, member.name().lastIndexOf("Property")),
   1.263 +                        false,
   1.264 +                        true)));
   1.265 +
   1.266 +        Content code = HtmlTree.CODE(strong);
   1.267 +        tdSummary.addContent(code);
   1.268 +    }
   1.269 +
   1.270 +    /**
   1.271 +     * {@inheritDoc}
   1.272 +     */
   1.273 +    protected void addInheritedSummaryLink(ClassDoc cd,
   1.274 +            ProgramElementDoc member, Content linksTree) {
   1.275 +        linksTree.addContent(new RawHtml(
   1.276 +                writer.getDocLink(LinkInfoImpl.CONTEXT_MEMBER, cd, (MemberDoc)member,
   1.277 +                ((member.name().lastIndexOf("Property") != -1) && configuration.javafx)
   1.278 +                        ? member.name().substring(0, member.name().length() - "Property".length())
   1.279 +                        : member.name(),
   1.280 +                false, true)));
   1.281 +    }
   1.282 +
   1.283 +    /**
   1.284 +     * {@inheritDoc}
   1.285 +     */
   1.286 +    protected void addSummaryType(ProgramElementDoc member, Content tdSummaryType) {
   1.287 +        MethodDoc property = (MethodDoc)member;
   1.288 +        addModifierAndType(property, property.returnType(), tdSummaryType);
   1.289 +    }
   1.290 +
   1.291 +    /**
   1.292 +     * {@inheritDoc}
   1.293 +     */
   1.294 +    protected Content getDeprecatedLink(ProgramElementDoc member) {
   1.295 +        return writer.getDocLink(LinkInfoImpl.CONTEXT_MEMBER,
   1.296 +                (MemberDoc) member, ((MethodDoc)member).qualifiedName());
   1.297 +    }
   1.298 +
   1.299 +    /**
   1.300 +     * {@inheritDoc}
   1.301 +     */
   1.302 +    protected Content getNavSummaryLink(ClassDoc cd, boolean link) {
   1.303 +        if (link) {
   1.304 +            return writer.getHyperLink((cd == null)?
   1.305 +                "property_summary":
   1.306 +                "properties_inherited_from_class_" +
   1.307 +                configuration.getClassName(cd),
   1.308 +                writer.getResource("doclet.navProperty"));
   1.309 +        } else {
   1.310 +            return writer.getResource("doclet.navProperty");
   1.311 +        }
   1.312 +    }
   1.313 +
   1.314 +    /**
   1.315 +     * {@inheritDoc}
   1.316 +     */
   1.317 +    protected void addNavDetailLink(boolean link, Content liNav) {
   1.318 +        if (link) {
   1.319 +            liNav.addContent(writer.getHyperLink("property_detail",
   1.320 +                    writer.getResource("doclet.navProperty")));
   1.321 +        } else {
   1.322 +            liNav.addContent(writer.getResource("doclet.navProperty"));
   1.323 +        }
   1.324 +    }
   1.325 +}

mercurial