Tue, 03 Dec 2013 14:21:45 -0800
8025416: doclet not substituting {@docRoot} in some cases
Reviewed-by: jjg
1 /*
2 * Copyright (c) 2003, 2013, 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 * Writes enum constant documentation in HTML format.
37 *
38 * <p><b>This is NOT part of any supported API.
39 * If you write code that depends on this, you do so at your own risk.
40 * This code and its internal interfaces are subject to change or
41 * deletion without notice.</b>
42 *
43 * @author Jamie Ho
44 * @author Bhavesh Patel (Modified)
45 */
46 public class EnumConstantWriterImpl extends AbstractMemberWriter
47 implements EnumConstantWriter, MemberSummaryWriter {
49 public EnumConstantWriterImpl(SubWriterHolderWriter writer,
50 ClassDoc classdoc) {
51 super(writer, classdoc);
52 }
54 public EnumConstantWriterImpl(SubWriterHolderWriter writer) {
55 super(writer);
56 }
58 /**
59 * {@inheritDoc}
60 */
61 public Content getMemberSummaryHeader(ClassDoc classDoc,
62 Content memberSummaryTree) {
63 memberSummaryTree.addContent(HtmlConstants.START_OF_ENUM_CONSTANT_SUMMARY);
64 Content memberTree = writer.getMemberTreeHeader();
65 writer.addSummaryHeader(this, classDoc, memberTree);
66 return memberTree;
67 }
69 /**
70 * {@inheritDoc}
71 */
72 public Content getEnumConstantsDetailsTreeHeader(ClassDoc classDoc,
73 Content memberDetailsTree) {
74 memberDetailsTree.addContent(HtmlConstants.START_OF_ENUM_CONSTANT_DETAILS);
75 Content enumConstantsDetailsTree = writer.getMemberTreeHeader();
76 enumConstantsDetailsTree.addContent(writer.getMarkerAnchor(
77 SectionName.ENUM_CONSTANT_DETAIL));
78 Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING,
79 writer.enumConstantsDetailsLabel);
80 enumConstantsDetailsTree.addContent(heading);
81 return enumConstantsDetailsTree;
82 }
84 /**
85 * {@inheritDoc}
86 */
87 public Content getEnumConstantsTreeHeader(FieldDoc enumConstant,
88 Content enumConstantsDetailsTree) {
89 enumConstantsDetailsTree.addContent(
90 writer.getMarkerAnchor(enumConstant.name()));
91 Content enumConstantsTree = writer.getMemberTreeHeader();
92 Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING);
93 heading.addContent(enumConstant.name());
94 enumConstantsTree.addContent(heading);
95 return enumConstantsTree;
96 }
98 /**
99 * {@inheritDoc}
100 */
101 public Content getSignature(FieldDoc enumConstant) {
102 Content pre = new HtmlTree(HtmlTag.PRE);
103 writer.addAnnotationInfo(enumConstant, pre);
104 addModifiers(enumConstant, pre);
105 Content enumConstantLink = writer.getLink(new LinkInfoImpl(
106 configuration, LinkInfoImpl.Kind.MEMBER, enumConstant.type()));
107 pre.addContent(enumConstantLink);
108 pre.addContent(" ");
109 if (configuration.linksource) {
110 Content enumConstantName = new StringContent(enumConstant.name());
111 writer.addSrcLink(enumConstant, enumConstantName, pre);
112 } else {
113 addName(enumConstant.name(), pre);
114 }
115 return pre;
116 }
118 /**
119 * {@inheritDoc}
120 */
121 public void addDeprecated(FieldDoc enumConstant, Content enumConstantsTree) {
122 addDeprecatedInfo(enumConstant, enumConstantsTree);
123 }
125 /**
126 * {@inheritDoc}
127 */
128 public void addComments(FieldDoc enumConstant, Content enumConstantsTree) {
129 addComment(enumConstant, enumConstantsTree);
130 }
132 /**
133 * {@inheritDoc}
134 */
135 public void addTags(FieldDoc enumConstant, Content enumConstantsTree) {
136 writer.addTagsInfo(enumConstant, enumConstantsTree);
137 }
139 /**
140 * {@inheritDoc}
141 */
142 public Content getEnumConstantsDetails(Content enumConstantsDetailsTree) {
143 return getMemberTree(enumConstantsDetailsTree);
144 }
146 /**
147 * {@inheritDoc}
148 */
149 public Content getEnumConstants(Content enumConstantsTree,
150 boolean isLastContent) {
151 return getMemberTree(enumConstantsTree, isLastContent);
152 }
154 /**
155 * {@inheritDoc}
156 */
157 public void close() throws IOException {
158 writer.close();
159 }
161 public int getMemberKind() {
162 return VisibleMemberMap.ENUM_CONSTANTS;
163 }
165 /**
166 * {@inheritDoc}
167 */
168 public void addSummaryLabel(Content memberTree) {
169 Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
170 writer.getResource("doclet.Enum_Constant_Summary"));
171 memberTree.addContent(label);
172 }
174 /**
175 * {@inheritDoc}
176 */
177 public String getTableSummary() {
178 return configuration.getText("doclet.Member_Table_Summary",
179 configuration.getText("doclet.Enum_Constant_Summary"),
180 configuration.getText("doclet.enum_constants"));
181 }
183 /**
184 * {@inheritDoc}
185 */
186 public Content getCaption() {
187 return configuration.getResource("doclet.Enum_Constants");
188 }
190 /**
191 * {@inheritDoc}
192 */
193 public String[] getSummaryTableHeader(ProgramElementDoc member) {
194 String[] header = new String[] {
195 configuration.getText("doclet.0_and_1",
196 configuration.getText("doclet.Enum_Constant"),
197 configuration.getText("doclet.Description"))
198 };
199 return header;
200 }
202 /**
203 * {@inheritDoc}
204 */
205 public void addSummaryAnchor(ClassDoc cd, Content memberTree) {
206 memberTree.addContent(writer.getMarkerAnchor(
207 SectionName.ENUM_CONSTANT_SUMMARY));
208 }
210 /**
211 * {@inheritDoc}
212 */
213 public void addInheritedSummaryAnchor(ClassDoc cd, Content inheritedTree) {
214 }
216 /**
217 * {@inheritDoc}
218 */
219 public void addInheritedSummaryLabel(ClassDoc cd, Content inheritedTree) {
220 }
222 /**
223 * {@inheritDoc}
224 */
225 protected void addSummaryLink(LinkInfoImpl.Kind context, ClassDoc cd, ProgramElementDoc member,
226 Content tdSummary) {
227 Content memberLink = HtmlTree.SPAN(HtmlStyle.memberNameLink,
228 writer.getDocLink(context, (MemberDoc) member, member.name(), false));
229 Content code = HtmlTree.CODE(memberLink);
230 tdSummary.addContent(code);
231 }
233 /**
234 * {@inheritDoc}
235 */
236 @Override
237 public void setSummaryColumnStyle(HtmlTree tdTree) {
238 tdTree.addStyle(HtmlStyle.colOne);
239 }
241 /**
242 * {@inheritDoc}
243 */
244 protected void addInheritedSummaryLink(ClassDoc cd,
245 ProgramElementDoc member, Content linksTree) {
246 }
248 /**
249 * {@inheritDoc}
250 */
251 protected void addSummaryType(ProgramElementDoc member, Content tdSummaryType) {
252 //Not applicable.
253 }
255 /**
256 * {@inheritDoc}
257 */
258 protected Content getDeprecatedLink(ProgramElementDoc member) {
259 return writer.getDocLink(LinkInfoImpl.Kind.MEMBER,
260 (MemberDoc) member, ((FieldDoc)member).qualifiedName());
261 }
263 /**
264 * {@inheritDoc}
265 */
266 protected Content getNavSummaryLink(ClassDoc cd, boolean link) {
267 if (link) {
268 if (cd == null) {
269 return writer.getHyperLink(SectionName.ENUM_CONSTANT_SUMMARY,
270 writer.getResource("doclet.navEnum"));
271 } else {
272 return writer.getHyperLink(
273 SectionName.ENUM_CONSTANTS_INHERITANCE,
274 configuration.getClassName(cd), writer.getResource("doclet.navEnum"));
275 }
276 } else {
277 return writer.getResource("doclet.navEnum");
278 }
279 }
281 /**
282 * {@inheritDoc}
283 */
284 protected void addNavDetailLink(boolean link, Content liNav) {
285 if (link) {
286 liNav.addContent(writer.getHyperLink(
287 SectionName.ENUM_CONSTANT_DETAIL,
288 writer.getResource("doclet.navEnum")));
289 } else {
290 liNav.addContent(writer.getResource("doclet.navEnum"));
291 }
292 }
293 }