Mon, 21 Jan 2013 00:45:35 -0500
8006124: javadoc/doclet should be updated to support profiles
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 | /** |
duke@1 | 177 | * Return an instance of the annotation type member builder for the given |
duke@1 | 178 | * class. |
duke@1 | 179 | * |
duke@1 | 180 | * @return an instance of the annotation type memebr builder for the given |
duke@1 | 181 | * annotation type. |
duke@1 | 182 | */ |
duke@1 | 183 | public AbstractBuilder getAnnotationTypeOptionalMemberBuilder( |
duke@1 | 184 | AnnotationTypeWriter annotationTypeWriter) |
duke@1 | 185 | throws Exception { |
jjg@1410 | 186 | return AnnotationTypeOptionalMemberBuilder.getInstance(context, |
duke@1 | 187 | annotationTypeWriter.getAnnotationTypeDoc(), |
duke@1 | 188 | writerFactory.getAnnotationTypeOptionalMemberWriter( |
duke@1 | 189 | annotationTypeWriter)); |
duke@1 | 190 | } |
duke@1 | 191 | |
duke@1 | 192 | /** |
duke@1 | 193 | * Return an instance of the annotation type member builder for the given |
duke@1 | 194 | * class. |
duke@1 | 195 | * |
duke@1 | 196 | * @return an instance of the annotation type memebr builder for the given |
duke@1 | 197 | * annotation type. |
duke@1 | 198 | */ |
duke@1 | 199 | public AbstractBuilder getAnnotationTypeRequiredMemberBuilder( |
duke@1 | 200 | AnnotationTypeWriter annotationTypeWriter) |
duke@1 | 201 | throws Exception { |
jjg@1410 | 202 | return AnnotationTypeRequiredMemberBuilder.getInstance(context, |
duke@1 | 203 | annotationTypeWriter.getAnnotationTypeDoc(), |
duke@1 | 204 | writerFactory.getAnnotationTypeRequiredMemberWriter( |
duke@1 | 205 | annotationTypeWriter)); |
duke@1 | 206 | } |
duke@1 | 207 | |
duke@1 | 208 | /** |
duke@1 | 209 | * Return an instance of the enum constants builder for the given class. |
duke@1 | 210 | * |
duke@1 | 211 | * @return an instance of the enum constants builder for the given class. |
duke@1 | 212 | */ |
duke@1 | 213 | public AbstractBuilder getEnumConstantsBuilder(ClassWriter classWriter) |
duke@1 | 214 | throws Exception { |
jjg@1410 | 215 | return EnumConstantBuilder.getInstance(context, classWriter.getClassDoc(), |
duke@1 | 216 | writerFactory.getEnumConstantWriter(classWriter)); |
duke@1 | 217 | } |
duke@1 | 218 | |
duke@1 | 219 | /** |
duke@1 | 220 | * Return an instance of the field builder for the given class. |
duke@1 | 221 | * |
duke@1 | 222 | * @return an instance of the field builder for the given class. |
duke@1 | 223 | */ |
duke@1 | 224 | public AbstractBuilder getFieldBuilder(ClassWriter classWriter) |
duke@1 | 225 | throws Exception { |
jjg@1410 | 226 | return FieldBuilder.getInstance(context, classWriter.getClassDoc(), |
duke@1 | 227 | writerFactory.getFieldWriter(classWriter)); |
duke@1 | 228 | } |
duke@1 | 229 | |
duke@1 | 230 | /** |
duke@1 | 231 | * Return an instance of the constructor builder for the given class. |
duke@1 | 232 | * |
duke@1 | 233 | * @return an instance of the constructor builder for the given class. |
duke@1 | 234 | */ |
duke@1 | 235 | public AbstractBuilder getConstructorBuilder(ClassWriter classWriter) |
duke@1 | 236 | throws Exception { |
jjg@1410 | 237 | return ConstructorBuilder.getInstance(context, |
jjg@1410 | 238 | classWriter.getClassDoc(), |
jjg@1410 | 239 | writerFactory.getConstructorWriter(classWriter)); |
duke@1 | 240 | } |
duke@1 | 241 | |
duke@1 | 242 | /** |
duke@1 | 243 | * Return an instance of the member summary builder for the given class. |
duke@1 | 244 | * |
duke@1 | 245 | * @return an instance of the member summary builder for the given class. |
duke@1 | 246 | */ |
duke@1 | 247 | public AbstractBuilder getMemberSummaryBuilder(ClassWriter classWriter) |
duke@1 | 248 | throws Exception { |
jjg@1410 | 249 | return MemberSummaryBuilder.getInstance(classWriter, context); |
duke@1 | 250 | } |
duke@1 | 251 | |
duke@1 | 252 | /** |
duke@1 | 253 | * Return an instance of the member summary builder for the given annotation |
duke@1 | 254 | * type. |
duke@1 | 255 | * |
duke@1 | 256 | * @return an instance of the member summary builder for the given |
duke@1 | 257 | * annotation type. |
duke@1 | 258 | */ |
duke@1 | 259 | public AbstractBuilder getMemberSummaryBuilder( |
duke@1 | 260 | AnnotationTypeWriter annotationTypeWriter) |
duke@1 | 261 | throws Exception { |
jjg@1410 | 262 | return MemberSummaryBuilder.getInstance(annotationTypeWriter, context); |
duke@1 | 263 | } |
duke@1 | 264 | |
duke@1 | 265 | /** |
duke@1 | 266 | * Return the builder that builds the serialized form. |
duke@1 | 267 | * |
duke@1 | 268 | * @return the builder that builds the serialized form. |
duke@1 | 269 | */ |
duke@1 | 270 | public AbstractBuilder getSerializedFormBuilder() |
duke@1 | 271 | throws Exception { |
jjg@1410 | 272 | return SerializedFormBuilder.getInstance(context); |
duke@1 | 273 | } |
duke@1 | 274 | } |