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 |
import com.sun.tools.doclets.internal.toolkit.util.*; |
|
29 |
import com.sun.tools.doclets.internal.toolkit.*; |
|
30 |
import com.sun.javadoc.*; |
|
31 |
import java.util.*; |
|
5855 | 32 |
|
10 | 33 |
/** |
34 |
* Builds documentation for a method. |
|
35 |
* |
|
36 |
* This code is not part of an API. |
|
37 |
* It is implementation that is subject to change. |
|
38 |
* Do not use it as an API |
|
39 |
* |
|
40 |
* @author Jamie Ho |
|
41 |
* @since 1.5 |
|
42 |
*/ |
|
43 |
public class MethodBuilder extends AbstractMemberBuilder { |
|
44 |
||
45 |
/** |
|
46 |
* The index of the current field that is being documented at this point |
|
47 |
* in time. |
|
48 |
*/ |
|
49 |
private int currentMethodIndex; |
|
50 |
||
51 |
/** |
|
52 |
* The class whose methods are being documented. |
|
53 |
*/ |
|
54 |
private ClassDoc classDoc; |
|
55 |
||
56 |
/** |
|
57 |
* The visible methods for the given class. |
|
58 |
*/ |
|
59 |
private VisibleMemberMap visibleMemberMap; |
|
60 |
||
61 |
/** |
|
62 |
* The writer to output the method documentation. |
|
63 |
*/ |
|
64 |
private MethodWriter writer; |
|
65 |
||
66 |
/** |
|
67 |
* The methods being documented. |
|
68 |
*/ |
|
868 | 69 |
private List<ProgramElementDoc> methods; |
10 | 70 |
|
71 |
private MethodBuilder(Configuration configuration) { |
|
72 |
super(configuration); |
|
73 |
} |
|
74 |
||
75 |
/** |
|
76 |
* Construct a new MethodBuilder. |
|
77 |
* |
|
78 |
* @param configuration the current configuration of the doclet. |
|
79 |
* @param classDoc the class whoses members are being documented. |
|
80 |
* @param writer the doclet specific writer. |
|
81 |
* |
|
82 |
* @return an instance of a MethodBuilder. |
|
83 |
*/ |
|
84 |
public static MethodBuilder getInstance( |
|
85 |
Configuration configuration, |
|
86 |
ClassDoc classDoc, |
|
87 |
MethodWriter writer) { |
|
88 |
MethodBuilder builder = new MethodBuilder(configuration); |
|
89 |
builder.classDoc = classDoc; |
|
90 |
builder.writer = writer; |
|
91 |
builder.visibleMemberMap = |
|
92 |
new VisibleMemberMap( |
|
93 |
classDoc, |
|
94 |
VisibleMemberMap.METHODS, |
|
95 |
configuration.nodeprecated); |
|
96 |
builder.methods = |
|
868 | 97 |
new ArrayList<ProgramElementDoc>(builder.visibleMemberMap.getLeafClassMembers( |
10 | 98 |
configuration)); |
99 |
if (configuration.getMemberComparator() != null) { |
|
100 |
Collections.sort( |
|
101 |
builder.methods, |
|
102 |
configuration.getMemberComparator()); |
|
103 |
} |
|
104 |
return builder; |
|
105 |
} |
|
106 |
||
107 |
/** |
|
108 |
* {@inheritDoc} |
|
109 |
*/ |
|
110 |
public String getName() { |
|
111 |
return "MethodDetails"; |
|
112 |
} |
|
113 |
||
114 |
/** |
|
115 |
* Returns a list of methods that will be documented for the given class. |
|
116 |
* This information can be used for doclet specific documentation |
|
117 |
* generation. |
|
118 |
* |
|
119 |
* @param classDoc the {@link ClassDoc} we want to check. |
|
120 |
* @return a list of methods that will be documented. |
|
121 |
*/ |
|
1789
7ac8c0815000
6765045: Remove rawtypes warnings from langtools
mcimadamore
parents:
1264
diff
changeset
|
122 |
public List<ProgramElementDoc> members(ClassDoc classDoc) { |
10 | 123 |
return visibleMemberMap.getMembersFor(classDoc); |
124 |
} |
|
125 |
||
126 |
/** |
|
127 |
* Returns the visible member map for the methods of this class. |
|
128 |
* |
|
129 |
* @return the visible member map for the methods of this class. |
|
130 |
*/ |
|
131 |
public VisibleMemberMap getVisibleMemberMap() { |
|
132 |
return visibleMemberMap; |
|
133 |
} |
|
134 |
||
135 |
/** |
|
136 |
* {@inheritDoc} |
|
137 |
*/ |
|
138 |
public boolean hasMembersToDocument() { |
|
139 |
return methods.size() > 0; |
|
140 |
} |
|
141 |
||
142 |
/** |
|
143 |
* Build the method documentation. |
|
144 |
*/ |
|
5855 | 145 |
public void buildMethodDoc(XMLNode node) { |
10 | 146 |
if (writer == null) { |
147 |
return; |
|
148 |
} |
|
149 |
for (currentMethodIndex = 0; |
|
150 |
currentMethodIndex < methods.size(); |
|
151 |
currentMethodIndex++) { |
|
5855 | 152 |
buildChildren(node); |
10 | 153 |
} |
154 |
} |
|
155 |
||
156 |
/** |
|
157 |
* Build the overall header. |
|
158 |
*/ |
|
5855 | 159 |
public void buildHeader(XMLNode node) { |
10 | 160 |
writer.writeHeader( |
161 |
classDoc, |
|
162 |
configuration.getText("doclet.Method_Detail")); |
|
163 |
} |
|
164 |
||
165 |
/** |
|
166 |
* Build the header for the individual method. |
|
167 |
*/ |
|
5855 | 168 |
public void buildMethodHeader(XMLNode node) { |
10 | 169 |
writer.writeMethodHeader( |
170 |
(MethodDoc) methods.get(currentMethodIndex), |
|
171 |
currentMethodIndex == 0); |
|
172 |
} |
|
173 |
||
174 |
/** |
|
175 |
* Build the signature. |
|
176 |
*/ |
|
5855 | 177 |
public void buildSignature(XMLNode node) { |
10 | 178 |
writer.writeSignature((MethodDoc) methods.get(currentMethodIndex)); |
179 |
} |
|
180 |
||
181 |
/** |
|
182 |
* Build the deprecation information. |
|
183 |
*/ |
|
5855 | 184 |
public void buildDeprecationInfo(XMLNode node) { |
10 | 185 |
writer.writeDeprecated((MethodDoc) methods.get(currentMethodIndex)); |
186 |
} |
|
187 |
||
188 |
/** |
|
189 |
* Build the comments for the method. Do nothing if |
|
190 |
* {@link Configuration#nocomment} is set to true. If this method |
|
191 |
*/ |
|
5855 | 192 |
public void buildMethodComments(XMLNode node) { |
10 | 193 |
if (!configuration.nocomment) { |
194 |
MethodDoc method = (MethodDoc) methods.get(currentMethodIndex); |
|
195 |
||
196 |
if (method.inlineTags().length == 0) { |
|
197 |
DocFinder.Output docs = DocFinder.search( |
|
198 |
new DocFinder.Input(method)); |
|
199 |
method = docs.inlineTags != null && docs.inlineTags.length > 0 ? |
|
200 |
(MethodDoc) docs.holder : method; |
|
201 |
||
202 |
} |
|
203 |
//NOTE: When we fix the bug where ClassDoc.interfaceTypes() does |
|
204 |
// not pass all implemented interfaces, holder will be the |
|
205 |
// interface type. For now, it is really the erasure. |
|
206 |
writer.writeComments(method.containingClass(), method); |
|
207 |
} |
|
208 |
} |
|
209 |
||
210 |
||
211 |
||
212 |
/** |
|
213 |
* Build the tag information. |
|
214 |
*/ |
|
5855 | 215 |
public void buildTagInfo(XMLNode node) { |
10 | 216 |
writer.writeTags((MethodDoc) methods.get(currentMethodIndex)); |
217 |
} |
|
218 |
||
219 |
/** |
|
220 |
* Build the footer of the method. |
|
221 |
*/ |
|
5855 | 222 |
public void buildMethodFooter(XMLNode node) { |
10 | 223 |
writer.writeMethodFooter(); |
224 |
} |
|
225 |
||
226 |
/** |
|
227 |
* Build the overall footer. |
|
228 |
*/ |
|
5855 | 229 |
public void buildFooter(XMLNode node) { |
10 | 230 |
writer.writeFooter(classDoc); |
231 |
} |
|
232 |
||
233 |
/** |
|
234 |
* Return the method writer for this builder. |
|
235 |
* |
|
236 |
* @return the method writer for this builder. |
|
237 |
*/ |
|
238 |
public MethodWriter getWriter() { |
|
239 |
return writer; |
|
240 |
} |
|
241 |
} |