duke@1: /* jjg@1357: * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. duke@1: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@1: * duke@1: * This code is free software; you can redistribute it and/or modify it duke@1: * under the terms of the GNU General Public License version 2 only, as ohair@554: * published by the Free Software Foundation. Oracle designates this duke@1: * particular file as subject to the "Classpath" exception as provided ohair@554: * by Oracle in the LICENSE file that accompanied this code. duke@1: * duke@1: * This code is distributed in the hope that it will be useful, but WITHOUT duke@1: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@1: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@1: * version 2 for more details (a copy is included in the LICENSE file that duke@1: * accompanied this code). duke@1: * duke@1: * You should have received a copy of the GNU General Public License version duke@1: * 2 along with this work; if not, write to the Free Software Foundation, duke@1: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@1: * ohair@554: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ohair@554: * or visit www.oracle.com if you need additional information or have any ohair@554: * questions. duke@1: */ duke@1: duke@1: package com.sun.tools.doclets.internal.toolkit.builders; duke@1: jjg@1357: import com.sun.javadoc.*; duke@1: import com.sun.tools.doclets.internal.toolkit.*; duke@1: import com.sun.tools.doclets.internal.toolkit.util.*; duke@1: duke@1: /** duke@1: * The factory for constructing builders. duke@1: * duke@1: * This code is not part of an API. duke@1: * It is implementation that is subject to change. duke@1: * Do not use it as an API duke@1: * duke@1: * @author Jamie Ho duke@1: * @since 1.4 duke@1: */ duke@1: duke@1: public class BuilderFactory { duke@1: duke@1: /** duke@1: * The current configuration of the doclet. duke@1: */ duke@1: private Configuration configuration; duke@1: duke@1: /** duke@1: * The factory to retrieve the required writers from. duke@1: */ duke@1: private WriterFactory writerFactory; duke@1: duke@1: /** duke@1: * Construct a builder factory using the given configuration. duke@1: * @param configuration the configuration for the current doclet duke@1: * being executed. duke@1: */ duke@1: public BuilderFactory (Configuration configuration) { duke@1: this.configuration = configuration; duke@1: this.writerFactory = configuration.getWriterFactory(); duke@1: } duke@1: duke@1: /** duke@1: * Return the builder that builds the constant summary. duke@1: * @return the builder that builds the constant summary. duke@1: */ duke@1: public AbstractBuilder getConstantsSummaryBuider() throws Exception { duke@1: return ConstantsSummaryBuilder.getInstance(configuration, duke@1: writerFactory.getConstantsSummaryWriter()); duke@1: } duke@1: duke@1: /** duke@1: * Return the builder that builds the package summary. duke@1: * duke@1: * @param pkg the package being documented. duke@1: * @param prevPkg the previous package being documented. duke@1: * @param nextPkg the next package being documented. duke@1: * @return the builder that builds the constant summary. duke@1: */ duke@1: public AbstractBuilder getPackageSummaryBuilder(PackageDoc pkg, PackageDoc prevPkg, duke@1: PackageDoc nextPkg) throws Exception { duke@1: return PackageSummaryBuilder.getInstance(configuration, pkg, duke@1: writerFactory.getPackageSummaryWriter(pkg, prevPkg, nextPkg)); duke@1: } duke@1: duke@1: /** duke@1: * Return the builder for the class. duke@1: * duke@1: * @param classDoc the class being documented. duke@1: * @param prevClass the previous class that was documented. duke@1: * @param nextClass the next class being documented. duke@1: * @param classTree the class tree. duke@1: * @return the writer for the class. Return null if this duke@1: * writer is not supported by the doclet. duke@1: */ duke@1: public AbstractBuilder getClassBuilder(ClassDoc classDoc, duke@1: ClassDoc prevClass, ClassDoc nextClass, ClassTree classTree) duke@1: throws Exception { duke@1: return ClassBuilder.getInstance(configuration, classDoc, duke@1: writerFactory.getClassWriter(classDoc, prevClass, nextClass, duke@1: classTree)); duke@1: } duke@1: duke@1: /** duke@1: * Return the builder for the annotation type. duke@1: * duke@1: * @param annotationType the annotation type being documented. duke@1: * @param prevType the previous type that was documented. duke@1: * @param nextType the next type being documented. duke@1: * @return the writer for the annotation type. Return null if this duke@1: * writer is not supported by the doclet. duke@1: */ duke@1: public AbstractBuilder getAnnotationTypeBuilder( duke@1: AnnotationTypeDoc annotationType, duke@1: Type prevType, Type nextType) duke@1: throws Exception { duke@1: return AnnotationTypeBuilder.getInstance(configuration, annotationType, duke@1: writerFactory.getAnnotationTypeWriter(annotationType, prevType, duke@1: nextType)); duke@1: } duke@1: duke@1: /** duke@1: * Return an instance of the method builder for the given class. duke@1: * duke@1: * @return an instance of the method builder for the given class. duke@1: */ duke@1: public AbstractBuilder getMethodBuilder(ClassWriter classWriter) duke@1: throws Exception { duke@1: return MethodBuilder.getInstance(configuration, duke@1: classWriter.getClassDoc(), duke@1: writerFactory.getMethodWriter(classWriter)); duke@1: } duke@1: duke@1: /** duke@1: * Return an instance of the annotation type member builder for the given duke@1: * class. duke@1: * duke@1: * @return an instance of the annotation type memebr builder for the given duke@1: * annotation type. duke@1: */ duke@1: public AbstractBuilder getAnnotationTypeOptionalMemberBuilder( duke@1: AnnotationTypeWriter annotationTypeWriter) duke@1: throws Exception { duke@1: return AnnotationTypeOptionalMemberBuilder.getInstance(configuration, duke@1: annotationTypeWriter.getAnnotationTypeDoc(), duke@1: writerFactory.getAnnotationTypeOptionalMemberWriter( duke@1: annotationTypeWriter)); duke@1: } duke@1: duke@1: /** duke@1: * Return an instance of the annotation type member builder for the given duke@1: * class. duke@1: * duke@1: * @return an instance of the annotation type memebr builder for the given duke@1: * annotation type. duke@1: */ duke@1: public AbstractBuilder getAnnotationTypeRequiredMemberBuilder( duke@1: AnnotationTypeWriter annotationTypeWriter) duke@1: throws Exception { duke@1: return AnnotationTypeRequiredMemberBuilder.getInstance(configuration, duke@1: annotationTypeWriter.getAnnotationTypeDoc(), duke@1: writerFactory.getAnnotationTypeRequiredMemberWriter( duke@1: annotationTypeWriter)); duke@1: } duke@1: duke@1: /** duke@1: * Return an instance of the enum constants builder for the given class. duke@1: * duke@1: * @return an instance of the enum constants builder for the given class. duke@1: */ duke@1: public AbstractBuilder getEnumConstantsBuilder(ClassWriter classWriter) duke@1: throws Exception { duke@1: return EnumConstantBuilder.getInstance(configuration, classWriter.getClassDoc(), duke@1: writerFactory.getEnumConstantWriter(classWriter)); duke@1: } duke@1: duke@1: /** duke@1: * Return an instance of the field builder for the given class. duke@1: * duke@1: * @return an instance of the field builder for the given class. duke@1: */ duke@1: public AbstractBuilder getFieldBuilder(ClassWriter classWriter) duke@1: throws Exception { duke@1: return FieldBuilder.getInstance(configuration, classWriter.getClassDoc(), duke@1: writerFactory.getFieldWriter(classWriter)); duke@1: } duke@1: duke@1: /** duke@1: * Return an instance of the constructor builder for the given class. duke@1: * duke@1: * @return an instance of the constructor builder for the given class. duke@1: */ duke@1: public AbstractBuilder getConstructorBuilder(ClassWriter classWriter) duke@1: throws Exception { duke@1: return ConstructorBuilder.getInstance(configuration, duke@1: classWriter.getClassDoc(), writerFactory.getConstructorWriter( duke@1: classWriter)); duke@1: } duke@1: duke@1: /** duke@1: * Return an instance of the member summary builder for the given class. duke@1: * duke@1: * @return an instance of the member summary builder for the given class. duke@1: */ duke@1: public AbstractBuilder getMemberSummaryBuilder(ClassWriter classWriter) duke@1: throws Exception { duke@1: return MemberSummaryBuilder.getInstance(classWriter, configuration); duke@1: } duke@1: duke@1: /** duke@1: * Return an instance of the member summary builder for the given annotation duke@1: * type. duke@1: * duke@1: * @return an instance of the member summary builder for the given duke@1: * annotation type. duke@1: */ duke@1: public AbstractBuilder getMemberSummaryBuilder( duke@1: AnnotationTypeWriter annotationTypeWriter) duke@1: throws Exception { duke@1: return MemberSummaryBuilder.getInstance(annotationTypeWriter, duke@1: configuration); duke@1: } duke@1: duke@1: /** duke@1: * Return the builder that builds the serialized form. duke@1: * duke@1: * @return the builder that builds the serialized form. duke@1: */ duke@1: public AbstractBuilder getSerializedFormBuilder() duke@1: throws Exception { duke@1: return SerializedFormBuilder.getInstance(configuration); duke@1: } duke@1: }