author | jjg |
Fri, 18 Jun 2010 21:13:56 -0700 | |
changeset 5855 | 00d9c252e60c |
parent 5520 | 86e4b9a9da40 |
child 7614 | cfadc977ca75 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
5520 | 2 |
* Copyright (c) 2003, 2008, 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 |
||
28 |
||
29 |
import com.sun.tools.doclets.internal.toolkit.util.*; |
|
30 |
import com.sun.tools.doclets.internal.toolkit.*; |
|
31 |
import com.sun.javadoc.*; |
|
32 |
import java.util.*; |
|
33 |
||
34 |
/** |
|
35 |
* Builds documentation for required annotation type members. |
|
36 |
* |
|
37 |
* This code is not part of an API. |
|
38 |
* It is implementation that is subject to change. |
|
39 |
* Do not use it as an API |
|
40 |
* |
|
41 |
* @author Jamie Ho |
|
42 |
* @since 1.5 |
|
43 |
*/ |
|
44 |
public class AnnotationTypeRequiredMemberBuilder extends AbstractMemberBuilder { |
|
45 |
||
46 |
/** |
|
47 |
* The annotation type whose members are being documented. |
|
48 |
*/ |
|
49 |
protected ClassDoc classDoc; |
|
50 |
||
51 |
/** |
|
52 |
* The visible members for the given class. |
|
53 |
*/ |
|
54 |
protected VisibleMemberMap visibleMemberMap; |
|
55 |
||
56 |
/** |
|
57 |
* The writer to output the member documentation. |
|
58 |
*/ |
|
59 |
protected AnnotationTypeRequiredMemberWriter writer; |
|
60 |
||
61 |
/** |
|
62 |
* The list of members being documented. |
|
63 |
*/ |
|
868 | 64 |
protected List<ProgramElementDoc> members; |
10 | 65 |
|
66 |
/** |
|
67 |
* The index of the current member that is being documented at this point |
|
68 |
* in time. |
|
69 |
*/ |
|
70 |
protected int currentMemberIndex; |
|
71 |
||
72 |
/** |
|
73 |
* Construct a new AnnotationTypeRequiredMemberBuilder. |
|
74 |
* |
|
75 |
* @param configuration the current configuration of the |
|
76 |
* doclet. |
|
77 |
*/ |
|
78 |
protected AnnotationTypeRequiredMemberBuilder(Configuration configuration) { |
|
79 |
super(configuration); |
|
80 |
} |
|
81 |
||
82 |
||
83 |
/** |
|
84 |
* Construct a new AnnotationTypeMemberBuilder. |
|
85 |
* |
|
86 |
* @param configuration the current configuration of the doclet. |
|
87 |
* @param classDoc the class whoses members are being documented. |
|
88 |
* @param writer the doclet specific writer. |
|
89 |
*/ |
|
90 |
public static AnnotationTypeRequiredMemberBuilder getInstance( |
|
91 |
Configuration configuration, ClassDoc classDoc, |
|
92 |
AnnotationTypeRequiredMemberWriter writer) { |
|
93 |
AnnotationTypeRequiredMemberBuilder builder = |
|
94 |
new AnnotationTypeRequiredMemberBuilder(configuration); |
|
95 |
builder.classDoc = classDoc; |
|
96 |
builder.writer = writer; |
|
97 |
builder.visibleMemberMap = new VisibleMemberMap(classDoc, |
|
98 |
VisibleMemberMap.ANNOTATION_TYPE_MEMBER_REQUIRED, configuration.nodeprecated); |
|
868 | 99 |
builder.members = new ArrayList<ProgramElementDoc>( |
10 | 100 |
builder.visibleMemberMap.getMembersFor(classDoc)); |
101 |
if (configuration.getMemberComparator() != null) { |
|
102 |
Collections.sort(builder.members, |
|
103 |
configuration.getMemberComparator()); |
|
104 |
} |
|
105 |
return builder; |
|
106 |
} |
|
107 |
||
108 |
/** |
|
109 |
* {@inheritDoc} |
|
110 |
*/ |
|
111 |
public String getName() { |
|
112 |
return "AnnotationTypeRequiredMemberDetails"; |
|
113 |
} |
|
114 |
||
115 |
/** |
|
116 |
* Returns a list of members that will be documented for the given class. |
|
117 |
* This information can be used for doclet specific documentation |
|
118 |
* generation. |
|
119 |
* |
|
120 |
* @param classDoc the {@link ClassDoc} we want to check. |
|
121 |
* @return a list of members that will be documented. |
|
122 |
*/ |
|
1789
7ac8c0815000
6765045: Remove rawtypes warnings from langtools
mcimadamore
parents:
1264
diff
changeset
|
123 |
public List<ProgramElementDoc> members(ClassDoc classDoc) { |
10 | 124 |
return visibleMemberMap.getMembersFor(classDoc); |
125 |
} |
|
126 |
||
127 |
/** |
|
128 |
* Returns the visible member map for the members of this class. |
|
129 |
* |
|
130 |
* @return the visible member map for the members of this class. |
|
131 |
*/ |
|
132 |
public VisibleMemberMap getVisibleMemberMap() { |
|
133 |
return visibleMemberMap; |
|
134 |
} |
|
135 |
||
136 |
/** |
|
137 |
* summaryOrder.size() |
|
138 |
*/ |
|
139 |
public boolean hasMembersToDocument() { |
|
140 |
return members.size() > 0; |
|
141 |
} |
|
142 |
||
143 |
/** |
|
144 |
* Build the member documentation. |
|
145 |
* |
|
146 |
* @param elements the XML elements that specify how to construct this |
|
147 |
* documentation. |
|
148 |
*/ |
|
5855 | 149 |
public void buildAnnotationTypeRequiredMember(XMLNode node) { |
10 | 150 |
if (writer == null) { |
151 |
return; |
|
152 |
} |
|
153 |
for (currentMemberIndex = 0; currentMemberIndex < members.size(); |
|
154 |
currentMemberIndex++) { |
|
5855 | 155 |
buildChildren(node); |
10 | 156 |
} |
157 |
} |
|
158 |
||
159 |
/** |
|
160 |
* Build the overall header. |
|
161 |
*/ |
|
5855 | 162 |
public void buildHeader(XMLNode node) { |
10 | 163 |
writer.writeHeader(classDoc, |
164 |
configuration.getText("doclet.Annotation_Type_Member_Detail")); |
|
165 |
} |
|
166 |
||
167 |
/** |
|
168 |
* Build the header for the individual members. |
|
169 |
*/ |
|
5855 | 170 |
public void buildMemberHeader(XMLNode node) { |
10 | 171 |
writer.writeMemberHeader((MemberDoc) members.get( |
172 |
currentMemberIndex), |
|
173 |
currentMemberIndex == 0); |
|
174 |
} |
|
175 |
||
176 |
/** |
|
177 |
* Build the signature. |
|
178 |
*/ |
|
5855 | 179 |
public void buildSignature(XMLNode node) { |
10 | 180 |
writer.writeSignature((MemberDoc) members.get(currentMemberIndex)); |
181 |
} |
|
182 |
||
183 |
/** |
|
184 |
* Build the deprecation information. |
|
185 |
*/ |
|
5855 | 186 |
public void buildDeprecationInfo(XMLNode node) { |
10 | 187 |
writer.writeDeprecated((MemberDoc) members.get(currentMemberIndex)); |
188 |
} |
|
189 |
||
190 |
/** |
|
191 |
* Build the comments for the member. Do nothing if |
|
192 |
* {@link Configuration#nocomment} is set to true. |
|
193 |
*/ |
|
5855 | 194 |
public void buildMemberComments(XMLNode node) { |
10 | 195 |
if(! configuration.nocomment){ |
196 |
writer.writeComments((MemberDoc) members.get(currentMemberIndex)); |
|
197 |
} |
|
198 |
} |
|
199 |
||
200 |
/** |
|
201 |
* Build the tag information. |
|
202 |
*/ |
|
5855 | 203 |
public void buildTagInfo(XMLNode node) { |
10 | 204 |
writer.writeTags((MemberDoc) members.get(currentMemberIndex)); |
205 |
} |
|
206 |
||
207 |
/** |
|
208 |
* Build the footer for the individual member. |
|
209 |
*/ |
|
5855 | 210 |
public void buildMemberFooter(XMLNode node) { |
10 | 211 |
writer.writeMemberFooter(); |
212 |
} |
|
213 |
||
214 |
/** |
|
215 |
* Build the overall footer. |
|
216 |
*/ |
|
5855 | 217 |
public void buildFooter(XMLNode node) { |
10 | 218 |
writer.writeFooter(classDoc); |
219 |
} |
|
220 |
||
221 |
/** |
|
222 |
* Return the annotation type required member writer for this builder. |
|
223 |
* |
|
224 |
* @return the annotation type required member constant writer for this |
|
225 |
* builder. |
|
226 |
*/ |
|
227 |
public AnnotationTypeRequiredMemberWriter getWriter() { |
|
228 |
return writer; |
|
229 |
} |
|
230 |
} |