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

Wed, 18 Sep 2013 17:13:26 -0700

author
bpatel
date
Wed, 18 Sep 2013 17:13:26 -0700
changeset 2035
a2a5ad0853ed
parent 1606
ccbe7ffdd867
child 2525
2eb010b6cb22
permissions
-rw-r--r--

8015249: javadoc fails to document static final fields in annotation types
Reviewed-by: jjg

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

mercurial