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

Tue, 24 Dec 2013 09:17:37 -0800

author
ksrini
date
Tue, 24 Dec 2013 09:17:37 -0800
changeset 2227
998b10c43157
parent 2147
130b8c0e570e
child 2525
2eb010b6cb22
permissions
-rw-r--r--

8029230: Update copyright year to match last edit in jdk8 langtools repository for 2013
Reviewed-by: ksrini
Contributed-by: steve.sides@oracle.com

jjg@1606 1 /*
jjg@1606 2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
jjg@1606 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
jjg@1606 4 *
jjg@1606 5 * This code is free software; you can redistribute it and/or modify it
jjg@1606 6 * under the terms of the GNU General Public License version 2 only, as
jjg@1606 7 * published by the Free Software Foundation. Oracle designates this
jjg@1606 8 * particular file as subject to the "Classpath" exception as provided
jjg@1606 9 * by Oracle in the LICENSE file that accompanied this code.
jjg@1606 10 *
jjg@1606 11 * This code is distributed in the hope that it will be useful, but WITHOUT
jjg@1606 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
jjg@1606 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
jjg@1606 14 * version 2 for more details (a copy is included in the LICENSE file that
jjg@1606 15 * accompanied this code).
jjg@1606 16 *
jjg@1606 17 * You should have received a copy of the GNU General Public License version
jjg@1606 18 * 2 along with this work; if not, write to the Free Software Foundation,
jjg@1606 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
jjg@1606 20 *
jjg@1606 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
jjg@1606 22 * or visit www.oracle.com if you need additional information or have any
jjg@1606 23 * questions.
jjg@1606 24 */
jjg@1606 25
jjg@1606 26 package com.sun.tools.doclets.formats.html;
jjg@1606 27
jjg@1606 28 import java.io.*;
jjg@1606 29
jjg@1606 30 import com.sun.javadoc.*;
jjg@1606 31 import com.sun.tools.doclets.formats.html.markup.*;
jjg@1606 32 import com.sun.tools.doclets.internal.toolkit.*;
jjg@1606 33 import com.sun.tools.doclets.internal.toolkit.util.*;
jjg@1606 34
jjg@1606 35 /**
jjg@1606 36 * Writes property documentation in HTML format.
jjg@1606 37 *
jjg@1606 38 * <p><b>This is NOT part of any supported API.
jjg@1606 39 * If you write code that depends on this, you do so at your own risk.
jjg@1606 40 * This code and its internal interfaces are subject to change or
jjg@1606 41 * deletion without notice.</b>
jjg@1606 42 *
jjg@1606 43 * @author Robert Field
jjg@1606 44 * @author Atul M Dambalkar
jjg@1606 45 * @author Jamie Ho (rewrite)
jjg@1606 46 * @author Bhavesh Patel (Modified)
jjg@1606 47 */
jjg@1606 48 public class PropertyWriterImpl extends AbstractMemberWriter
jjg@1606 49 implements PropertyWriter, MemberSummaryWriter {
jjg@1606 50
jjg@1606 51 public PropertyWriterImpl(SubWriterHolderWriter writer, ClassDoc classdoc) {
jjg@1606 52 super(writer, classdoc);
jjg@1606 53 }
jjg@1606 54
jjg@1606 55 /**
jjg@1606 56 * {@inheritDoc}
jjg@1606 57 */
jjg@1606 58 public Content getMemberSummaryHeader(ClassDoc classDoc,
jjg@1606 59 Content memberSummaryTree) {
jjg@1606 60 memberSummaryTree.addContent(HtmlConstants.START_OF_PROPERTY_SUMMARY);
jjg@1606 61 Content memberTree = writer.getMemberTreeHeader();
jjg@1606 62 writer.addSummaryHeader(this, classDoc, memberTree);
jjg@1606 63 return memberTree;
jjg@1606 64 }
jjg@1606 65
jjg@1606 66 /**
jjg@1606 67 * {@inheritDoc}
jjg@1606 68 */
jjg@1606 69 public Content getPropertyDetailsTreeHeader(ClassDoc classDoc,
jjg@1606 70 Content memberDetailsTree) {
jjg@1606 71 memberDetailsTree.addContent(HtmlConstants.START_OF_PROPERTY_DETAILS);
jjg@1606 72 Content propertyDetailsTree = writer.getMemberTreeHeader();
bpatel@2101 73 propertyDetailsTree.addContent(writer.getMarkerAnchor(
bpatel@2101 74 SectionName.PROPERTY_DETAIL));
jjg@1606 75 Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING,
jjg@1606 76 writer.propertyDetailsLabel);
jjg@1606 77 propertyDetailsTree.addContent(heading);
jjg@1606 78 return propertyDetailsTree;
jjg@1606 79 }
jjg@1606 80
jjg@1606 81 /**
jjg@1606 82 * {@inheritDoc}
jjg@1606 83 */
jjg@1606 84 public Content getPropertyDocTreeHeader(MethodDoc property,
jjg@1606 85 Content propertyDetailsTree) {
jjg@1606 86 propertyDetailsTree.addContent(
jjg@1606 87 writer.getMarkerAnchor(property.name()));
jjg@1606 88 Content propertyDocTree = writer.getMemberTreeHeader();
jjg@1606 89 Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING);
jjg@1606 90 heading.addContent(property.name().substring(0, property.name().lastIndexOf("Property")));
jjg@1606 91 propertyDocTree.addContent(heading);
jjg@1606 92 return propertyDocTree;
jjg@1606 93 }
jjg@1606 94
jjg@1606 95 /**
jjg@1606 96 * {@inheritDoc}
jjg@1606 97 */
jjg@1606 98 public Content getSignature(MethodDoc property) {
jjg@1606 99 Content pre = new HtmlTree(HtmlTag.PRE);
jjg@1606 100 writer.addAnnotationInfo(property, pre);
jjg@1606 101 addModifiers(property, pre);
jjg@1736 102 Content propertylink = writer.getLink(new LinkInfoImpl(
jjg@1735 103 configuration, LinkInfoImpl.Kind.MEMBER,
jjg@1736 104 property.returnType()));
jjg@1606 105 pre.addContent(propertylink);
jjg@1606 106 pre.addContent(" ");
jjg@1606 107 if (configuration.linksource) {
jjg@1606 108 Content propertyName = new StringContent(property.name());
jjg@1606 109 writer.addSrcLink(property, propertyName, pre);
jjg@1606 110 } else {
jjg@1606 111 addName(property.name(), pre);
jjg@1606 112 }
jjg@1606 113 return pre;
jjg@1606 114 }
jjg@1606 115
jjg@1606 116 /**
jjg@1606 117 * {@inheritDoc}
jjg@1606 118 */
jjg@1606 119 public void addDeprecated(MethodDoc property, Content propertyDocTree) {
jjg@1606 120 }
jjg@1606 121
jjg@1606 122 /**
jjg@1606 123 * {@inheritDoc}
jjg@1606 124 */
jjg@1606 125 public void addComments(MethodDoc property, Content propertyDocTree) {
jjg@1606 126 ClassDoc holder = property.containingClass();
jjg@1606 127 if (property.inlineTags().length > 0) {
jjg@1606 128 if (holder.equals(classdoc) ||
jjg@1606 129 (! (holder.isPublic() || Util.isLinkable(holder, configuration)))) {
jjg@1606 130 writer.addInlineComment(property, propertyDocTree);
jjg@1606 131 } else {
jjg@1736 132 Content link =
jjg@1735 133 writer.getDocLink(LinkInfoImpl.Kind.PROPERTY_DOC_COPY,
jjg@1606 134 holder, property,
jjg@1606 135 holder.isIncluded() ?
jjg@1606 136 holder.typeName() : holder.qualifiedTypeName(),
jjg@1736 137 false);
jjg@1606 138 Content codeLink = HtmlTree.CODE(link);
bpatel@2147 139 Content descfrmLabel = HtmlTree.SPAN(HtmlStyle.descfrmTypeLabel, holder.isClass()?
jjg@1606 140 writer.descfrmClassLabel : writer.descfrmInterfaceLabel);
bpatel@2147 141 descfrmLabel.addContent(writer.getSpace());
bpatel@2147 142 descfrmLabel.addContent(codeLink);
bpatel@2147 143 propertyDocTree.addContent(HtmlTree.DIV(HtmlStyle.block, descfrmLabel));
jjg@1606 144 writer.addInlineComment(property, propertyDocTree);
jjg@1606 145 }
jjg@1606 146 }
jjg@1606 147 }
jjg@1606 148
jjg@1606 149 /**
jjg@1606 150 * {@inheritDoc}
jjg@1606 151 */
jjg@1606 152 public void addTags(MethodDoc property, Content propertyDocTree) {
jjg@1606 153 writer.addTagsInfo(property, propertyDocTree);
jjg@1606 154 }
jjg@1606 155
jjg@1606 156 /**
jjg@1606 157 * {@inheritDoc}
jjg@1606 158 */
jjg@1606 159 public Content getPropertyDetails(Content propertyDetailsTree) {
jjg@1606 160 return getMemberTree(propertyDetailsTree);
jjg@1606 161 }
jjg@1606 162
jjg@1606 163 /**
jjg@1606 164 * {@inheritDoc}
jjg@1606 165 */
jjg@1606 166 public Content getPropertyDoc(Content propertyDocTree,
jjg@1606 167 boolean isLastContent) {
jjg@1606 168 return getMemberTree(propertyDocTree, isLastContent);
jjg@1606 169 }
jjg@1606 170
jjg@1606 171 /**
jjg@1606 172 * Close the writer.
jjg@1606 173 */
jjg@1606 174 public void close() throws IOException {
jjg@1606 175 writer.close();
jjg@1606 176 }
jjg@1606 177
jjg@1606 178 public int getMemberKind() {
jjg@1606 179 return VisibleMemberMap.PROPERTIES;
jjg@1606 180 }
jjg@1606 181
jjg@1606 182 /**
jjg@1606 183 * {@inheritDoc}
jjg@1606 184 */
jjg@1606 185 public void addSummaryLabel(Content memberTree) {
jjg@1606 186 Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
jjg@1606 187 writer.getResource("doclet.Property_Summary"));
jjg@1606 188 memberTree.addContent(label);
jjg@1606 189 }
jjg@1606 190
jjg@1606 191 /**
jjg@1606 192 * {@inheritDoc}
jjg@1606 193 */
jjg@1606 194 public String getTableSummary() {
jjg@1606 195 return configuration.getText("doclet.Member_Table_Summary",
jjg@1606 196 configuration.getText("doclet.Property_Summary"),
jjg@1606 197 configuration.getText("doclet.properties"));
jjg@1606 198 }
jjg@1606 199
jjg@1606 200 /**
jjg@1606 201 * {@inheritDoc}
jjg@1606 202 */
jjg@1747 203 public Content getCaption() {
jjg@1747 204 return configuration.getResource("doclet.Properties");
jjg@1606 205 }
jjg@1606 206
jjg@1606 207 /**
jjg@1606 208 * {@inheritDoc}
jjg@1606 209 */
jjg@1606 210 public String[] getSummaryTableHeader(ProgramElementDoc member) {
jjg@1606 211 String[] header = new String[] {
jjg@1606 212 configuration.getText("doclet.Type"),
jjg@1606 213 configuration.getText("doclet.0_and_1",
jjg@1606 214 configuration.getText("doclet.Property"),
jjg@1606 215 configuration.getText("doclet.Description"))
jjg@1606 216 };
jjg@1606 217 return header;
jjg@1606 218 }
jjg@1606 219
jjg@1606 220 /**
jjg@1606 221 * {@inheritDoc}
jjg@1606 222 */
jjg@1606 223 public void addSummaryAnchor(ClassDoc cd, Content memberTree) {
bpatel@2101 224 memberTree.addContent(writer.getMarkerAnchor(
bpatel@2101 225 SectionName.PROPERTY_SUMMARY));
jjg@1606 226 }
jjg@1606 227
jjg@1606 228 /**
jjg@1606 229 * {@inheritDoc}
jjg@1606 230 */
jjg@1606 231 public void addInheritedSummaryAnchor(ClassDoc cd, Content inheritedTree) {
jjg@1606 232 inheritedTree.addContent(writer.getMarkerAnchor(
bpatel@2101 233 SectionName.PROPERTIES_INHERITANCE,
bpatel@2101 234 configuration.getClassName(cd)));
jjg@1606 235 }
jjg@1606 236
jjg@1606 237 /**
jjg@1606 238 * {@inheritDoc}
jjg@1606 239 */
jjg@1606 240 public void addInheritedSummaryLabel(ClassDoc cd, Content inheritedTree) {
jjg@1737 241 Content classLink = writer.getPreQualifiedClassLink(
jjg@1737 242 LinkInfoImpl.Kind.MEMBER, cd, false);
jjg@1606 243 Content label = new StringContent(cd.isClass() ?
jjg@1606 244 configuration.getText("doclet.Properties_Inherited_From_Class") :
jjg@1606 245 configuration.getText("doclet.Properties_Inherited_From_Interface"));
jjg@1606 246 Content labelHeading = HtmlTree.HEADING(HtmlConstants.INHERITED_SUMMARY_HEADING,
jjg@1606 247 label);
jjg@1606 248 labelHeading.addContent(writer.getSpace());
jjg@1606 249 labelHeading.addContent(classLink);
jjg@1606 250 inheritedTree.addContent(labelHeading);
jjg@1606 251 }
jjg@1606 252
jjg@1606 253 /**
jjg@1606 254 * {@inheritDoc}
jjg@1606 255 */
jjg@1735 256 protected void addSummaryLink(LinkInfoImpl.Kind context, ClassDoc cd, ProgramElementDoc member,
jjg@1606 257 Content tdSummary) {
bpatel@2147 258 Content memberLink = HtmlTree.SPAN(HtmlStyle.memberNameLink,
bpatel@1935 259 writer.getDocLink(context, cd,
bpatel@1935 260 (MemberDoc) member,
bpatel@1935 261 member.name().substring(0, member.name().lastIndexOf("Property")),
bpatel@1935 262 false,
bpatel@1935 263 true));
jjg@1606 264
bpatel@2147 265 Content code = HtmlTree.CODE(memberLink);
jjg@1606 266 tdSummary.addContent(code);
jjg@1606 267 }
jjg@1606 268
jjg@1606 269 /**
jjg@1606 270 * {@inheritDoc}
jjg@1606 271 */
jjg@1606 272 protected void addInheritedSummaryLink(ClassDoc cd,
jjg@1606 273 ProgramElementDoc member, Content linksTree) {
jjg@1736 274 linksTree.addContent(
jjg@1735 275 writer.getDocLink(LinkInfoImpl.Kind.MEMBER, cd, (MemberDoc)member,
jjg@1606 276 ((member.name().lastIndexOf("Property") != -1) && configuration.javafx)
jjg@1606 277 ? member.name().substring(0, member.name().length() - "Property".length())
jjg@1606 278 : member.name(),
jjg@1736 279 false, true));
jjg@1606 280 }
jjg@1606 281
jjg@1606 282 /**
jjg@1606 283 * {@inheritDoc}
jjg@1606 284 */
jjg@1606 285 protected void addSummaryType(ProgramElementDoc member, Content tdSummaryType) {
jjg@1606 286 MethodDoc property = (MethodDoc)member;
jjg@1606 287 addModifierAndType(property, property.returnType(), tdSummaryType);
jjg@1606 288 }
jjg@1606 289
jjg@1606 290 /**
jjg@1606 291 * {@inheritDoc}
jjg@1606 292 */
jjg@1606 293 protected Content getDeprecatedLink(ProgramElementDoc member) {
jjg@1735 294 return writer.getDocLink(LinkInfoImpl.Kind.MEMBER,
jjg@1606 295 (MemberDoc) member, ((MethodDoc)member).qualifiedName());
jjg@1606 296 }
jjg@1606 297
jjg@1606 298 /**
jjg@1606 299 * {@inheritDoc}
jjg@1606 300 */
jjg@1606 301 protected Content getNavSummaryLink(ClassDoc cd, boolean link) {
jjg@1606 302 if (link) {
bpatel@2101 303 if (cd == null) {
bpatel@2101 304 return writer.getHyperLink(
bpatel@2101 305 SectionName.PROPERTY_SUMMARY,
jjg@1606 306 writer.getResource("doclet.navProperty"));
bpatel@2101 307 } else {
bpatel@2101 308 return writer.getHyperLink(
bpatel@2101 309 SectionName.PROPERTIES_INHERITANCE,
bpatel@2101 310 configuration.getClassName(cd), writer.getResource("doclet.navProperty"));
bpatel@2101 311 }
jjg@1606 312 } else {
jjg@1606 313 return writer.getResource("doclet.navProperty");
jjg@1606 314 }
jjg@1606 315 }
jjg@1606 316
jjg@1606 317 /**
jjg@1606 318 * {@inheritDoc}
jjg@1606 319 */
jjg@1606 320 protected void addNavDetailLink(boolean link, Content liNav) {
jjg@1606 321 if (link) {
bpatel@2101 322 liNav.addContent(writer.getHyperLink(
bpatel@2101 323 SectionName.PROPERTY_DETAIL,
jjg@1606 324 writer.getResource("doclet.navProperty")));
jjg@1606 325 } else {
jjg@1606 326 liNav.addContent(writer.getResource("doclet.navProperty"));
jjg@1606 327 }
jjg@1606 328 }
jjg@1606 329 }

mercurial