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

Wed, 31 Oct 2012 13:48:15 -0700

author
jjg
date
Wed, 31 Oct 2012 13:48:15 -0700
changeset 1383
b980e8e6aabf
parent 1359
25e14ad23cef
child 1410
bfec2a1cc869
permissions
-rw-r--r--

8001664: refactor javadoc to use abstraction to handle files
Reviewed-by: darcy

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

mercurial