author | jjg |
Wed, 10 Oct 2012 16:48:21 -0700 | |
changeset 14260 | 727a84636f12 |
parent 14258 | 8d2148961366 |
child 14542 | 7062120649c2 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
14258 | 2 |
* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. |
10 | 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 |
|
5520 | 7 |
* published by the Free Software Foundation. Oracle designates this |
10 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5520 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
10 | 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 |
* |
|
5520 | 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. |
|
10 | 24 |
*/ |
25 |
||
26 |
package com.sun.tools.doclets.internal.toolkit.builders; |
|
27 |
||
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
28 |
import java.util.*; |
14258 | 29 |
|
30 |
import com.sun.javadoc.*; |
|
10 | 31 |
import com.sun.tools.doclets.internal.toolkit.*; |
14258 | 32 |
import com.sun.tools.doclets.internal.toolkit.util.*; |
10 | 33 |
|
34 |
/** |
|
35 |
* Builds documentation for required annotation type members. |
|
36 |
* |
|
14260
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
37 |
* <p><b>This is NOT part of any supported API. |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
38 |
* If you write code that depends on this, you do so at your own risk. |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
39 |
* This code and its internal interfaces are subject to change or |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
40 |
* deletion without notice.</b> |
10 | 41 |
* |
42 |
* @author Jamie Ho |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
43 |
* @author Bhavesh Patel (Modified) |
10 | 44 |
* @since 1.5 |
45 |
*/ |
|
46 |
public class AnnotationTypeRequiredMemberBuilder extends AbstractMemberBuilder { |
|
47 |
||
48 |
/** |
|
49 |
* The annotation type whose members are being documented. |
|
50 |
*/ |
|
51 |
protected ClassDoc classDoc; |
|
52 |
||
53 |
/** |
|
54 |
* The visible members for the given class. |
|
55 |
*/ |
|
56 |
protected VisibleMemberMap visibleMemberMap; |
|
57 |
||
58 |
/** |
|
59 |
* The writer to output the member documentation. |
|
60 |
*/ |
|
61 |
protected AnnotationTypeRequiredMemberWriter writer; |
|
62 |
||
63 |
/** |
|
64 |
* The list of members being documented. |
|
65 |
*/ |
|
868 | 66 |
protected List<ProgramElementDoc> members; |
10 | 67 |
|
68 |
/** |
|
69 |
* The index of the current member that is being documented at this point |
|
70 |
* in time. |
|
71 |
*/ |
|
72 |
protected int currentMemberIndex; |
|
73 |
||
74 |
/** |
|
75 |
* Construct a new AnnotationTypeRequiredMemberBuilder. |
|
76 |
* |
|
77 |
* @param configuration the current configuration of the |
|
78 |
* doclet. |
|
79 |
*/ |
|
80 |
protected AnnotationTypeRequiredMemberBuilder(Configuration configuration) { |
|
81 |
super(configuration); |
|
82 |
} |
|
83 |
||
84 |
||
85 |
/** |
|
86 |
* Construct a new AnnotationTypeMemberBuilder. |
|
87 |
* |
|
88 |
* @param configuration the current configuration of the doclet. |
|
89 |
* @param classDoc the class whoses members are being documented. |
|
90 |
* @param writer the doclet specific writer. |
|
91 |
*/ |
|
92 |
public static AnnotationTypeRequiredMemberBuilder getInstance( |
|
93 |
Configuration configuration, ClassDoc classDoc, |
|
94 |
AnnotationTypeRequiredMemberWriter writer) { |
|
95 |
AnnotationTypeRequiredMemberBuilder builder = |
|
96 |
new AnnotationTypeRequiredMemberBuilder(configuration); |
|
97 |
builder.classDoc = classDoc; |
|
98 |
builder.writer = writer; |
|
99 |
builder.visibleMemberMap = new VisibleMemberMap(classDoc, |
|
100 |
VisibleMemberMap.ANNOTATION_TYPE_MEMBER_REQUIRED, configuration.nodeprecated); |
|
868 | 101 |
builder.members = new ArrayList<ProgramElementDoc>( |
10 | 102 |
builder.visibleMemberMap.getMembersFor(classDoc)); |
103 |
if (configuration.getMemberComparator() != null) { |
|
104 |
Collections.sort(builder.members, |
|
105 |
configuration.getMemberComparator()); |
|
106 |
} |
|
107 |
return builder; |
|
108 |
} |
|
109 |
||
110 |
/** |
|
111 |
* {@inheritDoc} |
|
112 |
*/ |
|
113 |
public String getName() { |
|
114 |
return "AnnotationTypeRequiredMemberDetails"; |
|
115 |
} |
|
116 |
||
117 |
/** |
|
118 |
* Returns a list of members that will be documented for the given class. |
|
119 |
* This information can be used for doclet specific documentation |
|
120 |
* generation. |
|
121 |
* |
|
122 |
* @param classDoc the {@link ClassDoc} we want to check. |
|
123 |
* @return a list of members that will be documented. |
|
124 |
*/ |
|
1789
7ac8c0815000
6765045: Remove rawtypes warnings from langtools
mcimadamore
parents:
1264
diff
changeset
|
125 |
public List<ProgramElementDoc> members(ClassDoc classDoc) { |
10 | 126 |
return visibleMemberMap.getMembersFor(classDoc); |
127 |
} |
|
128 |
||
129 |
/** |
|
130 |
* Returns the visible member map for the members of this class. |
|
131 |
* |
|
132 |
* @return the visible member map for the members of this class. |
|
133 |
*/ |
|
134 |
public VisibleMemberMap getVisibleMemberMap() { |
|
135 |
return visibleMemberMap; |
|
136 |
} |
|
137 |
||
138 |
/** |
|
139 |
* summaryOrder.size() |
|
140 |
*/ |
|
141 |
public boolean hasMembersToDocument() { |
|
142 |
return members.size() > 0; |
|
143 |
} |
|
144 |
||
145 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
146 |
* Build the annotation type required member documentation. |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
147 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
148 |
* @param node the XML element that specifies which components to document |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
149 |
* @param memberDetailsTree the content tree to which the documentation will be added |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
150 |
*/ |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
151 |
public void buildAnnotationTypeRequiredMember(XMLNode node, Content memberDetailsTree) { |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
152 |
buildAnnotationTypeMember(node, memberDetailsTree); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
153 |
} |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
154 |
|
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
155 |
/** |
10 | 156 |
* Build the member documentation. |
157 |
* |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
158 |
* @param node the XML element that specifies which components to document |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
159 |
* @param memberDetailsTree the content tree to which the documentation will be added |
10 | 160 |
*/ |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
161 |
public void buildAnnotationTypeMember(XMLNode node, Content memberDetailsTree) { |
10 | 162 |
if (writer == null) { |
163 |
return; |
|
164 |
} |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
165 |
int size = members.size(); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
166 |
if (size > 0) { |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
167 |
writer.addAnnotationDetailsTreeHeader( |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
168 |
classDoc, memberDetailsTree); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
169 |
for (currentMemberIndex = 0; currentMemberIndex < size; |
10 | 170 |
currentMemberIndex++) { |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
171 |
Content annotationDocTree = writer.getAnnotationDocTreeHeader( |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
172 |
(MemberDoc) members.get(currentMemberIndex), |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
173 |
memberDetailsTree); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
174 |
buildChildren(node, annotationDocTree); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
175 |
memberDetailsTree.addContent(writer.getAnnotationDoc( |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
176 |
annotationDocTree, (currentMemberIndex == size - 1))); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
177 |
} |
10 | 178 |
} |
179 |
} |
|
180 |
||
181 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
182 |
* Build the signature. |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
183 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
184 |
* @param node the XML element that specifies which components to document |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
185 |
* @param annotationDocTree the content tree to which the documentation will be added |
10 | 186 |
*/ |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
187 |
public void buildSignature(XMLNode node, Content annotationDocTree) { |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
188 |
annotationDocTree.addContent( |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
189 |
writer.getSignature((MemberDoc) members.get(currentMemberIndex))); |
10 | 190 |
} |
191 |
||
192 |
/** |
|
193 |
* Build the deprecation information. |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
194 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
195 |
* @param node the XML element that specifies which components to document |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
196 |
* @param annotationDocTree the content tree to which the documentation will be added |
10 | 197 |
*/ |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
198 |
public void buildDeprecationInfo(XMLNode node, Content annotationDocTree) { |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
199 |
writer.addDeprecated((MemberDoc) members.get(currentMemberIndex), |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
200 |
annotationDocTree); |
10 | 201 |
} |
202 |
||
203 |
/** |
|
204 |
* Build the comments for the member. Do nothing if |
|
205 |
* {@link Configuration#nocomment} is set to true. |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
206 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
207 |
* @param node the XML element that specifies which components to document |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
208 |
* @param annotationDocTree the content tree to which the documentation will be added |
10 | 209 |
*/ |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
210 |
public void buildMemberComments(XMLNode node, Content annotationDocTree) { |
10 | 211 |
if(! configuration.nocomment){ |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
212 |
writer.addComments((MemberDoc) members.get(currentMemberIndex), |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
213 |
annotationDocTree); |
10 | 214 |
} |
215 |
} |
|
216 |
||
217 |
/** |
|
218 |
* Build the tag information. |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
219 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
220 |
* @param node the XML element that specifies which components to document |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
221 |
* @param annotationDocTree the content tree to which the documentation will be added |
10 | 222 |
*/ |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
223 |
public void buildTagInfo(XMLNode node, Content annotationDocTree) { |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
224 |
writer.addTags((MemberDoc) members.get(currentMemberIndex), |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
225 |
annotationDocTree); |
10 | 226 |
} |
227 |
||
228 |
/** |
|
229 |
* Return the annotation type required member writer for this builder. |
|
230 |
* |
|
231 |
* @return the annotation type required member constant writer for this |
|
232 |
* builder. |
|
233 |
*/ |
|
234 |
public AnnotationTypeRequiredMemberWriter getWriter() { |
|
235 |
return writer; |
|
236 |
} |
|
237 |
} |