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.*; |
|
32 |
||
33 |
/** |
|
34 |
* Builds documentation for a constructor. |
|
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 ConstructorBuilder extends AbstractMemberBuilder { |
|
44 |
||
45 |
/** |
|
46 |
* The name of this builder. |
|
47 |
*/ |
|
48 |
public static final String NAME = "ConstructorDetails"; |
|
49 |
||
50 |
/** |
|
51 |
* The index of the current field that is being documented at this point |
|
52 |
* in time. |
|
53 |
*/ |
|
54 |
private int currentMethodIndex; |
|
55 |
||
56 |
/** |
|
57 |
* The class whose constructors are being documented. |
|
58 |
*/ |
|
59 |
private ClassDoc classDoc; |
|
60 |
||
61 |
/** |
|
62 |
* The visible constructors for the given class. |
|
63 |
*/ |
|
64 |
private VisibleMemberMap visibleMemberMap; |
|
65 |
||
66 |
/** |
|
67 |
* The writer to output the constructor documentation. |
|
68 |
*/ |
|
69 |
private ConstructorWriter writer; |
|
70 |
||
71 |
/** |
|
72 |
* The constructors being documented. |
|
73 |
*/ |
|
868 | 74 |
private List<ProgramElementDoc> constructors; |
10 | 75 |
|
76 |
/** |
|
77 |
* Construct a new ConstructorBuilder. |
|
78 |
* |
|
79 |
* @param configuration the current configuration of the |
|
80 |
* doclet. |
|
81 |
*/ |
|
82 |
private ConstructorBuilder(Configuration configuration) { |
|
83 |
super(configuration); |
|
84 |
} |
|
85 |
||
86 |
/** |
|
87 |
* Construct a new ConstructorBuilder. |
|
88 |
* |
|
89 |
* @param configuration the current configuration of the doclet. |
|
90 |
* @param classDoc the class whoses members are being documented. |
|
91 |
* @param writer the doclet specific writer. |
|
92 |
*/ |
|
93 |
public static ConstructorBuilder getInstance( |
|
94 |
Configuration configuration, |
|
95 |
ClassDoc classDoc, |
|
96 |
ConstructorWriter writer) { |
|
97 |
ConstructorBuilder builder = new ConstructorBuilder(configuration); |
|
98 |
builder.classDoc = classDoc; |
|
99 |
builder.writer = writer; |
|
100 |
builder.visibleMemberMap = |
|
101 |
new VisibleMemberMap( |
|
102 |
classDoc, |
|
103 |
VisibleMemberMap.CONSTRUCTORS, |
|
104 |
configuration.nodeprecated); |
|
105 |
builder.constructors = |
|
868 | 106 |
new ArrayList<ProgramElementDoc>(builder.visibleMemberMap.getMembersFor(classDoc)); |
10 | 107 |
for (int i = 0; i < builder.constructors.size(); i++) { |
868 | 108 |
if (builder.constructors.get(i).isProtected() |
109 |
|| builder.constructors.get(i).isPrivate()) { |
|
10 | 110 |
writer.setFoundNonPubConstructor(true); |
111 |
} |
|
112 |
} |
|
113 |
if (configuration.getMemberComparator() != null) { |
|
114 |
Collections.sort( |
|
115 |
builder.constructors, |
|
116 |
configuration.getMemberComparator()); |
|
117 |
} |
|
118 |
return builder; |
|
119 |
} |
|
120 |
||
121 |
/** |
|
122 |
* {@inheritDoc} |
|
123 |
*/ |
|
124 |
public String getName() { |
|
125 |
return NAME; |
|
126 |
} |
|
127 |
||
128 |
/** |
|
129 |
* {@inheritDoc} |
|
130 |
*/ |
|
131 |
public boolean hasMembersToDocument() { |
|
132 |
return constructors.size() > 0; |
|
133 |
} |
|
134 |
||
135 |
/** |
|
136 |
* Returns a list of constructors that will be documented for the given class. |
|
137 |
* This information can be used for doclet specific documentation |
|
138 |
* generation. |
|
139 |
* |
|
140 |
* @return a list of constructors that will be documented. |
|
141 |
*/ |
|
1789
7ac8c0815000
6765045: Remove rawtypes warnings from langtools
mcimadamore
parents:
1264
diff
changeset
|
142 |
public List<ProgramElementDoc> members(ClassDoc classDoc) { |
10 | 143 |
return visibleMemberMap.getMembersFor(classDoc); |
144 |
} |
|
145 |
||
146 |
/** |
|
147 |
* Return the constructor writer for this builder. |
|
148 |
* |
|
149 |
* @return the constructor writer for this builder. |
|
150 |
*/ |
|
151 |
public ConstructorWriter getWriter() { |
|
152 |
return writer; |
|
153 |
} |
|
154 |
||
155 |
/** |
|
156 |
* Build the constructor documentation. |
|
157 |
* |
|
158 |
* @param elements the XML elements that specify how to construct this |
|
159 |
* documentation. |
|
160 |
*/ |
|
5855 | 161 |
public void buildConstructorDoc(XMLNode node) { |
10 | 162 |
if (writer == null) { |
163 |
return; |
|
164 |
} |
|
165 |
for (currentMethodIndex = 0; |
|
166 |
currentMethodIndex < constructors.size(); |
|
167 |
currentMethodIndex++) { |
|
5855 | 168 |
buildChildren(node); |
10 | 169 |
} |
170 |
} |
|
171 |
||
172 |
/** |
|
173 |
* Build the overall header. |
|
174 |
*/ |
|
5855 | 175 |
public void buildHeader(XMLNode node) { |
10 | 176 |
writer.writeHeader( |
177 |
classDoc, |
|
178 |
configuration.getText("doclet.Constructor_Detail")); |
|
179 |
} |
|
180 |
||
181 |
/** |
|
182 |
* Build the header for the individual constructor. |
|
183 |
*/ |
|
5855 | 184 |
public void buildConstructorHeader(XMLNode node) { |
10 | 185 |
writer.writeConstructorHeader( |
186 |
(ConstructorDoc) constructors.get(currentMethodIndex), |
|
187 |
currentMethodIndex == 0); |
|
188 |
} |
|
189 |
||
190 |
/** |
|
191 |
* Build the signature. |
|
192 |
*/ |
|
5855 | 193 |
public void buildSignature(XMLNode node) { |
10 | 194 |
writer.writeSignature( |
195 |
(ConstructorDoc) constructors.get(currentMethodIndex)); |
|
196 |
} |
|
197 |
||
198 |
/** |
|
199 |
* Build the deprecation information. |
|
200 |
*/ |
|
5855 | 201 |
public void buildDeprecationInfo(XMLNode node) { |
10 | 202 |
writer.writeDeprecated( |
203 |
(ConstructorDoc) constructors.get(currentMethodIndex)); |
|
204 |
} |
|
205 |
||
206 |
/** |
|
207 |
* Build the comments for the constructor. Do nothing if |
|
208 |
* {@link Configuration#nocomment} is set to true. |
|
209 |
*/ |
|
5855 | 210 |
public void buildConstructorComments(XMLNode node) { |
10 | 211 |
if (!configuration.nocomment) { |
212 |
writer.writeComments( |
|
213 |
(ConstructorDoc) constructors.get(currentMethodIndex)); |
|
214 |
} |
|
215 |
} |
|
216 |
||
217 |
/** |
|
218 |
* Build the tag information. |
|
219 |
*/ |
|
5855 | 220 |
public void buildTagInfo(XMLNode node) { |
10 | 221 |
writer.writeTags((ConstructorDoc) constructors.get(currentMethodIndex)); |
222 |
} |
|
223 |
||
224 |
/** |
|
225 |
* Build the footer for the individual constructor. |
|
226 |
*/ |
|
5855 | 227 |
public void buildConstructorFooter(XMLNode node) { |
10 | 228 |
writer.writeConstructorFooter(); |
229 |
} |
|
230 |
||
231 |
/** |
|
232 |
* Build the overall footer. |
|
233 |
*/ |
|
5855 | 234 |
public void buildFooter(XMLNode node) { |
10 | 235 |
writer.writeFooter(classDoc); |
236 |
} |
|
237 |
} |