|
1 /* |
|
2 * Copyright 2003 Sun Microsystems, Inc. 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. Sun designates this |
|
8 * particular file as subject to the "Classpath" exception as provided |
|
9 * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
|
22 * CA 95054 USA or visit www.sun.com if you need additional information or |
|
23 * have any questions. |
|
24 */ |
|
25 |
|
26 package com.sun.tools.doclets.internal.toolkit.builders; |
|
27 |
|
28 import com.sun.tools.doclets.internal.toolkit.*; |
|
29 import com.sun.tools.doclets.internal.toolkit.util.*; |
|
30 import com.sun.javadoc.*; |
|
31 |
|
32 /** |
|
33 * The factory for constructing builders. |
|
34 * |
|
35 * This code is not part of an API. |
|
36 * It is implementation that is subject to change. |
|
37 * Do not use it as an API |
|
38 * |
|
39 * @author Jamie Ho |
|
40 * @since 1.4 |
|
41 */ |
|
42 |
|
43 public class BuilderFactory { |
|
44 |
|
45 /** |
|
46 * The current configuration of the doclet. |
|
47 */ |
|
48 private Configuration configuration; |
|
49 |
|
50 /** |
|
51 * The factory to retrieve the required writers from. |
|
52 */ |
|
53 private WriterFactory writerFactory; |
|
54 |
|
55 /** |
|
56 * Construct a builder factory using the given configuration. |
|
57 * @param configuration the configuration for the current doclet |
|
58 * being executed. |
|
59 */ |
|
60 public BuilderFactory (Configuration configuration) { |
|
61 this.configuration = configuration; |
|
62 this.writerFactory = configuration.getWriterFactory(); |
|
63 } |
|
64 |
|
65 /** |
|
66 * Return the builder that builds the constant summary. |
|
67 * @return the builder that builds the constant summary. |
|
68 */ |
|
69 public AbstractBuilder getConstantsSummaryBuider() throws Exception { |
|
70 return ConstantsSummaryBuilder.getInstance(configuration, |
|
71 writerFactory.getConstantsSummaryWriter()); |
|
72 } |
|
73 |
|
74 /** |
|
75 * Return the builder that builds the package summary. |
|
76 * |
|
77 * @param pkg the package being documented. |
|
78 * @param prevPkg the previous package being documented. |
|
79 * @param nextPkg the next package being documented. |
|
80 * @return the builder that builds the constant summary. |
|
81 */ |
|
82 public AbstractBuilder getPackageSummaryBuilder(PackageDoc pkg, PackageDoc prevPkg, |
|
83 PackageDoc nextPkg) throws Exception { |
|
84 return PackageSummaryBuilder.getInstance(configuration, pkg, |
|
85 writerFactory.getPackageSummaryWriter(pkg, prevPkg, nextPkg)); |
|
86 } |
|
87 |
|
88 /** |
|
89 * Return the builder for the class. |
|
90 * |
|
91 * @param classDoc the class being documented. |
|
92 * @param prevClass the previous class that was documented. |
|
93 * @param nextClass the next class being documented. |
|
94 * @param classTree the class tree. |
|
95 * @return the writer for the class. Return null if this |
|
96 * writer is not supported by the doclet. |
|
97 */ |
|
98 public AbstractBuilder getClassBuilder(ClassDoc classDoc, |
|
99 ClassDoc prevClass, ClassDoc nextClass, ClassTree classTree) |
|
100 throws Exception { |
|
101 return ClassBuilder.getInstance(configuration, classDoc, |
|
102 writerFactory.getClassWriter(classDoc, prevClass, nextClass, |
|
103 classTree)); |
|
104 } |
|
105 |
|
106 /** |
|
107 * Return the builder for the annotation type. |
|
108 * |
|
109 * @param annotationType the annotation type being documented. |
|
110 * @param prevType the previous type that was documented. |
|
111 * @param nextType the next type being documented. |
|
112 * @return the writer for the annotation type. Return null if this |
|
113 * writer is not supported by the doclet. |
|
114 */ |
|
115 public AbstractBuilder getAnnotationTypeBuilder( |
|
116 AnnotationTypeDoc annotationType, |
|
117 Type prevType, Type nextType) |
|
118 throws Exception { |
|
119 return AnnotationTypeBuilder.getInstance(configuration, annotationType, |
|
120 writerFactory.getAnnotationTypeWriter(annotationType, prevType, |
|
121 nextType)); |
|
122 } |
|
123 |
|
124 /** |
|
125 * Return an instance of the method builder for the given class. |
|
126 * |
|
127 * @return an instance of the method builder for the given class. |
|
128 */ |
|
129 public AbstractBuilder getMethodBuilder(ClassWriter classWriter) |
|
130 throws Exception { |
|
131 return MethodBuilder.getInstance(configuration, |
|
132 classWriter.getClassDoc(), |
|
133 writerFactory.getMethodWriter(classWriter)); |
|
134 } |
|
135 |
|
136 /** |
|
137 * Return an instance of the annotation type member builder for the given |
|
138 * class. |
|
139 * |
|
140 * @return an instance of the annotation type memebr builder for the given |
|
141 * annotation type. |
|
142 */ |
|
143 public AbstractBuilder getAnnotationTypeOptionalMemberBuilder( |
|
144 AnnotationTypeWriter annotationTypeWriter) |
|
145 throws Exception { |
|
146 return AnnotationTypeOptionalMemberBuilder.getInstance(configuration, |
|
147 annotationTypeWriter.getAnnotationTypeDoc(), |
|
148 writerFactory.getAnnotationTypeOptionalMemberWriter( |
|
149 annotationTypeWriter)); |
|
150 } |
|
151 |
|
152 /** |
|
153 * Return an instance of the annotation type member builder for the given |
|
154 * class. |
|
155 * |
|
156 * @return an instance of the annotation type memebr builder for the given |
|
157 * annotation type. |
|
158 */ |
|
159 public AbstractBuilder getAnnotationTypeRequiredMemberBuilder( |
|
160 AnnotationTypeWriter annotationTypeWriter) |
|
161 throws Exception { |
|
162 return AnnotationTypeRequiredMemberBuilder.getInstance(configuration, |
|
163 annotationTypeWriter.getAnnotationTypeDoc(), |
|
164 writerFactory.getAnnotationTypeRequiredMemberWriter( |
|
165 annotationTypeWriter)); |
|
166 } |
|
167 |
|
168 /** |
|
169 * Return an instance of the enum constants builder for the given class. |
|
170 * |
|
171 * @return an instance of the enum constants builder for the given class. |
|
172 */ |
|
173 public AbstractBuilder getEnumConstantsBuilder(ClassWriter classWriter) |
|
174 throws Exception { |
|
175 return EnumConstantBuilder.getInstance(configuration, classWriter.getClassDoc(), |
|
176 writerFactory.getEnumConstantWriter(classWriter)); |
|
177 } |
|
178 |
|
179 /** |
|
180 * Return an instance of the field builder for the given class. |
|
181 * |
|
182 * @return an instance of the field builder for the given class. |
|
183 */ |
|
184 public AbstractBuilder getFieldBuilder(ClassWriter classWriter) |
|
185 throws Exception { |
|
186 return FieldBuilder.getInstance(configuration, classWriter.getClassDoc(), |
|
187 writerFactory.getFieldWriter(classWriter)); |
|
188 } |
|
189 |
|
190 /** |
|
191 * Return an instance of the constructor builder for the given class. |
|
192 * |
|
193 * @return an instance of the constructor builder for the given class. |
|
194 */ |
|
195 public AbstractBuilder getConstructorBuilder(ClassWriter classWriter) |
|
196 throws Exception { |
|
197 return ConstructorBuilder.getInstance(configuration, |
|
198 classWriter.getClassDoc(), writerFactory.getConstructorWriter( |
|
199 classWriter)); |
|
200 } |
|
201 |
|
202 /** |
|
203 * Return an instance of the member summary builder for the given class. |
|
204 * |
|
205 * @return an instance of the member summary builder for the given class. |
|
206 */ |
|
207 public AbstractBuilder getMemberSummaryBuilder(ClassWriter classWriter) |
|
208 throws Exception { |
|
209 return MemberSummaryBuilder.getInstance(classWriter, configuration); |
|
210 } |
|
211 |
|
212 /** |
|
213 * Return an instance of the member summary builder for the given annotation |
|
214 * type. |
|
215 * |
|
216 * @return an instance of the member summary builder for the given |
|
217 * annotation type. |
|
218 */ |
|
219 public AbstractBuilder getMemberSummaryBuilder( |
|
220 AnnotationTypeWriter annotationTypeWriter) |
|
221 throws Exception { |
|
222 return MemberSummaryBuilder.getInstance(annotationTypeWriter, |
|
223 configuration); |
|
224 } |
|
225 |
|
226 /** |
|
227 * Return the builder that builds the serialized form. |
|
228 * |
|
229 * @return the builder that builds the serialized form. |
|
230 */ |
|
231 public AbstractBuilder getSerializedFormBuilder() |
|
232 throws Exception { |
|
233 return SerializedFormBuilder.getInstance(configuration); |
|
234 } |
|
235 } |