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

Thu, 15 Nov 2012 19:54:20 -0800

author
jjg
date
Thu, 15 Nov 2012 19:54:20 -0800
changeset 1412
400a4e8accd3
parent 1372
78962d89f283
child 1417
522a1ee72340
permissions
-rw-r--r--

8002079: update DocFile to use a JavaFileManager
Reviewed-by: darcy

duke@1 1 /*
jjg@1357 2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
duke@1 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@1 4 *
duke@1 5 * This code is free software; you can redistribute it and/or modify it
duke@1 6 * under the terms of the GNU General Public License version 2 only, as
ohair@554 7 * published by the Free Software Foundation. Oracle designates this
duke@1 8 * particular file as subject to the "Classpath" exception as provided
ohair@554 9 * by Oracle in the LICENSE file that accompanied this code.
duke@1 10 *
duke@1 11 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@1 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@1 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@1 14 * version 2 for more details (a copy is included in the LICENSE file that
duke@1 15 * accompanied this code).
duke@1 16 *
duke@1 17 * You should have received a copy of the GNU General Public License version
duke@1 18 * 2 along with this work; if not, write to the Free Software Foundation,
duke@1 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@1 20 *
ohair@554 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ohair@554 22 * or visit www.oracle.com if you need additional information or have any
ohair@554 23 * questions.
duke@1 24 */
duke@1 25
duke@1 26 package com.sun.tools.doclets.formats.html;
duke@1 27
bpatel@766 28 import java.io.*;
jjg@1357 29
duke@1 30 import com.sun.javadoc.*;
jjg@1357 31 import com.sun.tools.doclets.formats.html.markup.*;
bpatel@766 32 import com.sun.tools.doclets.internal.toolkit.*;
duke@1 33 import com.sun.tools.doclets.internal.toolkit.util.*;
duke@1 34
duke@1 35 /**
duke@1 36 * This abstract class exists to provide functionality needed in the
duke@1 37 * the formatting of member information. Since AbstractSubWriter and its
duke@1 38 * subclasses control this, they would be the logical place to put this.
duke@1 39 * However, because each member type has its own subclass, subclassing
duke@1 40 * can not be used effectively to change formatting. The concrete
duke@1 41 * class subclass of this class can be subclassed to change formatting.
duke@1 42 *
jjg@1359 43 * <p><b>This is NOT part of any supported API.
jjg@1359 44 * If you write code that depends on this, you do so at your own risk.
jjg@1359 45 * This code and its internal interfaces are subject to change or
jjg@1359 46 * deletion without notice.</b>
jjg@1359 47 *
duke@1 48 * @see AbstractMemberWriter
duke@1 49 * @see ClassWriterImpl
duke@1 50 *
duke@1 51 * @author Robert Field
duke@1 52 * @author Atul M Dambalkar
bpatel@243 53 * @author Bhavesh Patel (Modified)
duke@1 54 */
duke@1 55 public abstract class SubWriterHolderWriter extends HtmlDocletWriter {
duke@1 56
jjg@1372 57 public SubWriterHolderWriter(ConfigurationImpl configuration, DocPath filename)
jjg@1372 58 throws IOException {
duke@1 59 super(configuration, filename);
duke@1 60 }
duke@1 61
bpatel@766 62 /**
bpatel@766 63 * Add the summary header.
bpatel@766 64 *
bpatel@766 65 * @param mw the writer for the member being documented
bpatel@766 66 * @param cd the classdoc to be documented
bpatel@766 67 * @param memberTree the content tree to which the summary header will be added
bpatel@766 68 */
bpatel@766 69 public void addSummaryHeader(AbstractMemberWriter mw, ClassDoc cd,
bpatel@766 70 Content memberTree) {
bpatel@766 71 mw.addSummaryAnchor(cd, memberTree);
bpatel@766 72 mw.addSummaryLabel(memberTree);
bpatel@766 73 }
bpatel@766 74
bpatel@766 75 /**
bpatel@766 76 * Get the summary table.
bpatel@766 77 *
bpatel@766 78 * @param mw the writer for the member being documented
bpatel@766 79 * @param cd the classdoc to be documented
bpatel@766 80 * @return the content tree for the summary table
bpatel@766 81 */
bpatel@766 82 public Content getSummaryTableTree(AbstractMemberWriter mw, ClassDoc cd) {
bpatel@766 83 Content table = HtmlTree.TABLE(HtmlStyle.overviewSummary, 0, 3, 0,
bpatel@766 84 mw.getTableSummary(), getTableCaption(mw.getCaption()));
bpatel@766 85 table.addContent(getSummaryTableHeader(mw.getSummaryTableHeader(cd), "col"));
bpatel@766 86 return table;
duke@1 87 }
duke@1 88
bpatel@766 89 /**
bpatel@766 90 * Add the inherited summary header.
bpatel@766 91 *
bpatel@766 92 * @param mw the writer for the member being documented
bpatel@766 93 * @param cd the classdoc to be documented
bpatel@766 94 * @param inheritedTree the content tree to which the inherited summary header will be added
bpatel@766 95 */
bpatel@766 96 public void addInheritedSummaryHeader(AbstractMemberWriter mw, ClassDoc cd,
bpatel@766 97 Content inheritedTree) {
bpatel@766 98 mw.addInheritedSummaryAnchor(cd, inheritedTree);
bpatel@766 99 mw.addInheritedSummaryLabel(cd, inheritedTree);
duke@1 100 }
duke@1 101
bpatel@766 102 /**
bpatel@766 103 * Add the index comment.
bpatel@766 104 *
bpatel@766 105 * @param member the member being documented
bpatel@766 106 * @param contentTree the content tree to which the comment will be added
bpatel@766 107 */
bpatel@766 108 protected void addIndexComment(Doc member, Content contentTree) {
bpatel@766 109 addIndexComment(member, member.firstSentenceTags(), contentTree);
duke@1 110 }
duke@1 111
bpatel@766 112 /**
bpatel@766 113 * Add the index comment.
bpatel@766 114 *
bpatel@766 115 * @param member the member being documented
bpatel@766 116 * @param firstSentenceTags the first sentence tags for the member to be documented
bpatel@766 117 * @param tdSummary the content tree to which the comment will be added
bpatel@766 118 */
bpatel@766 119 protected void addIndexComment(Doc member, Tag[] firstSentenceTags,
bpatel@766 120 Content tdSummary) {
bpatel@766 121 Tag[] deprs = member.tags("deprecated");
bpatel@766 122 Content div;
bpatel@766 123 if (Util.isDeprecated((ProgramElementDoc) member)) {
bpatel@766 124 Content strong = HtmlTree.STRONG(deprecatedPhrase);
bpatel@766 125 div = HtmlTree.DIV(HtmlStyle.block, strong);
bpatel@766 126 div.addContent(getSpace());
bpatel@766 127 if (deprs.length > 0) {
bpatel@766 128 addInlineDeprecatedComment(member, deprs[0], div);
bpatel@766 129 }
bpatel@766 130 tdSummary.addContent(div);
bpatel@766 131 return;
bpatel@766 132 } else {
bpatel@766 133 ClassDoc cd = ((ProgramElementDoc)member).containingClass();
bpatel@766 134 if (cd != null && Util.isDeprecated(cd)) {
bpatel@766 135 Content strong = HtmlTree.STRONG(deprecatedPhrase);
bpatel@766 136 div = HtmlTree.DIV(HtmlStyle.block, strong);
bpatel@766 137 div.addContent(getSpace());
bpatel@766 138 tdSummary.addContent(div);
bpatel@766 139 }
bpatel@766 140 }
bpatel@766 141 addSummaryComment(member, firstSentenceTags, tdSummary);
duke@1 142 }
duke@1 143
bpatel@766 144 /**
bpatel@766 145 * Add the summary type for the member.
bpatel@766 146 *
bpatel@766 147 * @param mw the writer for the member being documented
bpatel@766 148 * @param member the member to be documented
bpatel@766 149 * @param tdSummaryType the content tree to which the type will be added
bpatel@766 150 */
bpatel@766 151 public void addSummaryType(AbstractMemberWriter mw, ProgramElementDoc member,
bpatel@766 152 Content tdSummaryType) {
bpatel@766 153 mw.addSummaryType(member, tdSummaryType);
bpatel@766 154 }
bpatel@766 155
bpatel@766 156 /**
bpatel@766 157 * Add the summary link for the member.
bpatel@766 158 *
bpatel@766 159 * @param mw the writer for the member being documented
bpatel@766 160 * @param member the member to be documented
bpatel@766 161 * @param contentTree the content tree to which the link will be added
bpatel@766 162 */
bpatel@766 163 public void addSummaryLinkComment(AbstractMemberWriter mw,
bpatel@766 164 ProgramElementDoc member, Content contentTree) {
bpatel@766 165 addSummaryLinkComment(mw, member, member.firstSentenceTags(), contentTree);
duke@1 166 }
duke@1 167
bpatel@766 168 /**
bpatel@766 169 * Add the summary link comment.
bpatel@766 170 *
bpatel@766 171 * @param mw the writer for the member being documented
bpatel@766 172 * @param member the member being documented
bpatel@766 173 * @param firstSentenceTags the first sentence tags for the member to be documented
bpatel@766 174 * @param tdSummary the content tree to which the comment will be added
bpatel@766 175 */
bpatel@766 176 public void addSummaryLinkComment(AbstractMemberWriter mw,
bpatel@766 177 ProgramElementDoc member, Tag[] firstSentenceTags, Content tdSummary) {
bpatel@766 178 addIndexComment(member, firstSentenceTags, tdSummary);
bpatel@766 179 }
bpatel@766 180
bpatel@766 181 /**
bpatel@766 182 * Add the inherited member summary.
bpatel@766 183 *
bpatel@766 184 * @param mw the writer for the member being documented
bpatel@766 185 * @param cd the class being documented
bpatel@766 186 * @param member the member being documented
bpatel@766 187 * @param isFirst true if its the first link being documented
bpatel@766 188 * @param linksTree the content tree to which the summary will be added
bpatel@766 189 */
bpatel@766 190 public void addInheritedMemberSummary(AbstractMemberWriter mw, ClassDoc cd,
bpatel@766 191 ProgramElementDoc member, boolean isFirst, Content linksTree) {
duke@1 192 if (! isFirst) {
bpatel@766 193 linksTree.addContent(", ");
duke@1 194 }
bpatel@766 195 mw.addInheritedSummaryLink(cd, member, linksTree);
duke@1 196 }
duke@1 197
bpatel@766 198 /**
bpatel@766 199 * Get the document content header tree
bpatel@766 200 *
bpatel@766 201 * @return a content tree the document content header
bpatel@766 202 */
bpatel@766 203 public Content getContentHeader() {
bpatel@766 204 HtmlTree div = new HtmlTree(HtmlTag.DIV);
bpatel@766 205 div.addStyle(HtmlStyle.contentContainer);
bpatel@766 206 return div;
bpatel@766 207 }
bpatel@766 208
bpatel@766 209 /**
bpatel@766 210 * Get the member header tree
bpatel@766 211 *
bpatel@766 212 * @return a content tree the member header
bpatel@766 213 */
bpatel@766 214 public Content getMemberTreeHeader() {
bpatel@766 215 HtmlTree li = new HtmlTree(HtmlTag.LI);
bpatel@766 216 li.addStyle(HtmlStyle.blockList);
bpatel@766 217 return li;
bpatel@766 218 }
bpatel@766 219
bpatel@766 220 /**
bpatel@766 221 * Get the member tree
bpatel@766 222 *
bpatel@766 223 * @param contentTree the tree used to generate the complete member tree
bpatel@766 224 * @return a content tree for the member
bpatel@766 225 */
bpatel@766 226 public Content getMemberTree(Content contentTree) {
bpatel@766 227 Content ul = HtmlTree.UL(HtmlStyle.blockList, contentTree);
bpatel@766 228 return ul;
bpatel@766 229 }
bpatel@766 230
bpatel@766 231 /**
bpatel@766 232 * Get the member summary tree
bpatel@766 233 *
bpatel@766 234 * @param contentTree the tree used to generate the member summary tree
bpatel@766 235 * @return a content tree for the member summary
bpatel@766 236 */
bpatel@766 237 public Content getMemberSummaryTree(Content contentTree) {
bpatel@766 238 return getMemberTree(HtmlStyle.summary, contentTree);
bpatel@766 239 }
bpatel@766 240
bpatel@766 241 /**
bpatel@766 242 * Get the member details tree
bpatel@766 243 *
bpatel@766 244 * @param contentTree the tree used to generate the member details tree
bpatel@766 245 * @return a content tree for the member details
bpatel@766 246 */
bpatel@766 247 public Content getMemberDetailsTree(Content contentTree) {
bpatel@766 248 return getMemberTree(HtmlStyle.details, contentTree);
bpatel@766 249 }
bpatel@766 250
bpatel@766 251 /**
bpatel@766 252 * Get the member tree
bpatel@766 253 *
bpatel@766 254 * @param style the style class to be added to the content tree
bpatel@766 255 * @param contentTree the tree used to generate the complete member tree
bpatel@766 256 */
bpatel@766 257 public Content getMemberTree(HtmlStyle style, Content contentTree) {
bpatel@766 258 Content div = HtmlTree.DIV(style, getMemberTree(contentTree));
bpatel@766 259 return div;
bpatel@766 260 }
duke@1 261 }

mercurial