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

changeset 0
959103a6100f
child 2525
2eb010b6cb22
equal deleted inserted replaced
-1:000000000000 0:959103a6100f
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 */
25
26 package com.sun.tools.doclets.formats.html;
27
28 import java.io.*;
29
30 import com.sun.javadoc.*;
31 import com.sun.tools.doclets.formats.html.markup.*;
32 import com.sun.tools.doclets.internal.toolkit.*;
33
34 /**
35 * Writes annotation type required member documentation in HTML format.
36 *
37 * <p><b>This is NOT part of any supported API.
38 * If you write code that depends on this, you do so at your own risk.
39 * This code and its internal interfaces are subject to change or
40 * deletion without notice.</b>
41 *
42 * @author Jamie Ho
43 * @author Bhavesh Patel (Modified)
44 */
45 public class AnnotationTypeRequiredMemberWriterImpl extends AbstractMemberWriter
46 implements AnnotationTypeRequiredMemberWriter, MemberSummaryWriter {
47
48 /**
49 * Construct a new AnnotationTypeRequiredMemberWriterImpl.
50 *
51 * @param writer the writer that will write the output.
52 * @param annotationType the AnnotationType that holds this member.
53 */
54 public AnnotationTypeRequiredMemberWriterImpl(SubWriterHolderWriter writer,
55 AnnotationTypeDoc annotationType) {
56 super(writer, annotationType);
57 }
58
59 /**
60 * {@inheritDoc}
61 */
62 public Content getMemberSummaryHeader(ClassDoc classDoc,
63 Content memberSummaryTree) {
64 memberSummaryTree.addContent(
65 HtmlConstants.START_OF_ANNOTATION_TYPE_REQUIRED_MEMBER_SUMMARY);
66 Content memberTree = writer.getMemberTreeHeader();
67 writer.addSummaryHeader(this, classDoc, memberTree);
68 return memberTree;
69 }
70
71 /**
72 * {@inheritDoc}
73 */
74 public Content getMemberTreeHeader() {
75 return writer.getMemberTreeHeader();
76 }
77
78 /**
79 * {@inheritDoc}
80 */
81 public void addAnnotationDetailsMarker(Content memberDetails) {
82 memberDetails.addContent(HtmlConstants.START_OF_ANNOTATION_TYPE_DETAILS);
83 }
84
85 /**
86 * {@inheritDoc}
87 */
88 public void addAnnotationDetailsTreeHeader(ClassDoc classDoc,
89 Content memberDetailsTree) {
90 if (!writer.printedAnnotationHeading) {
91 memberDetailsTree.addContent(writer.getMarkerAnchor(
92 SectionName.ANNOTATION_TYPE_ELEMENT_DETAIL));
93 Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING,
94 writer.annotationTypeDetailsLabel);
95 memberDetailsTree.addContent(heading);
96 writer.printedAnnotationHeading = true;
97 }
98 }
99
100 /**
101 * {@inheritDoc}
102 */
103 public Content getAnnotationDocTreeHeader(MemberDoc member,
104 Content annotationDetailsTree) {
105 annotationDetailsTree.addContent(
106 writer.getMarkerAnchor(member.name() +
107 ((ExecutableMemberDoc) member).signature()));
108 Content annotationDocTree = writer.getMemberTreeHeader();
109 Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING);
110 heading.addContent(member.name());
111 annotationDocTree.addContent(heading);
112 return annotationDocTree;
113 }
114
115 /**
116 * {@inheritDoc}
117 */
118 public Content getSignature(MemberDoc member) {
119 Content pre = new HtmlTree(HtmlTag.PRE);
120 writer.addAnnotationInfo(member, pre);
121 addModifiers(member, pre);
122 Content link =
123 writer.getLink(new LinkInfoImpl(configuration,
124 LinkInfoImpl.Kind.MEMBER, getType(member)));
125 pre.addContent(link);
126 pre.addContent(writer.getSpace());
127 if (configuration.linksource) {
128 Content memberName = new StringContent(member.name());
129 writer.addSrcLink(member, memberName, pre);
130 } else {
131 addName(member.name(), pre);
132 }
133 return pre;
134 }
135
136 /**
137 * {@inheritDoc}
138 */
139 public void addDeprecated(MemberDoc member, Content annotationDocTree) {
140 addDeprecatedInfo(member, annotationDocTree);
141 }
142
143 /**
144 * {@inheritDoc}
145 */
146 public void addComments(MemberDoc member, Content annotationDocTree) {
147 addComment(member, annotationDocTree);
148 }
149
150 /**
151 * {@inheritDoc}
152 */
153 public void addTags(MemberDoc member, Content annotationDocTree) {
154 writer.addTagsInfo(member, annotationDocTree);
155 }
156
157 /**
158 * {@inheritDoc}
159 */
160 public Content getAnnotationDetails(Content annotationDetailsTree) {
161 return getMemberTree(annotationDetailsTree);
162 }
163
164 /**
165 * {@inheritDoc}
166 */
167 public Content getAnnotationDoc(Content annotationDocTree,
168 boolean isLastContent) {
169 return getMemberTree(annotationDocTree, isLastContent);
170 }
171
172 /**
173 * Close the writer.
174 */
175 public void close() throws IOException {
176 writer.close();
177 }
178
179 /**
180 * {@inheritDoc}
181 */
182 public void addSummaryLabel(Content memberTree) {
183 Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
184 writer.getResource("doclet.Annotation_Type_Required_Member_Summary"));
185 memberTree.addContent(label);
186 }
187
188 /**
189 * {@inheritDoc}
190 */
191 public String getTableSummary() {
192 return configuration.getText("doclet.Member_Table_Summary",
193 configuration.getText("doclet.Annotation_Type_Required_Member_Summary"),
194 configuration.getText("doclet.annotation_type_required_members"));
195 }
196
197 /**
198 * {@inheritDoc}
199 */
200 public Content getCaption() {
201 return configuration.getResource("doclet.Annotation_Type_Required_Members");
202 }
203
204 /**
205 * {@inheritDoc}
206 */
207 public String[] getSummaryTableHeader(ProgramElementDoc member) {
208 String[] header = new String[] {
209 writer.getModifierTypeHeader(),
210 configuration.getText("doclet.0_and_1",
211 configuration.getText("doclet.Annotation_Type_Required_Member"),
212 configuration.getText("doclet.Description"))
213 };
214 return header;
215 }
216
217 /**
218 * {@inheritDoc}
219 */
220 public void addSummaryAnchor(ClassDoc cd, Content memberTree) {
221 memberTree.addContent(writer.getMarkerAnchor(
222 SectionName.ANNOTATION_TYPE_REQUIRED_ELEMENT_SUMMARY));
223 }
224
225 /**
226 * {@inheritDoc}
227 */
228 public void addInheritedSummaryAnchor(ClassDoc cd, Content inheritedTree) {
229 }
230
231 /**
232 * {@inheritDoc}
233 */
234 public void addInheritedSummaryLabel(ClassDoc cd, Content inheritedTree) {
235 }
236
237 /**
238 * {@inheritDoc}
239 */
240 protected void addSummaryLink(LinkInfoImpl.Kind context, ClassDoc cd, ProgramElementDoc member,
241 Content tdSummary) {
242 Content memberLink = HtmlTree.SPAN(HtmlStyle.memberNameLink,
243 writer.getDocLink(context, (MemberDoc) member, member.name(), false));
244 Content code = HtmlTree.CODE(memberLink);
245 tdSummary.addContent(code);
246 }
247
248 /**
249 * {@inheritDoc}
250 */
251 protected void addInheritedSummaryLink(ClassDoc cd,
252 ProgramElementDoc member, Content linksTree) {
253 //Not applicable.
254 }
255
256 /**
257 * {@inheritDoc}
258 */
259 protected void addSummaryType(ProgramElementDoc member, Content tdSummaryType) {
260 MemberDoc m = (MemberDoc)member;
261 addModifierAndType(m, getType(m), tdSummaryType);
262 }
263
264 /**
265 * {@inheritDoc}
266 */
267 protected Content getDeprecatedLink(ProgramElementDoc member) {
268 return writer.getDocLink(LinkInfoImpl.Kind.MEMBER,
269 (MemberDoc) member, ((MemberDoc)member).qualifiedName());
270 }
271
272 /**
273 * {@inheritDoc}
274 */
275 protected Content getNavSummaryLink(ClassDoc cd, boolean link) {
276 if (link) {
277 return writer.getHyperLink(
278 SectionName.ANNOTATION_TYPE_REQUIRED_ELEMENT_SUMMARY,
279 writer.getResource("doclet.navAnnotationTypeRequiredMember"));
280 } else {
281 return writer.getResource("doclet.navAnnotationTypeRequiredMember");
282 }
283 }
284
285 /**
286 * {@inheritDoc}
287 */
288 protected void addNavDetailLink(boolean link, Content liNav) {
289 if (link) {
290 liNav.addContent(writer.getHyperLink(
291 SectionName.ANNOTATION_TYPE_ELEMENT_DETAIL,
292 writer.getResource("doclet.navAnnotationTypeMember")));
293 } else {
294 liNav.addContent(writer.getResource("doclet.navAnnotationTypeMember"));
295 }
296 }
297
298 private Type getType(MemberDoc member) {
299 if (member instanceof FieldDoc) {
300 return ((FieldDoc) member).type();
301 } else {
302 return ((MethodDoc) member).returnType();
303 }
304 }
305 }

mercurial