1194N/A/*
1194N/A * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
1194N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1194N/A *
1194N/A * This code is free software; you can redistribute it and/or modify it
1194N/A * under the terms of the GNU General Public License version 2 only, as
1194N/A * published by the Free Software Foundation. Oracle designates this
1194N/A * particular file as subject to the "Classpath" exception as provided
1194N/A * by Oracle in the LICENSE file that accompanied this code.
1194N/A *
1194N/A * This code is distributed in the hope that it will be useful, but WITHOUT
1194N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1194N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1194N/A * version 2 for more details (a copy is included in the LICENSE file that
1194N/A * accompanied this code).
1194N/A *
1194N/A * You should have received a copy of the GNU General Public License version
1194N/A * 2 along with this work; if not, write to the Free Software Foundation,
1194N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1194N/A *
1194N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1194N/A * or visit www.oracle.com if you need additional information or have any
1194N/A * questions.
1194N/A */
1194N/A
1194N/Apackage com.sun.tools.doclets.formats.html;
1194N/A
1194N/Aimport java.io.*;
1194N/A
1194N/Aimport com.sun.javadoc.*;
1194N/Aimport com.sun.tools.doclets.formats.html.markup.*;
1194N/Aimport com.sun.tools.doclets.internal.toolkit.*;
1194N/Aimport com.sun.tools.doclets.internal.toolkit.util.*;
1194N/A
1194N/A/**
1194N/A * Writes property documentation in HTML format.
1194N/A *
1194N/A * @author Robert Field
1194N/A * @author Atul M Dambalkar
1194N/A * @author Jamie Ho (rewrite)
1194N/A * @author Bhavesh Patel (Modified)
1194N/A */
1194N/Apublic class PropertyWriterImpl extends AbstractMemberWriter
1194N/A implements PropertyWriter, MemberSummaryWriter {
1194N/A
1194N/A public PropertyWriterImpl(SubWriterHolderWriter writer, ClassDoc classdoc) {
1194N/A super(writer, classdoc);
1194N/A }
1194N/A
1194N/A /**
1194N/A * {@inheritDoc}
1194N/A */
1194N/A public Content getMemberSummaryHeader(ClassDoc classDoc,
1194N/A Content memberSummaryTree) {
1194N/A memberSummaryTree.addContent(HtmlConstants.START_OF_PROPERTY_SUMMARY);
1194N/A Content memberTree = writer.getMemberTreeHeader();
1194N/A writer.addSummaryHeader(this, classDoc, memberTree);
1194N/A return memberTree;
1194N/A }
1194N/A
1194N/A /**
1194N/A * {@inheritDoc}
1194N/A */
1194N/A public Content getFieldDetailsTreeHeader(ClassDoc classDoc,
1194N/A Content memberDetailsTree) {
1194N/A memberDetailsTree.addContent(HtmlConstants.START_OF_PROPERTY_DETAILS);
1194N/A Content fieldDetailsTree = writer.getMemberTreeHeader();
1194N/A fieldDetailsTree.addContent(writer.getMarkerAnchor("property_detail"));
1194N/A Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING,
1194N/A writer.propertyDetailsLabel);
1194N/A fieldDetailsTree.addContent(heading);
1194N/A return fieldDetailsTree;
1194N/A }
1194N/A
1194N/A /**
1194N/A * {@inheritDoc}
1194N/A */
1194N/A public Content getFieldDocTreeHeader(MethodDoc field,
1194N/A Content fieldDetailsTree) {
1194N/A fieldDetailsTree.addContent(
1194N/A writer.getMarkerAnchor(field.name()));
1194N/A Content fieldDocTree = writer.getMemberTreeHeader();
1194N/A Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING);
1194N/A heading.addContent(field.name().substring(0, field.name().lastIndexOf("Property")));
1194N/A fieldDocTree.addContent(heading);
1194N/A return fieldDocTree;
1194N/A }
1194N/A
1194N/A /**
1194N/A * {@inheritDoc}
1194N/A */
1194N/A public Content getSignature(MethodDoc field) {
1194N/A return new Comment("property signature");
1194N/A }
1194N/A
1194N/A /**
1194N/A * {@inheritDoc}
1194N/A */
1194N/A public void addDeprecated(MethodDoc field, Content fieldDocTree) {
1194N/A }
1194N/A
1194N/A /**
1194N/A * {@inheritDoc}
1194N/A */
1194N/A public void addComments(MethodDoc field, Content fieldDocTree) {
1194N/A ClassDoc holder = field.containingClass();
1194N/A if (field.inlineTags().length > 0) {
1194N/A if (holder.equals(classdoc) ||
1194N/A (! (holder.isPublic() || Util.isLinkable(holder, configuration())))) {
1194N/A writer.addInlineComment(field, fieldDocTree);
1194N/A } else {
1194N/A Content link = new RawHtml(
1194N/A writer.getDocLink(LinkInfoImpl.CONTEXT_FIELD_DOC_COPY,
1194N/A holder, field,
1194N/A holder.isIncluded() ?
1194N/A holder.typeName() : holder.qualifiedTypeName(),
1194N/A false));
1194N/A Content codeLink = HtmlTree.CODE(link);
1194N/A Content strong = HtmlTree.STRONG(holder.isClass()?
1194N/A writer.descfrmClassLabel : writer.descfrmInterfaceLabel);
1194N/A strong.addContent(writer.getSpace());
1194N/A strong.addContent(codeLink);
1194N/A fieldDocTree.addContent(HtmlTree.DIV(HtmlStyle.block, strong));
1194N/A writer.addInlineComment(field, fieldDocTree);
1194N/A }
1194N/A }
1194N/A }
1194N/A
1194N/A /**
1194N/A * {@inheritDoc}
1194N/A */
1194N/A public void addTags(MethodDoc field, Content fieldDocTree) {
1194N/A writer.addTagsInfo(field, fieldDocTree);
1194N/A }
1194N/A
1194N/A /**
1194N/A * {@inheritDoc}
1194N/A */
1194N/A public Content getFieldDetails(Content fieldDetailsTree) {
1194N/A return getMemberTree(fieldDetailsTree);
1194N/A }
1194N/A
1194N/A /**
1194N/A * {@inheritDoc}
1194N/A */
1194N/A public Content getFieldDoc(Content fieldDocTree,
1194N/A boolean isLastContent) {
1194N/A return getMemberTree(fieldDocTree, isLastContent);
1194N/A }
1194N/A
1194N/A /**
1194N/A * Close the writer.
1194N/A */
1194N/A public void close() throws IOException {
1194N/A writer.close();
1194N/A }
1194N/A
1194N/A public int getMemberKind() {
1194N/A return VisibleMemberMap.PROPERTIES;
1194N/A }
1194N/A
1194N/A /**
1194N/A * {@inheritDoc}
1194N/A */
1194N/A public void addSummaryLabel(Content memberTree) {
1194N/A Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
1194N/A writer.getResource("doclet.Property_Summary"));
1194N/A memberTree.addContent(label);
1194N/A }
1194N/A
1194N/A /**
1194N/A * {@inheritDoc}
1194N/A */
1194N/A public String getTableSummary() {
1194N/A return configuration().getText("doclet.Member_Table_Summary",
1194N/A configuration().getText("doclet.Property_Summary"),
1194N/A configuration().getText("doclet.properties"));
1194N/A }
1194N/A
1194N/A /**
1194N/A * {@inheritDoc}
1194N/A */
1194N/A public String getCaption() {
1194N/A return configuration().getText("doclet.Properties");
1194N/A }
1194N/A
1194N/A /**
1194N/A * {@inheritDoc}
1194N/A */
1194N/A public String[] getSummaryTableHeader(ProgramElementDoc member) {
1194N/A String[] header = new String[] {
1194N/A configuration().getText("doclet.Type"),
1194N/A configuration().getText("doclet.0_and_1",
1194N/A configuration().getText("doclet.Property"),
1194N/A configuration().getText("doclet.Description"))
1194N/A };
1194N/A return header;
1194N/A }
1194N/A
1194N/A /**
1194N/A * {@inheritDoc}
1194N/A */
1194N/A public void addSummaryAnchor(ClassDoc cd, Content memberTree) {
1194N/A memberTree.addContent(writer.getMarkerAnchor("property_summary"));
1194N/A }
1194N/A
1194N/A /**
1194N/A * {@inheritDoc}
1194N/A */
1194N/A public void addInheritedSummaryAnchor(ClassDoc cd, Content inheritedTree) {
1194N/A inheritedTree.addContent(writer.getMarkerAnchor(
1194N/A "properties_inherited_from_class_" + configuration().getClassName(cd)));
1194N/A }
1194N/A
1194N/A /**
1194N/A * {@inheritDoc}
1194N/A */
1194N/A public void addInheritedSummaryLabel(ClassDoc cd, Content inheritedTree) {
1194N/A Content classLink = new RawHtml(writer.getPreQualifiedClassLink(
1194N/A LinkInfoImpl.CONTEXT_MEMBER, cd, false));
1194N/A Content label = new StringContent(cd.isClass() ?
1194N/A configuration().getText("doclet.Properties_Inherited_From_Class") :
1194N/A configuration().getText("doclet.Properties_Inherited_From_Interface"));
1194N/A Content labelHeading = HtmlTree.HEADING(HtmlConstants.INHERITED_SUMMARY_HEADING,
1194N/A label);
1194N/A labelHeading.addContent(writer.getSpace());
1194N/A labelHeading.addContent(classLink);
1194N/A inheritedTree.addContent(labelHeading);
1194N/A }
1194N/A
1194N/A /**
1194N/A * {@inheritDoc}
1194N/A */
1194N/A protected void addSummaryLink(int context, ClassDoc cd, ProgramElementDoc member,
1194N/A Content tdSummary) {
1194N/A Content strong = HtmlTree.STRONG(new RawHtml(
1194N/A writer.getDocLink(context,
1194N/A cd,
1194N/A (MemberDoc) member,
1194N/A member.name().substring(0, member.name().lastIndexOf("Property")),
1194N/A false,
1194N/A true)));
1194N/A
1194N/A Content code = HtmlTree.CODE(strong);
1194N/A tdSummary.addContent(code);
1194N/A }
1194N/A
1194N/A /**
1194N/A * {@inheritDoc}
1194N/A */
1194N/A protected void addInheritedSummaryLink(ClassDoc cd,
1194N/A ProgramElementDoc member, Content linksTree) {
1194N/A linksTree.addContent(new RawHtml(
1194N/A writer.getDocLink(LinkInfoImpl.CONTEXT_MEMBER, cd, (MemberDoc)member,
1194N/A ((member.name().lastIndexOf("Property") != -1) && Configuration.getJavafxJavadoc())
1194N/A ? member.name().substring(0, member.name().length() - "Property".length())
1194N/A : member.name(),
1194N/A false, true)));
1194N/A }
1194N/A
1194N/A /**
1194N/A * {@inheritDoc}
1194N/A */
1194N/A protected void addSummaryType(ProgramElementDoc member, Content tdSummaryType) {
1194N/A MethodDoc method = (MethodDoc)member;
1194N/A addModifierAndType(method, method.returnType(), tdSummaryType);
1194N/A }
1194N/A
1194N/A /**
1194N/A * {@inheritDoc}
1194N/A */
1194N/A protected Content getDeprecatedLink(ProgramElementDoc member) {
1194N/A return writer.getDocLink(LinkInfoImpl.CONTEXT_MEMBER,
1194N/A (MemberDoc) member, ((MethodDoc)member).qualifiedName());
1194N/A }
1194N/A
1194N/A /**
1194N/A * {@inheritDoc}
1194N/A */
1194N/A protected Content getNavSummaryLink(ClassDoc cd, boolean link) {
1194N/A if (link) {
1194N/A return writer.getHyperLink("", (cd == null)?
1194N/A "property_summary":
1194N/A "properties_inherited_from_class_" +
1194N/A configuration().getClassName(cd),
1194N/A writer.getResource("doclet.navProperty"));
1194N/A } else {
1194N/A return writer.getResource("doclet.navProperty");
1194N/A }
1194N/A }
1194N/A
1194N/A /**
1194N/A * {@inheritDoc}
1194N/A */
1194N/A protected void addNavDetailLink(boolean link, Content liNav) {
1194N/A if (link) {
1194N/A liNav.addContent(writer.getHyperLink("", "property_detail",
1194N/A writer.getResource("doclet.navProperty")));
1194N/A } else {
1194N/A liNav.addContent(writer.getResource("doclet.navProperty"));
1194N/A }
1194N/A }
1194N/A}