duke@1: /* bpatel@1568: * Copyright (c) 2003, 2013, 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@1410: import java.util.HashSet; jjg@1410: import java.util.Set; jjg@1410: jjg@1357: import com.sun.javadoc.*; bpatel@1568: import com.sun.tools.javac.jvm.Profile; 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: * jjg@1359: *

This is NOT part of any supported API. jjg@1359: * If you write code that depends on this, you do so at your own risk. jjg@1359: * This code and its internal interfaces are subject to change or jjg@1359: * deletion without notice. 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: */ jjg@1410: private final Configuration configuration; duke@1: duke@1: /** duke@1: * The factory to retrieve the required writers from. duke@1: */ jjg@1410: private final WriterFactory writerFactory; jjg@1410: jjg@1410: private final AbstractBuilder.Context context; 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(); jjg@1410: jjg@1410: Set containingPackagesSeen = new HashSet(); jjg@1410: context = new AbstractBuilder.Context(configuration, containingPackagesSeen, jjg@1410: LayoutParser.getInstance(configuration)); 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 { jjg@1410: return ConstantsSummaryBuilder.getInstance(context, 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 { jjg@1410: return PackageSummaryBuilder.getInstance(context, pkg, duke@1: writerFactory.getPackageSummaryWriter(pkg, prevPkg, nextPkg)); duke@1: } duke@1: duke@1: /** bpatel@1568: * Return the builder that builds the profile summary. bpatel@1568: * bpatel@1568: * @param profile the profile being documented. bpatel@1568: * @param prevProfile the previous profile being documented. bpatel@1568: * @param nextProfile the next profile being documented. bpatel@1568: * @return the builder that builds the profile summary. bpatel@1568: */ bpatel@1568: public AbstractBuilder getProfileSummaryBuilder(Profile profile, Profile prevProfile, bpatel@1568: Profile nextProfile) throws Exception { bpatel@1568: return ProfileSummaryBuilder.getInstance(context, profile, bpatel@1568: writerFactory.getProfileSummaryWriter(profile, prevProfile, nextProfile)); bpatel@1568: } bpatel@1568: bpatel@1568: /** bpatel@1568: * Return the builder that builds the profile package summary. bpatel@1568: * bpatel@1568: * @param pkg the profile package being documented. bpatel@1568: * @param prevPkg the previous profile package being documented. bpatel@1568: * @param nextPkg the next profile package being documented. bpatel@1568: * @param profile the profile being documented. bpatel@1568: * @return the builder that builds the profile package summary. bpatel@1568: */ bpatel@1568: public AbstractBuilder getProfilePackageSummaryBuilder(PackageDoc pkg, PackageDoc prevPkg, bpatel@1568: PackageDoc nextPkg, Profile profile) throws Exception { bpatel@1568: return ProfilePackageSummaryBuilder.getInstance(context, pkg, bpatel@1568: writerFactory.getProfilePackageSummaryWriter(pkg, prevPkg, nextPkg, bpatel@1568: profile), profile); bpatel@1568: } bpatel@1568: bpatel@1568: /** 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, jjg@1410: ClassDoc prevClass, ClassDoc nextClass, ClassTree classTree) duke@1: throws Exception { jjg@1410: return ClassBuilder.getInstance(context, 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 { jjg@1410: return AnnotationTypeBuilder.getInstance(context, annotationType, jjg@1410: writerFactory.getAnnotationTypeWriter(annotationType, prevType, 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 { jjg@1410: return MethodBuilder.getInstance(context, duke@1: classWriter.getClassDoc(), duke@1: writerFactory.getMethodWriter(classWriter)); duke@1: } duke@1: duke@1: /** bpatel@2035: * Return an instance of the annotation type fields builder for the given bpatel@2035: * class. bpatel@2035: * bpatel@2035: * @return an instance of the annotation type field builder for the given bpatel@2035: * annotation type. bpatel@2035: */ bpatel@2035: public AbstractBuilder getAnnotationTypeFieldsBuilder( bpatel@2035: AnnotationTypeWriter annotationTypeWriter) bpatel@2035: throws Exception { bpatel@2035: return AnnotationTypeFieldBuilder.getInstance(context, bpatel@2035: annotationTypeWriter.getAnnotationTypeDoc(), bpatel@2035: writerFactory.getAnnotationTypeFieldWriter( bpatel@2035: annotationTypeWriter)); bpatel@2035: } bpatel@2035: bpatel@2035: /** duke@1: * Return an instance of the annotation type member builder for the given duke@1: * class. duke@1: * bpatel@2035: * @return an instance of the annotation type member builder for the given duke@1: * annotation type. duke@1: */ duke@1: public AbstractBuilder getAnnotationTypeOptionalMemberBuilder( duke@1: AnnotationTypeWriter annotationTypeWriter) duke@1: throws Exception { jjg@1410: return AnnotationTypeOptionalMemberBuilder.getInstance(context, 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: * bpatel@2035: * @return an instance of the annotation type member builder for the given duke@1: * annotation type. duke@1: */ duke@1: public AbstractBuilder getAnnotationTypeRequiredMemberBuilder( duke@1: AnnotationTypeWriter annotationTypeWriter) duke@1: throws Exception { jjg@1410: return AnnotationTypeRequiredMemberBuilder.getInstance(context, 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 { jjg@1410: return EnumConstantBuilder.getInstance(context, 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 { jjg@1410: return FieldBuilder.getInstance(context, classWriter.getClassDoc(), duke@1: writerFactory.getFieldWriter(classWriter)); duke@1: } duke@1: duke@1: /** jjg@1606: * Return an instance of the property builder for the given class. jjg@1606: * jjg@1606: * @return an instance of the field builder for the given class. jjg@1606: */ jjg@1606: public AbstractBuilder getPropertyBuilder(ClassWriter classWriter) throws Exception { jjg@1606: final PropertyWriter propertyWriter = jjg@1606: writerFactory.getPropertyWriter(classWriter); jjg@1606: return PropertyBuilder.getInstance(context, jjg@1606: classWriter.getClassDoc(), jjg@1606: propertyWriter); jjg@1606: } jjg@1606: jjg@1606: /** 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 { jjg@1410: return ConstructorBuilder.getInstance(context, jjg@1410: classWriter.getClassDoc(), jjg@1410: writerFactory.getConstructorWriter(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 { jjg@1410: return MemberSummaryBuilder.getInstance(classWriter, context); 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 { jjg@1410: return MemberSummaryBuilder.getInstance(annotationTypeWriter, context); 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 { jjg@1410: return SerializedFormBuilder.getInstance(context); duke@1: } duke@1: }