Thu, 15 Nov 2012 09:18:36 -0800
8000800: javadoc uses static non-final fields
Reviewed-by: bpatel
duke@1 | 1 | /* |
jjg@1357 | 2 | * Copyright (c) 2003, 2012, 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.*; |
duke@1 | 32 | import com.sun.tools.doclets.internal.toolkit.*; |
duke@1 | 33 | import com.sun.tools.doclets.internal.toolkit.util.*; |
duke@1 | 34 | |
duke@1 | 35 | /** |
duke@1 | 36 | * The factory for constructing builders. |
duke@1 | 37 | * |
jjg@1359 | 38 | * <p><b>This is NOT part of any supported API. |
jjg@1359 | 39 | * If you write code that depends on this, you do so at your own risk. |
jjg@1359 | 40 | * This code and its internal interfaces are subject to change or |
jjg@1359 | 41 | * deletion without notice.</b> |
duke@1 | 42 | * |
duke@1 | 43 | * @author Jamie Ho |
duke@1 | 44 | * @since 1.4 |
duke@1 | 45 | */ |
duke@1 | 46 | |
duke@1 | 47 | public class BuilderFactory { |
duke@1 | 48 | |
duke@1 | 49 | /** |
duke@1 | 50 | * The current configuration of the doclet. |
duke@1 | 51 | */ |
jjg@1410 | 52 | private final Configuration configuration; |
duke@1 | 53 | |
duke@1 | 54 | /** |
duke@1 | 55 | * The factory to retrieve the required writers from. |
duke@1 | 56 | */ |
jjg@1410 | 57 | private final WriterFactory writerFactory; |
jjg@1410 | 58 | |
jjg@1410 | 59 | private final AbstractBuilder.Context context; |
duke@1 | 60 | |
duke@1 | 61 | /** |
duke@1 | 62 | * Construct a builder factory using the given configuration. |
duke@1 | 63 | * @param configuration the configuration for the current doclet |
duke@1 | 64 | * being executed. |
duke@1 | 65 | */ |
duke@1 | 66 | public BuilderFactory (Configuration configuration) { |
duke@1 | 67 | this.configuration = configuration; |
duke@1 | 68 | this.writerFactory = configuration.getWriterFactory(); |
jjg@1410 | 69 | |
jjg@1410 | 70 | Set<String> containingPackagesSeen = new HashSet<String>(); |
jjg@1410 | 71 | context = new AbstractBuilder.Context(configuration, containingPackagesSeen, |
jjg@1410 | 72 | LayoutParser.getInstance(configuration)); |
duke@1 | 73 | } |
duke@1 | 74 | |
duke@1 | 75 | /** |
duke@1 | 76 | * Return the builder that builds the constant summary. |
duke@1 | 77 | * @return the builder that builds the constant summary. |
duke@1 | 78 | */ |
duke@1 | 79 | public AbstractBuilder getConstantsSummaryBuider() throws Exception { |
jjg@1410 | 80 | return ConstantsSummaryBuilder.getInstance(context, |
duke@1 | 81 | writerFactory.getConstantsSummaryWriter()); |
duke@1 | 82 | } |
duke@1 | 83 | |
duke@1 | 84 | /** |
duke@1 | 85 | * Return the builder that builds the package summary. |
duke@1 | 86 | * |
duke@1 | 87 | * @param pkg the package being documented. |
duke@1 | 88 | * @param prevPkg the previous package being documented. |
duke@1 | 89 | * @param nextPkg the next package being documented. |
duke@1 | 90 | * @return the builder that builds the constant summary. |
duke@1 | 91 | */ |
duke@1 | 92 | public AbstractBuilder getPackageSummaryBuilder(PackageDoc pkg, PackageDoc prevPkg, |
duke@1 | 93 | PackageDoc nextPkg) throws Exception { |
jjg@1410 | 94 | return PackageSummaryBuilder.getInstance(context, pkg, |
duke@1 | 95 | writerFactory.getPackageSummaryWriter(pkg, prevPkg, nextPkg)); |
duke@1 | 96 | } |
duke@1 | 97 | |
duke@1 | 98 | /** |
duke@1 | 99 | * Return the builder for the class. |
duke@1 | 100 | * |
duke@1 | 101 | * @param classDoc the class being documented. |
duke@1 | 102 | * @param prevClass the previous class that was documented. |
duke@1 | 103 | * @param nextClass the next class being documented. |
duke@1 | 104 | * @param classTree the class tree. |
duke@1 | 105 | * @return the writer for the class. Return null if this |
duke@1 | 106 | * writer is not supported by the doclet. |
duke@1 | 107 | */ |
duke@1 | 108 | public AbstractBuilder getClassBuilder(ClassDoc classDoc, |
jjg@1410 | 109 | ClassDoc prevClass, ClassDoc nextClass, ClassTree classTree) |
duke@1 | 110 | throws Exception { |
jjg@1410 | 111 | return ClassBuilder.getInstance(context, classDoc, |
duke@1 | 112 | writerFactory.getClassWriter(classDoc, prevClass, nextClass, |
duke@1 | 113 | classTree)); |
duke@1 | 114 | } |
duke@1 | 115 | |
duke@1 | 116 | /** |
duke@1 | 117 | * Return the builder for the annotation type. |
duke@1 | 118 | * |
duke@1 | 119 | * @param annotationType the annotation type being documented. |
duke@1 | 120 | * @param prevType the previous type that was documented. |
duke@1 | 121 | * @param nextType the next type being documented. |
duke@1 | 122 | * @return the writer for the annotation type. Return null if this |
duke@1 | 123 | * writer is not supported by the doclet. |
duke@1 | 124 | */ |
duke@1 | 125 | public AbstractBuilder getAnnotationTypeBuilder( |
duke@1 | 126 | AnnotationTypeDoc annotationType, |
duke@1 | 127 | Type prevType, Type nextType) |
duke@1 | 128 | throws Exception { |
jjg@1410 | 129 | return AnnotationTypeBuilder.getInstance(context, annotationType, |
jjg@1410 | 130 | writerFactory.getAnnotationTypeWriter(annotationType, prevType, nextType)); |
duke@1 | 131 | } |
duke@1 | 132 | |
duke@1 | 133 | /** |
duke@1 | 134 | * Return an instance of the method builder for the given class. |
duke@1 | 135 | * |
duke@1 | 136 | * @return an instance of the method builder for the given class. |
duke@1 | 137 | */ |
duke@1 | 138 | public AbstractBuilder getMethodBuilder(ClassWriter classWriter) |
duke@1 | 139 | throws Exception { |
jjg@1410 | 140 | return MethodBuilder.getInstance(context, |
duke@1 | 141 | classWriter.getClassDoc(), |
duke@1 | 142 | writerFactory.getMethodWriter(classWriter)); |
duke@1 | 143 | } |
duke@1 | 144 | |
duke@1 | 145 | /** |
duke@1 | 146 | * Return an instance of the annotation type member builder for the given |
duke@1 | 147 | * class. |
duke@1 | 148 | * |
duke@1 | 149 | * @return an instance of the annotation type memebr builder for the given |
duke@1 | 150 | * annotation type. |
duke@1 | 151 | */ |
duke@1 | 152 | public AbstractBuilder getAnnotationTypeOptionalMemberBuilder( |
duke@1 | 153 | AnnotationTypeWriter annotationTypeWriter) |
duke@1 | 154 | throws Exception { |
jjg@1410 | 155 | return AnnotationTypeOptionalMemberBuilder.getInstance(context, |
duke@1 | 156 | annotationTypeWriter.getAnnotationTypeDoc(), |
duke@1 | 157 | writerFactory.getAnnotationTypeOptionalMemberWriter( |
duke@1 | 158 | annotationTypeWriter)); |
duke@1 | 159 | } |
duke@1 | 160 | |
duke@1 | 161 | /** |
duke@1 | 162 | * Return an instance of the annotation type member builder for the given |
duke@1 | 163 | * class. |
duke@1 | 164 | * |
duke@1 | 165 | * @return an instance of the annotation type memebr builder for the given |
duke@1 | 166 | * annotation type. |
duke@1 | 167 | */ |
duke@1 | 168 | public AbstractBuilder getAnnotationTypeRequiredMemberBuilder( |
duke@1 | 169 | AnnotationTypeWriter annotationTypeWriter) |
duke@1 | 170 | throws Exception { |
jjg@1410 | 171 | return AnnotationTypeRequiredMemberBuilder.getInstance(context, |
duke@1 | 172 | annotationTypeWriter.getAnnotationTypeDoc(), |
duke@1 | 173 | writerFactory.getAnnotationTypeRequiredMemberWriter( |
duke@1 | 174 | annotationTypeWriter)); |
duke@1 | 175 | } |
duke@1 | 176 | |
duke@1 | 177 | /** |
duke@1 | 178 | * Return an instance of the enum constants builder for the given class. |
duke@1 | 179 | * |
duke@1 | 180 | * @return an instance of the enum constants builder for the given class. |
duke@1 | 181 | */ |
duke@1 | 182 | public AbstractBuilder getEnumConstantsBuilder(ClassWriter classWriter) |
duke@1 | 183 | throws Exception { |
jjg@1410 | 184 | return EnumConstantBuilder.getInstance(context, classWriter.getClassDoc(), |
duke@1 | 185 | writerFactory.getEnumConstantWriter(classWriter)); |
duke@1 | 186 | } |
duke@1 | 187 | |
duke@1 | 188 | /** |
duke@1 | 189 | * Return an instance of the field builder for the given class. |
duke@1 | 190 | * |
duke@1 | 191 | * @return an instance of the field builder for the given class. |
duke@1 | 192 | */ |
duke@1 | 193 | public AbstractBuilder getFieldBuilder(ClassWriter classWriter) |
duke@1 | 194 | throws Exception { |
jjg@1410 | 195 | return FieldBuilder.getInstance(context, classWriter.getClassDoc(), |
duke@1 | 196 | writerFactory.getFieldWriter(classWriter)); |
duke@1 | 197 | } |
duke@1 | 198 | |
duke@1 | 199 | /** |
duke@1 | 200 | * Return an instance of the constructor builder for the given class. |
duke@1 | 201 | * |
duke@1 | 202 | * @return an instance of the constructor builder for the given class. |
duke@1 | 203 | */ |
duke@1 | 204 | public AbstractBuilder getConstructorBuilder(ClassWriter classWriter) |
duke@1 | 205 | throws Exception { |
jjg@1410 | 206 | return ConstructorBuilder.getInstance(context, |
jjg@1410 | 207 | classWriter.getClassDoc(), |
jjg@1410 | 208 | writerFactory.getConstructorWriter(classWriter)); |
duke@1 | 209 | } |
duke@1 | 210 | |
duke@1 | 211 | /** |
duke@1 | 212 | * Return an instance of the member summary builder for the given class. |
duke@1 | 213 | * |
duke@1 | 214 | * @return an instance of the member summary builder for the given class. |
duke@1 | 215 | */ |
duke@1 | 216 | public AbstractBuilder getMemberSummaryBuilder(ClassWriter classWriter) |
duke@1 | 217 | throws Exception { |
jjg@1410 | 218 | return MemberSummaryBuilder.getInstance(classWriter, context); |
duke@1 | 219 | } |
duke@1 | 220 | |
duke@1 | 221 | /** |
duke@1 | 222 | * Return an instance of the member summary builder for the given annotation |
duke@1 | 223 | * type. |
duke@1 | 224 | * |
duke@1 | 225 | * @return an instance of the member summary builder for the given |
duke@1 | 226 | * annotation type. |
duke@1 | 227 | */ |
duke@1 | 228 | public AbstractBuilder getMemberSummaryBuilder( |
duke@1 | 229 | AnnotationTypeWriter annotationTypeWriter) |
duke@1 | 230 | throws Exception { |
jjg@1410 | 231 | return MemberSummaryBuilder.getInstance(annotationTypeWriter, context); |
duke@1 | 232 | } |
duke@1 | 233 | |
duke@1 | 234 | /** |
duke@1 | 235 | * Return the builder that builds the serialized form. |
duke@1 | 236 | * |
duke@1 | 237 | * @return the builder that builds the serialized form. |
duke@1 | 238 | */ |
duke@1 | 239 | public AbstractBuilder getSerializedFormBuilder() |
duke@1 | 240 | throws Exception { |
jjg@1410 | 241 | return SerializedFormBuilder.getInstance(context); |
duke@1 | 242 | } |
duke@1 | 243 | } |