jjg@1606: /* jjg@1606: * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. jjg@1606: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. jjg@1606: * jjg@1606: * This code is free software; you can redistribute it and/or modify it jjg@1606: * under the terms of the GNU General Public License version 2 only, as jjg@1606: * published by the Free Software Foundation. Oracle designates this jjg@1606: * particular file as subject to the "Classpath" exception as provided jjg@1606: * by Oracle in the LICENSE file that accompanied this code. jjg@1606: * jjg@1606: * This code is distributed in the hope that it will be useful, but WITHOUT jjg@1606: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or jjg@1606: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License jjg@1606: * version 2 for more details (a copy is included in the LICENSE file that jjg@1606: * accompanied this code). jjg@1606: * jjg@1606: * You should have received a copy of the GNU General Public License version jjg@1606: * 2 along with this work; if not, write to the Free Software Foundation, jjg@1606: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. jjg@1606: * jjg@1606: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA jjg@1606: * or visit www.oracle.com if you need additional information or have any jjg@1606: * questions. jjg@1606: */ jjg@1606: jjg@1606: package com.sun.tools.doclets.formats.html; jjg@1606: jjg@1606: import java.io.*; jjg@1606: jjg@1606: import com.sun.javadoc.*; jjg@1606: import com.sun.tools.doclets.formats.html.markup.*; jjg@1606: import com.sun.tools.doclets.internal.toolkit.*; jjg@1606: import com.sun.tools.doclets.internal.toolkit.util.*; jjg@1606: jjg@1606: /** jjg@1606: * Writes property documentation in HTML format. jjg@1606: * jjg@1606: *

This is NOT part of any supported API. jjg@1606: * If you write code that depends on this, you do so at your own risk. jjg@1606: * This code and its internal interfaces are subject to change or jjg@1606: * deletion without notice. jjg@1606: * jjg@1606: * @author Robert Field jjg@1606: * @author Atul M Dambalkar jjg@1606: * @author Jamie Ho (rewrite) jjg@1606: * @author Bhavesh Patel (Modified) jjg@1606: */ jjg@1606: public class PropertyWriterImpl extends AbstractMemberWriter jjg@1606: implements PropertyWriter, MemberSummaryWriter { jjg@1606: jjg@1606: public PropertyWriterImpl(SubWriterHolderWriter writer, ClassDoc classdoc) { jjg@1606: super(writer, classdoc); jjg@1606: } jjg@1606: jjg@1606: /** jjg@1606: * {@inheritDoc} jjg@1606: */ jjg@1606: public Content getMemberSummaryHeader(ClassDoc classDoc, jjg@1606: Content memberSummaryTree) { jjg@1606: memberSummaryTree.addContent(HtmlConstants.START_OF_PROPERTY_SUMMARY); jjg@1606: Content memberTree = writer.getMemberTreeHeader(); jjg@1606: writer.addSummaryHeader(this, classDoc, memberTree); jjg@1606: return memberTree; jjg@1606: } jjg@1606: jjg@1606: /** jjg@1606: * {@inheritDoc} jjg@1606: */ jjg@1606: public Content getPropertyDetailsTreeHeader(ClassDoc classDoc, jjg@1606: Content memberDetailsTree) { jjg@1606: memberDetailsTree.addContent(HtmlConstants.START_OF_PROPERTY_DETAILS); jjg@1606: Content propertyDetailsTree = writer.getMemberTreeHeader(); bpatel@2101: propertyDetailsTree.addContent(writer.getMarkerAnchor( bpatel@2101: SectionName.PROPERTY_DETAIL)); jjg@1606: Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING, jjg@1606: writer.propertyDetailsLabel); jjg@1606: propertyDetailsTree.addContent(heading); jjg@1606: return propertyDetailsTree; jjg@1606: } jjg@1606: jjg@1606: /** jjg@1606: * {@inheritDoc} jjg@1606: */ jjg@1606: public Content getPropertyDocTreeHeader(MethodDoc property, jjg@1606: Content propertyDetailsTree) { jjg@1606: propertyDetailsTree.addContent( jjg@1606: writer.getMarkerAnchor(property.name())); jjg@1606: Content propertyDocTree = writer.getMemberTreeHeader(); jjg@1606: Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING); jjg@1606: heading.addContent(property.name().substring(0, property.name().lastIndexOf("Property"))); jjg@1606: propertyDocTree.addContent(heading); jjg@1606: return propertyDocTree; jjg@1606: } jjg@1606: jjg@1606: /** jjg@1606: * {@inheritDoc} jjg@1606: */ jjg@1606: public Content getSignature(MethodDoc property) { jjg@1606: Content pre = new HtmlTree(HtmlTag.PRE); jjg@1606: writer.addAnnotationInfo(property, pre); jjg@1606: addModifiers(property, pre); jjg@1736: Content propertylink = writer.getLink(new LinkInfoImpl( jjg@1735: configuration, LinkInfoImpl.Kind.MEMBER, jjg@1736: property.returnType())); jjg@1606: pre.addContent(propertylink); jjg@1606: pre.addContent(" "); jjg@1606: if (configuration.linksource) { jjg@1606: Content propertyName = new StringContent(property.name()); jjg@1606: writer.addSrcLink(property, propertyName, pre); jjg@1606: } else { jjg@1606: addName(property.name(), pre); jjg@1606: } jjg@1606: return pre; jjg@1606: } jjg@1606: jjg@1606: /** jjg@1606: * {@inheritDoc} jjg@1606: */ jjg@1606: public void addDeprecated(MethodDoc property, Content propertyDocTree) { jjg@1606: } jjg@1606: jjg@1606: /** jjg@1606: * {@inheritDoc} jjg@1606: */ jjg@1606: public void addComments(MethodDoc property, Content propertyDocTree) { jjg@1606: ClassDoc holder = property.containingClass(); jjg@1606: if (property.inlineTags().length > 0) { jjg@1606: if (holder.equals(classdoc) || jjg@1606: (! (holder.isPublic() || Util.isLinkable(holder, configuration)))) { jjg@1606: writer.addInlineComment(property, propertyDocTree); jjg@1606: } else { jjg@1736: Content link = jjg@1735: writer.getDocLink(LinkInfoImpl.Kind.PROPERTY_DOC_COPY, jjg@1606: holder, property, jjg@1606: holder.isIncluded() ? jjg@1606: holder.typeName() : holder.qualifiedTypeName(), jjg@1736: false); jjg@1606: Content codeLink = HtmlTree.CODE(link); bpatel@2147: Content descfrmLabel = HtmlTree.SPAN(HtmlStyle.descfrmTypeLabel, holder.isClass()? jjg@1606: writer.descfrmClassLabel : writer.descfrmInterfaceLabel); bpatel@2147: descfrmLabel.addContent(writer.getSpace()); bpatel@2147: descfrmLabel.addContent(codeLink); bpatel@2147: propertyDocTree.addContent(HtmlTree.DIV(HtmlStyle.block, descfrmLabel)); jjg@1606: writer.addInlineComment(property, propertyDocTree); jjg@1606: } jjg@1606: } jjg@1606: } jjg@1606: jjg@1606: /** jjg@1606: * {@inheritDoc} jjg@1606: */ jjg@1606: public void addTags(MethodDoc property, Content propertyDocTree) { jjg@1606: writer.addTagsInfo(property, propertyDocTree); jjg@1606: } jjg@1606: jjg@1606: /** jjg@1606: * {@inheritDoc} jjg@1606: */ jjg@1606: public Content getPropertyDetails(Content propertyDetailsTree) { jjg@1606: return getMemberTree(propertyDetailsTree); jjg@1606: } jjg@1606: jjg@1606: /** jjg@1606: * {@inheritDoc} jjg@1606: */ jjg@1606: public Content getPropertyDoc(Content propertyDocTree, jjg@1606: boolean isLastContent) { jjg@1606: return getMemberTree(propertyDocTree, isLastContent); jjg@1606: } jjg@1606: jjg@1606: /** jjg@1606: * Close the writer. jjg@1606: */ jjg@1606: public void close() throws IOException { jjg@1606: writer.close(); jjg@1606: } jjg@1606: jjg@1606: public int getMemberKind() { jjg@1606: return VisibleMemberMap.PROPERTIES; jjg@1606: } jjg@1606: jjg@1606: /** jjg@1606: * {@inheritDoc} jjg@1606: */ jjg@1606: public void addSummaryLabel(Content memberTree) { jjg@1606: Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING, jjg@1606: writer.getResource("doclet.Property_Summary")); jjg@1606: memberTree.addContent(label); jjg@1606: } jjg@1606: jjg@1606: /** jjg@1606: * {@inheritDoc} jjg@1606: */ jjg@1606: public String getTableSummary() { jjg@1606: return configuration.getText("doclet.Member_Table_Summary", jjg@1606: configuration.getText("doclet.Property_Summary"), jjg@1606: configuration.getText("doclet.properties")); jjg@1606: } jjg@1606: jjg@1606: /** jjg@1606: * {@inheritDoc} jjg@1606: */ jjg@1747: public Content getCaption() { jjg@1747: return configuration.getResource("doclet.Properties"); jjg@1606: } jjg@1606: jjg@1606: /** jjg@1606: * {@inheritDoc} jjg@1606: */ jjg@1606: public String[] getSummaryTableHeader(ProgramElementDoc member) { jjg@1606: String[] header = new String[] { jjg@1606: configuration.getText("doclet.Type"), jjg@1606: configuration.getText("doclet.0_and_1", jjg@1606: configuration.getText("doclet.Property"), jjg@1606: configuration.getText("doclet.Description")) jjg@1606: }; jjg@1606: return header; jjg@1606: } jjg@1606: jjg@1606: /** jjg@1606: * {@inheritDoc} jjg@1606: */ jjg@1606: public void addSummaryAnchor(ClassDoc cd, Content memberTree) { bpatel@2101: memberTree.addContent(writer.getMarkerAnchor( bpatel@2101: SectionName.PROPERTY_SUMMARY)); jjg@1606: } jjg@1606: jjg@1606: /** jjg@1606: * {@inheritDoc} jjg@1606: */ jjg@1606: public void addInheritedSummaryAnchor(ClassDoc cd, Content inheritedTree) { jjg@1606: inheritedTree.addContent(writer.getMarkerAnchor( bpatel@2101: SectionName.PROPERTIES_INHERITANCE, bpatel@2101: configuration.getClassName(cd))); jjg@1606: } jjg@1606: jjg@1606: /** jjg@1606: * {@inheritDoc} jjg@1606: */ jjg@1606: public void addInheritedSummaryLabel(ClassDoc cd, Content inheritedTree) { jjg@1737: Content classLink = writer.getPreQualifiedClassLink( jjg@1737: LinkInfoImpl.Kind.MEMBER, cd, false); jjg@1606: Content label = new StringContent(cd.isClass() ? jjg@1606: configuration.getText("doclet.Properties_Inherited_From_Class") : jjg@1606: configuration.getText("doclet.Properties_Inherited_From_Interface")); jjg@1606: Content labelHeading = HtmlTree.HEADING(HtmlConstants.INHERITED_SUMMARY_HEADING, jjg@1606: label); jjg@1606: labelHeading.addContent(writer.getSpace()); jjg@1606: labelHeading.addContent(classLink); jjg@1606: inheritedTree.addContent(labelHeading); jjg@1606: } jjg@1606: jjg@1606: /** jjg@1606: * {@inheritDoc} jjg@1606: */ jjg@1735: protected void addSummaryLink(LinkInfoImpl.Kind context, ClassDoc cd, ProgramElementDoc member, jjg@1606: Content tdSummary) { bpatel@2147: Content memberLink = HtmlTree.SPAN(HtmlStyle.memberNameLink, bpatel@1935: writer.getDocLink(context, cd, bpatel@1935: (MemberDoc) member, bpatel@1935: member.name().substring(0, member.name().lastIndexOf("Property")), bpatel@1935: false, bpatel@1935: true)); jjg@1606: bpatel@2147: Content code = HtmlTree.CODE(memberLink); jjg@1606: tdSummary.addContent(code); jjg@1606: } jjg@1606: jjg@1606: /** jjg@1606: * {@inheritDoc} jjg@1606: */ jjg@1606: protected void addInheritedSummaryLink(ClassDoc cd, jjg@1606: ProgramElementDoc member, Content linksTree) { jjg@1736: linksTree.addContent( jjg@1735: writer.getDocLink(LinkInfoImpl.Kind.MEMBER, cd, (MemberDoc)member, jjg@1606: ((member.name().lastIndexOf("Property") != -1) && configuration.javafx) jjg@1606: ? member.name().substring(0, member.name().length() - "Property".length()) jjg@1606: : member.name(), jjg@1736: false, true)); jjg@1606: } jjg@1606: jjg@1606: /** jjg@1606: * {@inheritDoc} jjg@1606: */ jjg@1606: protected void addSummaryType(ProgramElementDoc member, Content tdSummaryType) { jjg@1606: MethodDoc property = (MethodDoc)member; jjg@1606: addModifierAndType(property, property.returnType(), tdSummaryType); jjg@1606: } jjg@1606: jjg@1606: /** jjg@1606: * {@inheritDoc} jjg@1606: */ jjg@1606: protected Content getDeprecatedLink(ProgramElementDoc member) { jjg@1735: return writer.getDocLink(LinkInfoImpl.Kind.MEMBER, jjg@1606: (MemberDoc) member, ((MethodDoc)member).qualifiedName()); jjg@1606: } jjg@1606: jjg@1606: /** jjg@1606: * {@inheritDoc} jjg@1606: */ jjg@1606: protected Content getNavSummaryLink(ClassDoc cd, boolean link) { jjg@1606: if (link) { bpatel@2101: if (cd == null) { bpatel@2101: return writer.getHyperLink( bpatel@2101: SectionName.PROPERTY_SUMMARY, jjg@1606: writer.getResource("doclet.navProperty")); bpatel@2101: } else { bpatel@2101: return writer.getHyperLink( bpatel@2101: SectionName.PROPERTIES_INHERITANCE, bpatel@2101: configuration.getClassName(cd), writer.getResource("doclet.navProperty")); bpatel@2101: } jjg@1606: } else { jjg@1606: return writer.getResource("doclet.navProperty"); jjg@1606: } jjg@1606: } jjg@1606: jjg@1606: /** jjg@1606: * {@inheritDoc} jjg@1606: */ jjg@1606: protected void addNavDetailLink(boolean link, Content liNav) { jjg@1606: if (link) { bpatel@2101: liNav.addContent(writer.getHyperLink( bpatel@2101: SectionName.PROPERTY_DETAIL, jjg@1606: writer.getResource("doclet.navProperty"))); jjg@1606: } else { jjg@1606: liNav.addContent(writer.getResource("doclet.navProperty")); jjg@1606: } jjg@1606: } jjg@1606: }