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