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

     1 /*
     2  * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     8  * particular file as subject to the "Classpath" exception as provided
     9  * by Oracle in the LICENSE file that accompanied this code.
    10  *
    11  * This code is distributed in the hope that it will be useful, but WITHOUT
    12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    14  * version 2 for more details (a copy is included in the LICENSE file that
    15  * accompanied this code).
    16  *
    17  * You should have received a copy of the GNU General Public License version
    18  * 2 along with this work; if not, write to the Free Software Foundation,
    19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    20  *
    21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    22  * or visit www.oracle.com if you need additional information or have any
    23  * questions.
    24  */
    26 package com.sun.tools.doclets.internal.toolkit.builders;
    28 import com.sun.javadoc.*;
    29 import com.sun.tools.doclets.internal.toolkit.*;
    30 import com.sun.tools.doclets.internal.toolkit.util.*;
    32 /**
    33  * The factory for constructing builders.
    34  *
    35  *  <p><b>This is NOT part of any supported API.
    36  *  If you write code that depends on this, you do so at your own risk.
    37  *  This code and its internal interfaces are subject to change or
    38  *  deletion without notice.</b>
    39  *
    40  * @author Jamie Ho
    41  * @since 1.4
    42  */
    44 public class BuilderFactory {
    46     /**
    47      * The current configuration of the doclet.
    48      */
    49     private Configuration configuration;
    51     /**
    52      * The factory to retrieve the required writers from.
    53      */
    54     private WriterFactory writerFactory;
    56     /**
    57      * Construct a builder factory using the given configuration.
    58      * @param configuration the configuration for the current doclet
    59      * being executed.
    60      */
    61     public BuilderFactory (Configuration configuration) {
    62         this.configuration = configuration;
    63         this.writerFactory = configuration.getWriterFactory();
    64     }
    66     /**
    67      * Return the builder that builds the constant summary.
    68      * @return the builder that builds the constant summary.
    69      */
    70     public AbstractBuilder getConstantsSummaryBuider() throws Exception {
    71         return ConstantsSummaryBuilder.getInstance(configuration,
    72             writerFactory.getConstantsSummaryWriter());
    73     }
    75     /**
    76      * Return the builder that builds the package summary.
    77      *
    78      * @param pkg the package being documented.
    79      * @param prevPkg the previous package being documented.
    80      * @param nextPkg the next package being documented.
    81      * @return the builder that builds the constant summary.
    82      */
    83     public AbstractBuilder getPackageSummaryBuilder(PackageDoc pkg, PackageDoc prevPkg,
    84             PackageDoc nextPkg) throws Exception {
    85         return PackageSummaryBuilder.getInstance(configuration, pkg,
    86             writerFactory.getPackageSummaryWriter(pkg, prevPkg, nextPkg));
    87     }
    89     /**
    90      * Return the builder for the class.
    91      *
    92      * @param classDoc the class being documented.
    93      * @param prevClass the previous class that was documented.
    94      * @param nextClass the next class being documented.
    95      * @param classTree the class tree.
    96      * @return the writer for the class.  Return null if this
    97      * writer is not supported by the doclet.
    98      */
    99     public AbstractBuilder getClassBuilder(ClassDoc classDoc,
   100         ClassDoc prevClass, ClassDoc nextClass, ClassTree classTree)
   101             throws Exception {
   102         return ClassBuilder.getInstance(configuration, classDoc,
   103             writerFactory.getClassWriter(classDoc, prevClass, nextClass,
   104                 classTree));
   105     }
   107     /**
   108      * Return the builder for the annotation type.
   109      *
   110      * @param annotationType the annotation type being documented.
   111      * @param prevType the previous type that was documented.
   112      * @param nextType the next type being documented.
   113      * @return the writer for the annotation type.  Return null if this
   114      * writer is not supported by the doclet.
   115      */
   116     public AbstractBuilder getAnnotationTypeBuilder(
   117         AnnotationTypeDoc annotationType,
   118         Type prevType, Type nextType)
   119             throws Exception {
   120         return AnnotationTypeBuilder.getInstance(configuration, annotationType,
   121             writerFactory.getAnnotationTypeWriter(annotationType, prevType,
   122             nextType));
   123     }
   125     /**
   126      * Return an instance of the method builder for the given class.
   127      *
   128      * @return an instance of the method builder for the given class.
   129      */
   130     public AbstractBuilder getMethodBuilder(ClassWriter classWriter)
   131            throws Exception {
   132         return MethodBuilder.getInstance(configuration,
   133             classWriter.getClassDoc(),
   134             writerFactory.getMethodWriter(classWriter));
   135     }
   137     /**
   138      * Return an instance of the annotation type member builder for the given
   139      * class.
   140      *
   141      * @return an instance of the annotation type memebr builder for the given
   142      *         annotation type.
   143      */
   144     public AbstractBuilder getAnnotationTypeOptionalMemberBuilder(
   145             AnnotationTypeWriter annotationTypeWriter)
   146     throws Exception {
   147         return AnnotationTypeOptionalMemberBuilder.getInstance(configuration,
   148             annotationTypeWriter.getAnnotationTypeDoc(),
   149             writerFactory.getAnnotationTypeOptionalMemberWriter(
   150                 annotationTypeWriter));
   151     }
   153     /**
   154      * Return an instance of the annotation type member builder for the given
   155      * class.
   156      *
   157      * @return an instance of the annotation type memebr builder for the given
   158      *         annotation type.
   159      */
   160     public AbstractBuilder getAnnotationTypeRequiredMemberBuilder(
   161             AnnotationTypeWriter annotationTypeWriter)
   162     throws Exception {
   163         return AnnotationTypeRequiredMemberBuilder.getInstance(configuration,
   164             annotationTypeWriter.getAnnotationTypeDoc(),
   165             writerFactory.getAnnotationTypeRequiredMemberWriter(
   166                 annotationTypeWriter));
   167     }
   169     /**
   170      * Return an instance of the enum constants builder for the given class.
   171      *
   172      * @return an instance of the enum constants builder for the given class.
   173      */
   174     public AbstractBuilder getEnumConstantsBuilder(ClassWriter classWriter)
   175             throws Exception {
   176         return EnumConstantBuilder.getInstance(configuration, classWriter.getClassDoc(),
   177             writerFactory.getEnumConstantWriter(classWriter));
   178     }
   180     /**
   181      * Return an instance of the field builder for the given class.
   182      *
   183      * @return an instance of the field builder for the given class.
   184      */
   185     public AbstractBuilder getFieldBuilder(ClassWriter classWriter)
   186             throws Exception {
   187         return FieldBuilder.getInstance(configuration, classWriter.getClassDoc(),
   188             writerFactory.getFieldWriter(classWriter));
   189     }
   191     /**
   192      * Return an instance of the constructor builder for the given class.
   193      *
   194      * @return an instance of the constructor builder for the given class.
   195      */
   196     public AbstractBuilder getConstructorBuilder(ClassWriter classWriter)
   197             throws Exception {
   198         return ConstructorBuilder.getInstance(configuration,
   199             classWriter.getClassDoc(), writerFactory.getConstructorWriter(
   200             classWriter));
   201     }
   203     /**
   204      * Return an instance of the member summary builder for the given class.
   205      *
   206      * @return an instance of the member summary builder for the given class.
   207      */
   208     public AbstractBuilder getMemberSummaryBuilder(ClassWriter classWriter)
   209             throws Exception {
   210         return MemberSummaryBuilder.getInstance(classWriter, configuration);
   211     }
   213     /**
   214      * Return an instance of the member summary builder for the given annotation
   215      * type.
   216      *
   217      * @return an instance of the member summary builder for the given
   218      *         annotation type.
   219      */
   220     public AbstractBuilder getMemberSummaryBuilder(
   221             AnnotationTypeWriter annotationTypeWriter)
   222     throws Exception {
   223         return MemberSummaryBuilder.getInstance(annotationTypeWriter,
   224             configuration);
   225     }
   227     /**
   228      * Return the builder that builds the serialized form.
   229      *
   230      * @return the builder that builds the serialized form.
   231      */
   232     public AbstractBuilder getSerializedFormBuilder()
   233             throws Exception {
   234         return SerializedFormBuilder.getInstance(configuration);
   235     }
   236 }

mercurial