langtools/src/share/classes/com/sun/tools/doclets/formats/html/WriterFactoryImpl.java
author jjg
Thu, 10 Jun 2010 17:09:56 -0700
changeset 5848 c5a4ce47e780
parent 5520 86e4b9a9da40
child 14258 8d2148961366
permissions -rw-r--r--
6960407: Potential rebranding issues in openjdk/langtools repository sources Reviewed-by: darcy
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1652
diff changeset
     2
 * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
06bc494ca11e Initial load
duke
parents:
diff changeset
     4
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
06bc494ca11e Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1652
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1652
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    10
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
06bc494ca11e Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
06bc494ca11e Initial load
duke
parents:
diff changeset
    20
 *
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1652
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1652
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1652
diff changeset
    23
 * questions.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
06bc494ca11e Initial load
duke
parents:
diff changeset
    26
package com.sun.tools.doclets.formats.html;
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
import com.sun.tools.doclets.internal.toolkit.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
import com.sun.tools.doclets.internal.toolkit.util.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
import com.sun.javadoc.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
 * The factory that returns HTML writers.
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
 * @author Jamie Ho
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
 * @since 1.5
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
public class WriterFactoryImpl implements WriterFactory {
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
    private ConfigurationImpl configuration;
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
1475
19c0851667ca 6748541: javadoc should be reusable
jjg
parents: 10
diff changeset
    42
    public WriterFactoryImpl(ConfigurationImpl configuration) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
        this.configuration = configuration;
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
    public ConstantsSummaryWriter getConstantsSummaryWriter() throws Exception {
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
        return new ConstantsSummaryWriterImpl(configuration);
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
    public PackageSummaryWriter getPackageSummaryWriter(PackageDoc packageDoc,
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
        PackageDoc prevPkg, PackageDoc nextPkg) throws Exception {
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
        return new PackageWriterImpl(ConfigurationImpl.getInstance(), packageDoc,
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
            prevPkg, nextPkg);
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
    public ClassWriter getClassWriter(ClassDoc classDoc, ClassDoc prevClass,
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
            ClassDoc nextClass, ClassTree classTree)
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
            throws Exception {
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
        return new ClassWriterImpl(classDoc, prevClass, nextClass, classTree);
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
    public AnnotationTypeWriter getAnnotationTypeWriter(
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
        AnnotationTypeDoc annotationType, Type prevType, Type nextType)
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
    throws Exception {
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
        return new AnnotationTypeWriterImpl(annotationType, prevType, nextType);
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
    public AnnotationTypeOptionalMemberWriter
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
            getAnnotationTypeOptionalMemberWriter(
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
        AnnotationTypeWriter annotationTypeWriter) throws Exception {
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
        return new AnnotationTypeOptionalMemberWriterImpl(
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
            (SubWriterHolderWriter) annotationTypeWriter,
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
            annotationTypeWriter.getAnnotationTypeDoc());
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
    public AnnotationTypeRequiredMemberWriter
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
            getAnnotationTypeRequiredMemberWriter(AnnotationTypeWriter annotationTypeWriter) throws Exception {
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
        return new AnnotationTypeRequiredMemberWriterImpl(
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
            (SubWriterHolderWriter) annotationTypeWriter,
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
            annotationTypeWriter.getAnnotationTypeDoc());
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
    public EnumConstantWriter getEnumConstantWriter(ClassWriter classWriter)
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
            throws Exception {
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
        return new EnumConstantWriterImpl((SubWriterHolderWriter) classWriter,
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
            classWriter.getClassDoc());
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
    public FieldWriter getFieldWriter(ClassWriter classWriter)
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
            throws Exception {
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
        return new FieldWriterImpl((SubWriterHolderWriter) classWriter,
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
            classWriter.getClassDoc());
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
    public  MethodWriter getMethodWriter(ClassWriter classWriter)
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
            throws Exception {
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
        return new MethodWriterImpl((SubWriterHolderWriter) classWriter,
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
            classWriter.getClassDoc());
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
    public ConstructorWriter getConstructorWriter(ClassWriter classWriter)
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
            throws Exception {
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
        return new ConstructorWriterImpl((SubWriterHolderWriter) classWriter,
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
            classWriter.getClassDoc());
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
    public MemberSummaryWriter getMemberSummaryWriter(
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
        ClassWriter classWriter, int memberType)
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
    throws Exception {
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
        switch (memberType) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
            case VisibleMemberMap.CONSTRUCTORS:
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
                return (ConstructorWriterImpl) getConstructorWriter(classWriter);
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
            case VisibleMemberMap.ENUM_CONSTANTS:
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
                return (EnumConstantWriterImpl) getEnumConstantWriter(classWriter);
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
            case VisibleMemberMap.FIELDS:
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
                return (FieldWriterImpl) getFieldWriter(classWriter);
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
            case VisibleMemberMap.INNERCLASSES:
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
                return new NestedClassWriterImpl((SubWriterHolderWriter)
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
                    classWriter, classWriter.getClassDoc());
06bc494ca11e Initial load
duke
parents:
diff changeset
   153
            case VisibleMemberMap.METHODS:
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
                return (MethodWriterImpl) getMethodWriter(classWriter);
06bc494ca11e Initial load
duke
parents:
diff changeset
   155
            default:
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
                return null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   163
    public MemberSummaryWriter getMemberSummaryWriter(
06bc494ca11e Initial load
duke
parents:
diff changeset
   164
        AnnotationTypeWriter annotationTypeWriter, int memberType)
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
    throws Exception {
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
        switch (memberType) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
            case VisibleMemberMap.ANNOTATION_TYPE_MEMBER_OPTIONAL:
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
                return (AnnotationTypeOptionalMemberWriterImpl)
06bc494ca11e Initial load
duke
parents:
diff changeset
   169
                    getAnnotationTypeOptionalMemberWriter(annotationTypeWriter);
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
            case VisibleMemberMap.ANNOTATION_TYPE_MEMBER_REQUIRED:
06bc494ca11e Initial load
duke
parents:
diff changeset
   171
                return (AnnotationTypeRequiredMemberWriterImpl)
06bc494ca11e Initial load
duke
parents:
diff changeset
   172
                    getAnnotationTypeRequiredMemberWriter(annotationTypeWriter);
06bc494ca11e Initial load
duke
parents:
diff changeset
   173
            default:
06bc494ca11e Initial load
duke
parents:
diff changeset
   174
                return null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   175
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   176
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   177
06bc494ca11e Initial load
duke
parents:
diff changeset
   178
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   179
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
    public SerializedFormWriter getSerializedFormWriter() throws Exception {
06bc494ca11e Initial load
duke
parents:
diff changeset
   182
        return new SerializedFormWriterImpl();
06bc494ca11e Initial load
duke
parents:
diff changeset
   183
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   184
}