Sun, 24 Feb 2013 11:36:58 -0800
7112427: The doclet needs to be able to generate JavaFX documentation.
Reviewed-by: jjg
Contributed-by: jan.valenta@oracle.com
1 /*
2 * Copyright (c) 2003, 2013, Oracle and/or its affiliates. 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. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle 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 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.
24 */
26 package com.sun.tools.doclets.internal.toolkit.builders;
28 import java.util.HashSet;
29 import java.util.Set;
31 import com.sun.javadoc.*;
32 import com.sun.tools.javac.jvm.Profile;
33 import com.sun.tools.doclets.internal.toolkit.*;
34 import com.sun.tools.doclets.internal.toolkit.util.*;
36 /**
37 * The factory for constructing builders.
38 *
39 * <p><b>This is NOT part of any supported API.
40 * If you write code that depends on this, you do so at your own risk.
41 * This code and its internal interfaces are subject to change or
42 * deletion without notice.</b>
43 *
44 * @author Jamie Ho
45 * @since 1.4
46 */
48 public class BuilderFactory {
50 /**
51 * The current configuration of the doclet.
52 */
53 private final Configuration configuration;
55 /**
56 * The factory to retrieve the required writers from.
57 */
58 private final WriterFactory writerFactory;
60 private final AbstractBuilder.Context context;
62 /**
63 * Construct a builder factory using the given configuration.
64 * @param configuration the configuration for the current doclet
65 * being executed.
66 */
67 public BuilderFactory (Configuration configuration) {
68 this.configuration = configuration;
69 this.writerFactory = configuration.getWriterFactory();
71 Set<String> containingPackagesSeen = new HashSet<String>();
72 context = new AbstractBuilder.Context(configuration, containingPackagesSeen,
73 LayoutParser.getInstance(configuration));
74 }
76 /**
77 * Return the builder that builds the constant summary.
78 * @return the builder that builds the constant summary.
79 */
80 public AbstractBuilder getConstantsSummaryBuider() throws Exception {
81 return ConstantsSummaryBuilder.getInstance(context,
82 writerFactory.getConstantsSummaryWriter());
83 }
85 /**
86 * Return the builder that builds the package summary.
87 *
88 * @param pkg the package being documented.
89 * @param prevPkg the previous package being documented.
90 * @param nextPkg the next package being documented.
91 * @return the builder that builds the constant summary.
92 */
93 public AbstractBuilder getPackageSummaryBuilder(PackageDoc pkg, PackageDoc prevPkg,
94 PackageDoc nextPkg) throws Exception {
95 return PackageSummaryBuilder.getInstance(context, pkg,
96 writerFactory.getPackageSummaryWriter(pkg, prevPkg, nextPkg));
97 }
99 /**
100 * Return the builder that builds the profile summary.
101 *
102 * @param profile the profile being documented.
103 * @param prevProfile the previous profile being documented.
104 * @param nextProfile the next profile being documented.
105 * @return the builder that builds the profile summary.
106 */
107 public AbstractBuilder getProfileSummaryBuilder(Profile profile, Profile prevProfile,
108 Profile nextProfile) throws Exception {
109 return ProfileSummaryBuilder.getInstance(context, profile,
110 writerFactory.getProfileSummaryWriter(profile, prevProfile, nextProfile));
111 }
113 /**
114 * Return the builder that builds the profile package summary.
115 *
116 * @param pkg the profile package being documented.
117 * @param prevPkg the previous profile package being documented.
118 * @param nextPkg the next profile package being documented.
119 * @param profile the profile being documented.
120 * @return the builder that builds the profile package summary.
121 */
122 public AbstractBuilder getProfilePackageSummaryBuilder(PackageDoc pkg, PackageDoc prevPkg,
123 PackageDoc nextPkg, Profile profile) throws Exception {
124 return ProfilePackageSummaryBuilder.getInstance(context, pkg,
125 writerFactory.getProfilePackageSummaryWriter(pkg, prevPkg, nextPkg,
126 profile), profile);
127 }
129 /**
130 * Return the builder for the class.
131 *
132 * @param classDoc the class being documented.
133 * @param prevClass the previous class that was documented.
134 * @param nextClass the next class being documented.
135 * @param classTree the class tree.
136 * @return the writer for the class. Return null if this
137 * writer is not supported by the doclet.
138 */
139 public AbstractBuilder getClassBuilder(ClassDoc classDoc,
140 ClassDoc prevClass, ClassDoc nextClass, ClassTree classTree)
141 throws Exception {
142 return ClassBuilder.getInstance(context, classDoc,
143 writerFactory.getClassWriter(classDoc, prevClass, nextClass,
144 classTree));
145 }
147 /**
148 * Return the builder for the annotation type.
149 *
150 * @param annotationType the annotation type being documented.
151 * @param prevType the previous type that was documented.
152 * @param nextType the next type being documented.
153 * @return the writer for the annotation type. Return null if this
154 * writer is not supported by the doclet.
155 */
156 public AbstractBuilder getAnnotationTypeBuilder(
157 AnnotationTypeDoc annotationType,
158 Type prevType, Type nextType)
159 throws Exception {
160 return AnnotationTypeBuilder.getInstance(context, annotationType,
161 writerFactory.getAnnotationTypeWriter(annotationType, prevType, nextType));
162 }
164 /**
165 * Return an instance of the method builder for the given class.
166 *
167 * @return an instance of the method builder for the given class.
168 */
169 public AbstractBuilder getMethodBuilder(ClassWriter classWriter)
170 throws Exception {
171 return MethodBuilder.getInstance(context,
172 classWriter.getClassDoc(),
173 writerFactory.getMethodWriter(classWriter));
174 }
176 /**
177 * Return an instance of the annotation type member builder for the given
178 * class.
179 *
180 * @return an instance of the annotation type memebr builder for the given
181 * annotation type.
182 */
183 public AbstractBuilder getAnnotationTypeOptionalMemberBuilder(
184 AnnotationTypeWriter annotationTypeWriter)
185 throws Exception {
186 return AnnotationTypeOptionalMemberBuilder.getInstance(context,
187 annotationTypeWriter.getAnnotationTypeDoc(),
188 writerFactory.getAnnotationTypeOptionalMemberWriter(
189 annotationTypeWriter));
190 }
192 /**
193 * Return an instance of the annotation type member builder for the given
194 * class.
195 *
196 * @return an instance of the annotation type memebr builder for the given
197 * annotation type.
198 */
199 public AbstractBuilder getAnnotationTypeRequiredMemberBuilder(
200 AnnotationTypeWriter annotationTypeWriter)
201 throws Exception {
202 return AnnotationTypeRequiredMemberBuilder.getInstance(context,
203 annotationTypeWriter.getAnnotationTypeDoc(),
204 writerFactory.getAnnotationTypeRequiredMemberWriter(
205 annotationTypeWriter));
206 }
208 /**
209 * Return an instance of the enum constants builder for the given class.
210 *
211 * @return an instance of the enum constants builder for the given class.
212 */
213 public AbstractBuilder getEnumConstantsBuilder(ClassWriter classWriter)
214 throws Exception {
215 return EnumConstantBuilder.getInstance(context, classWriter.getClassDoc(),
216 writerFactory.getEnumConstantWriter(classWriter));
217 }
219 /**
220 * Return an instance of the field builder for the given class.
221 *
222 * @return an instance of the field builder for the given class.
223 */
224 public AbstractBuilder getFieldBuilder(ClassWriter classWriter)
225 throws Exception {
226 return FieldBuilder.getInstance(context, classWriter.getClassDoc(),
227 writerFactory.getFieldWriter(classWriter));
228 }
230 /**
231 * Return an instance of the property builder for the given class.
232 *
233 * @return an instance of the field builder for the given class.
234 */
235 public AbstractBuilder getPropertyBuilder(ClassWriter classWriter) throws Exception {
236 final PropertyWriter propertyWriter =
237 writerFactory.getPropertyWriter(classWriter);
238 return PropertyBuilder.getInstance(context,
239 classWriter.getClassDoc(),
240 propertyWriter);
241 }
243 /**
244 * Return an instance of the constructor builder for the given class.
245 *
246 * @return an instance of the constructor builder for the given class.
247 */
248 public AbstractBuilder getConstructorBuilder(ClassWriter classWriter)
249 throws Exception {
250 return ConstructorBuilder.getInstance(context,
251 classWriter.getClassDoc(),
252 writerFactory.getConstructorWriter(classWriter));
253 }
255 /**
256 * Return an instance of the member summary builder for the given class.
257 *
258 * @return an instance of the member summary builder for the given class.
259 */
260 public AbstractBuilder getMemberSummaryBuilder(ClassWriter classWriter)
261 throws Exception {
262 return MemberSummaryBuilder.getInstance(classWriter, context);
263 }
265 /**
266 * Return an instance of the member summary builder for the given annotation
267 * type.
268 *
269 * @return an instance of the member summary builder for the given
270 * annotation type.
271 */
272 public AbstractBuilder getMemberSummaryBuilder(
273 AnnotationTypeWriter annotationTypeWriter)
274 throws Exception {
275 return MemberSummaryBuilder.getInstance(annotationTypeWriter, context);
276 }
278 /**
279 * Return the builder that builds the serialized form.
280 *
281 * @return the builder that builds the serialized form.
282 */
283 public AbstractBuilder getSerializedFormBuilder()
284 throws Exception {
285 return SerializedFormBuilder.getInstance(context);
286 }
287 }