src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/BuilderFactory.java

Thu, 31 Aug 2017 15:17:03 +0800

author
aoqi
date
Thu, 31 Aug 2017 15:17:03 +0800
changeset 2525
2eb010b6cb22
parent 2035
a2a5ad0853ed
parent 0
959103a6100f
permissions
-rw-r--r--

merge

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation. Oracle designates this
aoqi@0 8 * particular file as subject to the "Classpath" exception as provided
aoqi@0 9 * by Oracle in the LICENSE file that accompanied this code.
aoqi@0 10 *
aoqi@0 11 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 14 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 15 * accompanied this code).
aoqi@0 16 *
aoqi@0 17 * You should have received a copy of the GNU General Public License version
aoqi@0 18 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 20 *
aoqi@0 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 22 * or visit www.oracle.com if you need additional information or have any
aoqi@0 23 * questions.
aoqi@0 24 */
aoqi@0 25
aoqi@0 26 package com.sun.tools.doclets.internal.toolkit.builders;
aoqi@0 27
aoqi@0 28 import java.util.HashSet;
aoqi@0 29 import java.util.Set;
aoqi@0 30
aoqi@0 31 import com.sun.javadoc.*;
aoqi@0 32 import com.sun.tools.javac.jvm.Profile;
aoqi@0 33 import com.sun.tools.doclets.internal.toolkit.*;
aoqi@0 34 import com.sun.tools.doclets.internal.toolkit.util.*;
aoqi@0 35
aoqi@0 36 /**
aoqi@0 37 * The factory for constructing builders.
aoqi@0 38 *
aoqi@0 39 * <p><b>This is NOT part of any supported API.
aoqi@0 40 * If you write code that depends on this, you do so at your own risk.
aoqi@0 41 * This code and its internal interfaces are subject to change or
aoqi@0 42 * deletion without notice.</b>
aoqi@0 43 *
aoqi@0 44 * @author Jamie Ho
aoqi@0 45 * @since 1.4
aoqi@0 46 */
aoqi@0 47
aoqi@0 48 public class BuilderFactory {
aoqi@0 49
aoqi@0 50 /**
aoqi@0 51 * The current configuration of the doclet.
aoqi@0 52 */
aoqi@0 53 private final Configuration configuration;
aoqi@0 54
aoqi@0 55 /**
aoqi@0 56 * The factory to retrieve the required writers from.
aoqi@0 57 */
aoqi@0 58 private final WriterFactory writerFactory;
aoqi@0 59
aoqi@0 60 private final AbstractBuilder.Context context;
aoqi@0 61
aoqi@0 62 /**
aoqi@0 63 * Construct a builder factory using the given configuration.
aoqi@0 64 * @param configuration the configuration for the current doclet
aoqi@0 65 * being executed.
aoqi@0 66 */
aoqi@0 67 public BuilderFactory (Configuration configuration) {
aoqi@0 68 this.configuration = configuration;
aoqi@0 69 this.writerFactory = configuration.getWriterFactory();
aoqi@0 70
aoqi@0 71 Set<String> containingPackagesSeen = new HashSet<String>();
aoqi@0 72 context = new AbstractBuilder.Context(configuration, containingPackagesSeen,
aoqi@0 73 LayoutParser.getInstance(configuration));
aoqi@0 74 }
aoqi@0 75
aoqi@0 76 /**
aoqi@0 77 * Return the builder that builds the constant summary.
aoqi@0 78 * @return the builder that builds the constant summary.
aoqi@0 79 */
aoqi@0 80 public AbstractBuilder getConstantsSummaryBuider() throws Exception {
aoqi@0 81 return ConstantsSummaryBuilder.getInstance(context,
aoqi@0 82 writerFactory.getConstantsSummaryWriter());
aoqi@0 83 }
aoqi@0 84
aoqi@0 85 /**
aoqi@0 86 * Return the builder that builds the package summary.
aoqi@0 87 *
aoqi@0 88 * @param pkg the package being documented.
aoqi@0 89 * @param prevPkg the previous package being documented.
aoqi@0 90 * @param nextPkg the next package being documented.
aoqi@0 91 * @return the builder that builds the constant summary.
aoqi@0 92 */
aoqi@0 93 public AbstractBuilder getPackageSummaryBuilder(PackageDoc pkg, PackageDoc prevPkg,
aoqi@0 94 PackageDoc nextPkg) throws Exception {
aoqi@0 95 return PackageSummaryBuilder.getInstance(context, pkg,
aoqi@0 96 writerFactory.getPackageSummaryWriter(pkg, prevPkg, nextPkg));
aoqi@0 97 }
aoqi@0 98
aoqi@0 99 /**
aoqi@0 100 * Return the builder that builds the profile summary.
aoqi@0 101 *
aoqi@0 102 * @param profile the profile being documented.
aoqi@0 103 * @param prevProfile the previous profile being documented.
aoqi@0 104 * @param nextProfile the next profile being documented.
aoqi@0 105 * @return the builder that builds the profile summary.
aoqi@0 106 */
aoqi@0 107 public AbstractBuilder getProfileSummaryBuilder(Profile profile, Profile prevProfile,
aoqi@0 108 Profile nextProfile) throws Exception {
aoqi@0 109 return ProfileSummaryBuilder.getInstance(context, profile,
aoqi@0 110 writerFactory.getProfileSummaryWriter(profile, prevProfile, nextProfile));
aoqi@0 111 }
aoqi@0 112
aoqi@0 113 /**
aoqi@0 114 * Return the builder that builds the profile package summary.
aoqi@0 115 *
aoqi@0 116 * @param pkg the profile package being documented.
aoqi@0 117 * @param prevPkg the previous profile package being documented.
aoqi@0 118 * @param nextPkg the next profile package being documented.
aoqi@0 119 * @param profile the profile being documented.
aoqi@0 120 * @return the builder that builds the profile package summary.
aoqi@0 121 */
aoqi@0 122 public AbstractBuilder getProfilePackageSummaryBuilder(PackageDoc pkg, PackageDoc prevPkg,
aoqi@0 123 PackageDoc nextPkg, Profile profile) throws Exception {
aoqi@0 124 return ProfilePackageSummaryBuilder.getInstance(context, pkg,
aoqi@0 125 writerFactory.getProfilePackageSummaryWriter(pkg, prevPkg, nextPkg,
aoqi@0 126 profile), profile);
aoqi@0 127 }
aoqi@0 128
aoqi@0 129 /**
aoqi@0 130 * Return the builder for the class.
aoqi@0 131 *
aoqi@0 132 * @param classDoc the class being documented.
aoqi@0 133 * @param prevClass the previous class that was documented.
aoqi@0 134 * @param nextClass the next class being documented.
aoqi@0 135 * @param classTree the class tree.
aoqi@0 136 * @return the writer for the class. Return null if this
aoqi@0 137 * writer is not supported by the doclet.
aoqi@0 138 */
aoqi@0 139 public AbstractBuilder getClassBuilder(ClassDoc classDoc,
aoqi@0 140 ClassDoc prevClass, ClassDoc nextClass, ClassTree classTree)
aoqi@0 141 throws Exception {
aoqi@0 142 return ClassBuilder.getInstance(context, classDoc,
aoqi@0 143 writerFactory.getClassWriter(classDoc, prevClass, nextClass,
aoqi@0 144 classTree));
aoqi@0 145 }
aoqi@0 146
aoqi@0 147 /**
aoqi@0 148 * Return the builder for the annotation type.
aoqi@0 149 *
aoqi@0 150 * @param annotationType the annotation type being documented.
aoqi@0 151 * @param prevType the previous type that was documented.
aoqi@0 152 * @param nextType the next type being documented.
aoqi@0 153 * @return the writer for the annotation type. Return null if this
aoqi@0 154 * writer is not supported by the doclet.
aoqi@0 155 */
aoqi@0 156 public AbstractBuilder getAnnotationTypeBuilder(
aoqi@0 157 AnnotationTypeDoc annotationType,
aoqi@0 158 Type prevType, Type nextType)
aoqi@0 159 throws Exception {
aoqi@0 160 return AnnotationTypeBuilder.getInstance(context, annotationType,
aoqi@0 161 writerFactory.getAnnotationTypeWriter(annotationType, prevType, nextType));
aoqi@0 162 }
aoqi@0 163
aoqi@0 164 /**
aoqi@0 165 * Return an instance of the method builder for the given class.
aoqi@0 166 *
aoqi@0 167 * @return an instance of the method builder for the given class.
aoqi@0 168 */
aoqi@0 169 public AbstractBuilder getMethodBuilder(ClassWriter classWriter)
aoqi@0 170 throws Exception {
aoqi@0 171 return MethodBuilder.getInstance(context,
aoqi@0 172 classWriter.getClassDoc(),
aoqi@0 173 writerFactory.getMethodWriter(classWriter));
aoqi@0 174 }
aoqi@0 175
aoqi@0 176 /**
aoqi@0 177 * Return an instance of the annotation type fields builder for the given
aoqi@0 178 * class.
aoqi@0 179 *
aoqi@0 180 * @return an instance of the annotation type field builder for the given
aoqi@0 181 * annotation type.
aoqi@0 182 */
aoqi@0 183 public AbstractBuilder getAnnotationTypeFieldsBuilder(
aoqi@0 184 AnnotationTypeWriter annotationTypeWriter)
aoqi@0 185 throws Exception {
aoqi@0 186 return AnnotationTypeFieldBuilder.getInstance(context,
aoqi@0 187 annotationTypeWriter.getAnnotationTypeDoc(),
aoqi@0 188 writerFactory.getAnnotationTypeFieldWriter(
aoqi@0 189 annotationTypeWriter));
aoqi@0 190 }
aoqi@0 191
aoqi@0 192 /**
aoqi@0 193 * Return an instance of the annotation type member builder for the given
aoqi@0 194 * class.
aoqi@0 195 *
aoqi@0 196 * @return an instance of the annotation type member builder for the given
aoqi@0 197 * annotation type.
aoqi@0 198 */
aoqi@0 199 public AbstractBuilder getAnnotationTypeOptionalMemberBuilder(
aoqi@0 200 AnnotationTypeWriter annotationTypeWriter)
aoqi@0 201 throws Exception {
aoqi@0 202 return AnnotationTypeOptionalMemberBuilder.getInstance(context,
aoqi@0 203 annotationTypeWriter.getAnnotationTypeDoc(),
aoqi@0 204 writerFactory.getAnnotationTypeOptionalMemberWriter(
aoqi@0 205 annotationTypeWriter));
aoqi@0 206 }
aoqi@0 207
aoqi@0 208 /**
aoqi@0 209 * Return an instance of the annotation type member builder for the given
aoqi@0 210 * class.
aoqi@0 211 *
aoqi@0 212 * @return an instance of the annotation type member builder for the given
aoqi@0 213 * annotation type.
aoqi@0 214 */
aoqi@0 215 public AbstractBuilder getAnnotationTypeRequiredMemberBuilder(
aoqi@0 216 AnnotationTypeWriter annotationTypeWriter)
aoqi@0 217 throws Exception {
aoqi@0 218 return AnnotationTypeRequiredMemberBuilder.getInstance(context,
aoqi@0 219 annotationTypeWriter.getAnnotationTypeDoc(),
aoqi@0 220 writerFactory.getAnnotationTypeRequiredMemberWriter(
aoqi@0 221 annotationTypeWriter));
aoqi@0 222 }
aoqi@0 223
aoqi@0 224 /**
aoqi@0 225 * Return an instance of the enum constants builder for the given class.
aoqi@0 226 *
aoqi@0 227 * @return an instance of the enum constants builder for the given class.
aoqi@0 228 */
aoqi@0 229 public AbstractBuilder getEnumConstantsBuilder(ClassWriter classWriter)
aoqi@0 230 throws Exception {
aoqi@0 231 return EnumConstantBuilder.getInstance(context, classWriter.getClassDoc(),
aoqi@0 232 writerFactory.getEnumConstantWriter(classWriter));
aoqi@0 233 }
aoqi@0 234
aoqi@0 235 /**
aoqi@0 236 * Return an instance of the field builder for the given class.
aoqi@0 237 *
aoqi@0 238 * @return an instance of the field builder for the given class.
aoqi@0 239 */
aoqi@0 240 public AbstractBuilder getFieldBuilder(ClassWriter classWriter)
aoqi@0 241 throws Exception {
aoqi@0 242 return FieldBuilder.getInstance(context, classWriter.getClassDoc(),
aoqi@0 243 writerFactory.getFieldWriter(classWriter));
aoqi@0 244 }
aoqi@0 245
aoqi@0 246 /**
aoqi@0 247 * Return an instance of the property builder for the given class.
aoqi@0 248 *
aoqi@0 249 * @return an instance of the field builder for the given class.
aoqi@0 250 */
aoqi@0 251 public AbstractBuilder getPropertyBuilder(ClassWriter classWriter) throws Exception {
aoqi@0 252 final PropertyWriter propertyWriter =
aoqi@0 253 writerFactory.getPropertyWriter(classWriter);
aoqi@0 254 return PropertyBuilder.getInstance(context,
aoqi@0 255 classWriter.getClassDoc(),
aoqi@0 256 propertyWriter);
aoqi@0 257 }
aoqi@0 258
aoqi@0 259 /**
aoqi@0 260 * Return an instance of the constructor builder for the given class.
aoqi@0 261 *
aoqi@0 262 * @return an instance of the constructor builder for the given class.
aoqi@0 263 */
aoqi@0 264 public AbstractBuilder getConstructorBuilder(ClassWriter classWriter)
aoqi@0 265 throws Exception {
aoqi@0 266 return ConstructorBuilder.getInstance(context,
aoqi@0 267 classWriter.getClassDoc(),
aoqi@0 268 writerFactory.getConstructorWriter(classWriter));
aoqi@0 269 }
aoqi@0 270
aoqi@0 271 /**
aoqi@0 272 * Return an instance of the member summary builder for the given class.
aoqi@0 273 *
aoqi@0 274 * @return an instance of the member summary builder for the given class.
aoqi@0 275 */
aoqi@0 276 public AbstractBuilder getMemberSummaryBuilder(ClassWriter classWriter)
aoqi@0 277 throws Exception {
aoqi@0 278 return MemberSummaryBuilder.getInstance(classWriter, context);
aoqi@0 279 }
aoqi@0 280
aoqi@0 281 /**
aoqi@0 282 * Return an instance of the member summary builder for the given annotation
aoqi@0 283 * type.
aoqi@0 284 *
aoqi@0 285 * @return an instance of the member summary builder for the given
aoqi@0 286 * annotation type.
aoqi@0 287 */
aoqi@0 288 public AbstractBuilder getMemberSummaryBuilder(
aoqi@0 289 AnnotationTypeWriter annotationTypeWriter)
aoqi@0 290 throws Exception {
aoqi@0 291 return MemberSummaryBuilder.getInstance(annotationTypeWriter, context);
aoqi@0 292 }
aoqi@0 293
aoqi@0 294 /**
aoqi@0 295 * Return the builder that builds the serialized form.
aoqi@0 296 *
aoqi@0 297 * @return the builder that builds the serialized form.
aoqi@0 298 */
aoqi@0 299 public AbstractBuilder getSerializedFormBuilder()
aoqi@0 300 throws Exception {
aoqi@0 301 return SerializedFormBuilder.getInstance(context);
aoqi@0 302 }
aoqi@0 303 }

mercurial