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

Tue, 09 Oct 2012 19:10:00 -0700

author
jjg
date
Tue, 09 Oct 2012 19:10:00 -0700
changeset 1357
c75be5bc5283
parent 798
4868a36f6fd8
child 1359
25e14ad23cef
permissions
-rw-r--r--

8000663: clean up langtools imports
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 *
duke@1 43 * @see AbstractMemberWriter
duke@1 44 * @see ClassWriterImpl
duke@1 45 *
duke@1 46 * @author Robert Field
duke@1 47 * @author Atul M Dambalkar
bpatel@243 48 * @author Bhavesh Patel (Modified)
duke@1 49 */
duke@1 50 public abstract class SubWriterHolderWriter extends HtmlDocletWriter {
duke@1 51
duke@1 52 public SubWriterHolderWriter(ConfigurationImpl configuration,
duke@1 53 String filename) throws IOException {
duke@1 54 super(configuration, filename);
duke@1 55 }
duke@1 56
duke@1 57
duke@1 58 public SubWriterHolderWriter(ConfigurationImpl configuration,
duke@1 59 String path, String filename, String relpath)
duke@1 60 throws IOException {
duke@1 61 super(configuration, path, filename, relpath);
duke@1 62 }
duke@1 63
duke@1 64 public void printTypeSummaryHeader() {
duke@1 65 tdIndex();
duke@1 66 font("-1");
duke@1 67 code();
duke@1 68 }
duke@1 69
duke@1 70 public void printTypeSummaryFooter() {
duke@1 71 codeEnd();
duke@1 72 fontEnd();
duke@1 73 tdEnd();
duke@1 74 }
duke@1 75
bpatel@766 76 /**
bpatel@766 77 * Add the summary header.
bpatel@766 78 *
bpatel@766 79 * @param mw the writer for the member being documented
bpatel@766 80 * @param cd the classdoc to be documented
bpatel@766 81 * @param memberTree the content tree to which the summary header will be added
bpatel@766 82 */
bpatel@766 83 public void addSummaryHeader(AbstractMemberWriter mw, ClassDoc cd,
bpatel@766 84 Content memberTree) {
bpatel@766 85 mw.addSummaryAnchor(cd, memberTree);
bpatel@766 86 mw.addSummaryLabel(memberTree);
bpatel@766 87 }
bpatel@766 88
bpatel@766 89 /**
bpatel@766 90 * Get the summary table.
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 * @return the content tree for the summary table
bpatel@766 95 */
bpatel@766 96 public Content getSummaryTableTree(AbstractMemberWriter mw, ClassDoc cd) {
bpatel@766 97 Content table = HtmlTree.TABLE(HtmlStyle.overviewSummary, 0, 3, 0,
bpatel@766 98 mw.getTableSummary(), getTableCaption(mw.getCaption()));
bpatel@766 99 table.addContent(getSummaryTableHeader(mw.getSummaryTableHeader(cd), "col"));
bpatel@766 100 return table;
duke@1 101 }
duke@1 102
duke@1 103 public void printTableHeadingBackground(String str) {
duke@1 104 tableIndexDetail();
duke@1 105 tableHeaderStart("#CCCCFF", 1);
bpatel@182 106 strong(str);
duke@1 107 tableHeaderEnd();
duke@1 108 tableEnd();
duke@1 109 }
duke@1 110
bpatel@766 111 /**
bpatel@766 112 * Add the inherited summary header.
bpatel@766 113 *
bpatel@766 114 * @param mw the writer for the member being documented
bpatel@766 115 * @param cd the classdoc to be documented
bpatel@766 116 * @param inheritedTree the content tree to which the inherited summary header will be added
bpatel@766 117 */
bpatel@766 118 public void addInheritedSummaryHeader(AbstractMemberWriter mw, ClassDoc cd,
bpatel@766 119 Content inheritedTree) {
bpatel@766 120 mw.addInheritedSummaryAnchor(cd, inheritedTree);
bpatel@766 121 mw.addInheritedSummaryLabel(cd, inheritedTree);
duke@1 122 }
duke@1 123
duke@1 124 public void printSummaryFooter(AbstractMemberWriter mw, ClassDoc cd) {
duke@1 125 tableEnd();
duke@1 126 space();
duke@1 127 }
duke@1 128
duke@1 129 public void printInheritedSummaryFooter(AbstractMemberWriter mw, ClassDoc cd) {
duke@1 130 codeEnd();
duke@1 131 summaryRowEnd();
duke@1 132 trEnd();
duke@1 133 tableEnd();
duke@1 134 space();
duke@1 135 }
duke@1 136
bpatel@766 137 /**
bpatel@766 138 * Add the index comment.
bpatel@766 139 *
bpatel@766 140 * @param member the member being documented
bpatel@766 141 * @param contentTree the content tree to which the comment will be added
bpatel@766 142 */
bpatel@766 143 protected void addIndexComment(Doc member, Content contentTree) {
bpatel@766 144 addIndexComment(member, member.firstSentenceTags(), contentTree);
duke@1 145 }
duke@1 146
duke@1 147 protected void printIndexComment(Doc member, Tag[] firstSentenceTags) {
duke@1 148 Tag[] deprs = member.tags("deprecated");
duke@1 149 if (Util.isDeprecated((ProgramElementDoc) member)) {
bpatel@182 150 strongText("doclet.Deprecated");
duke@1 151 space();
duke@1 152 if (deprs.length > 0) {
duke@1 153 printInlineDeprecatedComment(member, deprs[0]);
duke@1 154 }
duke@1 155 return;
duke@1 156 } else {
duke@1 157 ClassDoc cd = ((ProgramElementDoc)member).containingClass();
duke@1 158 if (cd != null && Util.isDeprecated(cd)) {
bpatel@182 159 strongText("doclet.Deprecated"); space();
duke@1 160 }
duke@1 161 }
duke@1 162 printSummaryComment(member, firstSentenceTags);
duke@1 163 }
duke@1 164
bpatel@766 165 /**
bpatel@766 166 * Add the index comment.
bpatel@766 167 *
bpatel@766 168 * @param member the member being documented
bpatel@766 169 * @param firstSentenceTags the first sentence tags for the member to be documented
bpatel@766 170 * @param tdSummary the content tree to which the comment will be added
bpatel@766 171 */
bpatel@766 172 protected void addIndexComment(Doc member, Tag[] firstSentenceTags,
bpatel@766 173 Content tdSummary) {
bpatel@766 174 Tag[] deprs = member.tags("deprecated");
bpatel@766 175 Content div;
bpatel@766 176 if (Util.isDeprecated((ProgramElementDoc) member)) {
bpatel@766 177 Content strong = HtmlTree.STRONG(deprecatedPhrase);
bpatel@766 178 div = HtmlTree.DIV(HtmlStyle.block, strong);
bpatel@766 179 div.addContent(getSpace());
bpatel@766 180 if (deprs.length > 0) {
bpatel@766 181 addInlineDeprecatedComment(member, deprs[0], div);
bpatel@766 182 }
bpatel@766 183 tdSummary.addContent(div);
bpatel@766 184 return;
bpatel@766 185 } else {
bpatel@766 186 ClassDoc cd = ((ProgramElementDoc)member).containingClass();
bpatel@766 187 if (cd != null && Util.isDeprecated(cd)) {
bpatel@766 188 Content strong = HtmlTree.STRONG(deprecatedPhrase);
bpatel@766 189 div = HtmlTree.DIV(HtmlStyle.block, strong);
bpatel@766 190 div.addContent(getSpace());
bpatel@766 191 tdSummary.addContent(div);
bpatel@766 192 }
bpatel@766 193 }
bpatel@766 194 addSummaryComment(member, firstSentenceTags, tdSummary);
duke@1 195 }
duke@1 196
bpatel@766 197 /**
bpatel@766 198 * Add the summary type for the member.
bpatel@766 199 *
bpatel@766 200 * @param mw the writer for the member being documented
bpatel@766 201 * @param member the member to be documented
bpatel@766 202 * @param tdSummaryType the content tree to which the type will be added
bpatel@766 203 */
bpatel@766 204 public void addSummaryType(AbstractMemberWriter mw, ProgramElementDoc member,
bpatel@766 205 Content tdSummaryType) {
bpatel@766 206 mw.addSummaryType(member, tdSummaryType);
bpatel@766 207 }
bpatel@766 208
bpatel@766 209 /**
bpatel@766 210 * Add the summary link for the member.
bpatel@766 211 *
bpatel@766 212 * @param mw the writer for the member being documented
bpatel@766 213 * @param member the member to be documented
bpatel@766 214 * @param contentTree the content tree to which the link will be added
bpatel@766 215 */
bpatel@766 216 public void addSummaryLinkComment(AbstractMemberWriter mw,
bpatel@766 217 ProgramElementDoc member, Content contentTree) {
bpatel@766 218 addSummaryLinkComment(mw, member, member.firstSentenceTags(), contentTree);
duke@1 219 }
duke@1 220
duke@1 221 public void printSummaryLinkComment(AbstractMemberWriter mw,
duke@1 222 ProgramElementDoc member,
duke@1 223 Tag[] firstSentenceTags) {
duke@1 224 codeEnd();
duke@1 225 println();
duke@1 226 br();
duke@1 227 printNbsps();
duke@1 228 printIndexComment(member, firstSentenceTags);
duke@1 229 summaryRowEnd();
duke@1 230 trEnd();
duke@1 231 }
duke@1 232
bpatel@766 233 /**
bpatel@766 234 * Add the summary link comment.
bpatel@766 235 *
bpatel@766 236 * @param mw the writer for the member being documented
bpatel@766 237 * @param member the member being documented
bpatel@766 238 * @param firstSentenceTags the first sentence tags for the member to be documented
bpatel@766 239 * @param tdSummary the content tree to which the comment will be added
bpatel@766 240 */
bpatel@766 241 public void addSummaryLinkComment(AbstractMemberWriter mw,
bpatel@766 242 ProgramElementDoc member, Tag[] firstSentenceTags, Content tdSummary) {
bpatel@766 243 addIndexComment(member, firstSentenceTags, tdSummary);
bpatel@766 244 }
bpatel@766 245
bpatel@766 246 /**
bpatel@766 247 * Add the inherited member summary.
bpatel@766 248 *
bpatel@766 249 * @param mw the writer for the member being documented
bpatel@766 250 * @param cd the class being documented
bpatel@766 251 * @param member the member being documented
bpatel@766 252 * @param isFirst true if its the first link being documented
bpatel@766 253 * @param linksTree the content tree to which the summary will be added
bpatel@766 254 */
bpatel@766 255 public void addInheritedMemberSummary(AbstractMemberWriter mw, ClassDoc cd,
bpatel@766 256 ProgramElementDoc member, boolean isFirst, Content linksTree) {
duke@1 257 if (! isFirst) {
bpatel@766 258 linksTree.addContent(", ");
duke@1 259 }
bpatel@766 260 mw.addInheritedSummaryLink(cd, member, linksTree);
duke@1 261 }
duke@1 262
duke@1 263 public void printMemberHeader() {
duke@1 264 hr();
duke@1 265 }
duke@1 266
duke@1 267 public void printMemberFooter() {
duke@1 268 }
duke@1 269
bpatel@766 270 /**
bpatel@766 271 * Get the document content header tree
bpatel@766 272 *
bpatel@766 273 * @return a content tree the document content header
bpatel@766 274 */
bpatel@766 275 public Content getContentHeader() {
bpatel@766 276 HtmlTree div = new HtmlTree(HtmlTag.DIV);
bpatel@766 277 div.addStyle(HtmlStyle.contentContainer);
bpatel@766 278 return div;
bpatel@766 279 }
bpatel@766 280
bpatel@766 281 /**
bpatel@766 282 * Get the member header tree
bpatel@766 283 *
bpatel@766 284 * @return a content tree the member header
bpatel@766 285 */
bpatel@766 286 public Content getMemberTreeHeader() {
bpatel@766 287 HtmlTree li = new HtmlTree(HtmlTag.LI);
bpatel@766 288 li.addStyle(HtmlStyle.blockList);
bpatel@766 289 return li;
bpatel@766 290 }
bpatel@766 291
bpatel@766 292 /**
bpatel@766 293 * Get the member tree
bpatel@766 294 *
bpatel@766 295 * @param contentTree the tree used to generate the complete member tree
bpatel@766 296 * @return a content tree for the member
bpatel@766 297 */
bpatel@766 298 public Content getMemberTree(Content contentTree) {
bpatel@766 299 Content ul = HtmlTree.UL(HtmlStyle.blockList, contentTree);
bpatel@766 300 return ul;
bpatel@766 301 }
bpatel@766 302
bpatel@766 303 /**
bpatel@766 304 * Get the member summary tree
bpatel@766 305 *
bpatel@766 306 * @param contentTree the tree used to generate the member summary tree
bpatel@766 307 * @return a content tree for the member summary
bpatel@766 308 */
bpatel@766 309 public Content getMemberSummaryTree(Content contentTree) {
bpatel@766 310 return getMemberTree(HtmlStyle.summary, contentTree);
bpatel@766 311 }
bpatel@766 312
bpatel@766 313 /**
bpatel@766 314 * Get the member details tree
bpatel@766 315 *
bpatel@766 316 * @param contentTree the tree used to generate the member details tree
bpatel@766 317 * @return a content tree for the member details
bpatel@766 318 */
bpatel@766 319 public Content getMemberDetailsTree(Content contentTree) {
bpatel@766 320 return getMemberTree(HtmlStyle.details, contentTree);
bpatel@766 321 }
bpatel@766 322
bpatel@766 323 /**
bpatel@766 324 * Get the member tree
bpatel@766 325 *
bpatel@766 326 * @param style the style class to be added to the content tree
bpatel@766 327 * @param contentTree the tree used to generate the complete member tree
bpatel@766 328 */
bpatel@766 329 public Content getMemberTree(HtmlStyle style, Content contentTree) {
bpatel@766 330 Content div = HtmlTree.DIV(style, getMemberTree(contentTree));
bpatel@766 331 return div;
bpatel@766 332 }
duke@1 333 }

mercurial