src/share/classes/com/sun/tools/doclets/formats/html/WriterFactoryImpl.java

Sat, 01 Dec 2007 00:00:00 +0000

author
duke
date
Sat, 01 Dec 2007 00:00:00 +0000
changeset 1
9a66ca7c79fa
child 140
22c4c1143a3a
permissions
-rw-r--r--

Initial load

     1 /*
     2  * Copyright 2003 Sun Microsystems, Inc.  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.  Sun designates this
     8  * particular file as subject to the "Classpath" exception as provided
     9  * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    22  * CA 95054 USA or visit www.sun.com if you need additional information or
    23  * have any questions.
    24  */
    26 package com.sun.tools.doclets.formats.html;
    28 import com.sun.tools.doclets.internal.toolkit.*;
    29 import com.sun.tools.doclets.internal.toolkit.util.*;
    30 import com.sun.javadoc.*;
    32 /**
    33  * The factory that returns HTML writers.
    34  *
    35  * @author Jamie Ho
    36  * @since 1.5
    37  */
    38 public class WriterFactoryImpl implements WriterFactory {
    40     private static WriterFactoryImpl instance;
    42     private ConfigurationImpl configuration;
    44     private WriterFactoryImpl(ConfigurationImpl configuration) {
    45         this.configuration = configuration;
    46     }
    48     /**
    49      * Return an instance of this factory.
    50      *
    51      * @return an instance of this factory.
    52      */
    53     public static WriterFactoryImpl getInstance() {
    54         if (instance == null) {
    55             instance = new WriterFactoryImpl(ConfigurationImpl.getInstance());
    56         }
    57         return instance;
    58     }
    60     /**
    61      * {@inheritDoc}
    62      */
    63     public ConstantsSummaryWriter getConstantsSummaryWriter() throws Exception {
    64         return new ConstantsSummaryWriterImpl(configuration);
    65     }
    67     /**
    68      * {@inheritDoc}
    69      */
    70     public PackageSummaryWriter getPackageSummaryWriter(PackageDoc packageDoc,
    71         PackageDoc prevPkg, PackageDoc nextPkg) throws Exception {
    72         return new PackageWriterImpl(ConfigurationImpl.getInstance(), packageDoc,
    73             prevPkg, nextPkg);
    74     }
    76     /**
    77      * {@inheritDoc}
    78      */
    79     public ClassWriter getClassWriter(ClassDoc classDoc, ClassDoc prevClass,
    80             ClassDoc nextClass, ClassTree classTree)
    81             throws Exception {
    82         return new ClassWriterImpl(classDoc, prevClass, nextClass, classTree);
    83     }
    85     /**
    86      * {@inheritDoc}
    87      */
    88     public AnnotationTypeWriter getAnnotationTypeWriter(
    89         AnnotationTypeDoc annotationType, Type prevType, Type nextType)
    90     throws Exception {
    91         return new AnnotationTypeWriterImpl(annotationType, prevType, nextType);
    92     }
    94     /**
    95      * {@inheritDoc}
    96      */
    97     public AnnotationTypeOptionalMemberWriter
    98             getAnnotationTypeOptionalMemberWriter(
    99         AnnotationTypeWriter annotationTypeWriter) throws Exception {
   100         return new AnnotationTypeOptionalMemberWriterImpl(
   101             (SubWriterHolderWriter) annotationTypeWriter,
   102             annotationTypeWriter.getAnnotationTypeDoc());
   103     }
   105     /**
   106      * {@inheritDoc}
   107      */
   108     public AnnotationTypeRequiredMemberWriter
   109             getAnnotationTypeRequiredMemberWriter(AnnotationTypeWriter annotationTypeWriter) throws Exception {
   110         return new AnnotationTypeRequiredMemberWriterImpl(
   111             (SubWriterHolderWriter) annotationTypeWriter,
   112             annotationTypeWriter.getAnnotationTypeDoc());
   113     }
   115     /**
   116      * {@inheritDoc}
   117      */
   118     public EnumConstantWriter getEnumConstantWriter(ClassWriter classWriter)
   119             throws Exception {
   120         return new EnumConstantWriterImpl((SubWriterHolderWriter) classWriter,
   121             classWriter.getClassDoc());
   122     }
   124     /**
   125      * {@inheritDoc}
   126      */
   127     public FieldWriter getFieldWriter(ClassWriter classWriter)
   128             throws Exception {
   129         return new FieldWriterImpl((SubWriterHolderWriter) classWriter,
   130             classWriter.getClassDoc());
   131     }
   133     /**
   134      * {@inheritDoc}
   135      */
   136     public  MethodWriter getMethodWriter(ClassWriter classWriter)
   137             throws Exception {
   138         return new MethodWriterImpl((SubWriterHolderWriter) classWriter,
   139             classWriter.getClassDoc());
   140     }
   142     /**
   143      * {@inheritDoc}
   144      */
   145     public ConstructorWriter getConstructorWriter(ClassWriter classWriter)
   146             throws Exception {
   147         return new ConstructorWriterImpl((SubWriterHolderWriter) classWriter,
   148             classWriter.getClassDoc());
   149     }
   151     /**
   152      * {@inheritDoc}
   153      */
   154     public MemberSummaryWriter getMemberSummaryWriter(
   155         ClassWriter classWriter, int memberType)
   156     throws Exception {
   157         switch (memberType) {
   158             case VisibleMemberMap.CONSTRUCTORS:
   159                 return (ConstructorWriterImpl) getConstructorWriter(classWriter);
   160             case VisibleMemberMap.ENUM_CONSTANTS:
   161                 return (EnumConstantWriterImpl) getEnumConstantWriter(classWriter);
   162             case VisibleMemberMap.FIELDS:
   163                 return (FieldWriterImpl) getFieldWriter(classWriter);
   164             case VisibleMemberMap.INNERCLASSES:
   165                 return new NestedClassWriterImpl((SubWriterHolderWriter)
   166                     classWriter, classWriter.getClassDoc());
   167             case VisibleMemberMap.METHODS:
   168                 return (MethodWriterImpl) getMethodWriter(classWriter);
   169             default:
   170                 return null;
   171         }
   172     }
   174     /**
   175      * {@inheritDoc}
   176      */
   177     public MemberSummaryWriter getMemberSummaryWriter(
   178         AnnotationTypeWriter annotationTypeWriter, int memberType)
   179     throws Exception {
   180         switch (memberType) {
   181             case VisibleMemberMap.ANNOTATION_TYPE_MEMBER_OPTIONAL:
   182                 return (AnnotationTypeOptionalMemberWriterImpl)
   183                     getAnnotationTypeOptionalMemberWriter(annotationTypeWriter);
   184             case VisibleMemberMap.ANNOTATION_TYPE_MEMBER_REQUIRED:
   185                 return (AnnotationTypeRequiredMemberWriterImpl)
   186                     getAnnotationTypeRequiredMemberWriter(annotationTypeWriter);
   187             default:
   188                 return null;
   189         }
   190     }
   192     /**
   193      * {@inheritDoc}
   194      */
   195     public SerializedFormWriter getSerializedFormWriter() throws Exception {
   196         return new SerializedFormWriterImpl();
   197     }
   198 }

mercurial