langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MemberSummaryBuilder.java
author jjg
Tue, 15 Jul 2008 19:22:51 -0700
changeset 868 d0f233085cbb
parent 10 06bc494ca11e
child 1264 076a3cde30d5
permissions -rw-r--r--
6657907: javadoc has unchecked warnings Reviewed-by: bpatel
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
06bc494ca11e Initial load
duke
parents:
diff changeset
     2
 * Copyright 2003-2004 Sun Microsystems, Inc.  All Rights Reserved.
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
06bc494ca11e Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
06bc494ca11e Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
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
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
06bc494ca11e Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
06bc494ca11e Initial load
duke
parents:
diff changeset
    23
 * have any questions.
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.internal.toolkit.builders;
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
import com.sun.tools.doclets.internal.toolkit.util.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
import com.sun.tools.doclets.internal.toolkit.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
import com.sun.javadoc.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
import java.util.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
import java.lang.reflect.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
 * Builds the member summary.
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
 * This code is not part of an API.
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
 * It is implementation that is subject to change.
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
 * Do not use it as an API
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
 * @author Jamie Ho
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
 * @since 1.5
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
public class MemberSummaryBuilder extends AbstractMemberBuilder {
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
        /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
         * The XML root for this builder.
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
         */
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
        public static final String NAME = "MemberSummary";
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
        /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
         * The visible members for the given class.
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
         */
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
        private VisibleMemberMap[] visibleMemberMaps;
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
        /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
         * The member summary writers for the given class.
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
         */
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
        private MemberSummaryWriter[] memberSummaryWriters;
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
        /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
         * The type being documented.
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
         */
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
        private ClassDoc classDoc;
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
        private MemberSummaryBuilder(Configuration configuration) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
                super(configuration);
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
        /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
         * Construct a new MemberSummaryBuilder.
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
         *
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
         * @param classWriter   the writer for the class whose members are being
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
         *                      summarized.
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
         * @param configuration the current configuration of the doclet.
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
         */
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
        public static MemberSummaryBuilder getInstance(
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
                ClassWriter classWriter, Configuration configuration)
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
        throws Exception {
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
                MemberSummaryBuilder builder = new MemberSummaryBuilder(configuration);
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
                builder.classDoc = classWriter.getClassDoc();
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
                builder.init(classWriter);
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
                return builder;
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
     * Construct a new MemberSummaryBuilder.
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
     * @param annotationTypeWriter the writer for the class whose members are
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
     *                             being summarized.
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
     * @param configuration the current configuration of the doclet.
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
    public static MemberSummaryBuilder getInstance(
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
        AnnotationTypeWriter annotationTypeWriter, Configuration configuration)
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
    throws Exception {
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
        MemberSummaryBuilder builder = new MemberSummaryBuilder(configuration);
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
        builder.classDoc = annotationTypeWriter.getAnnotationTypeDoc();
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
        builder.init(annotationTypeWriter);
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
        return builder;
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
    private void init(Object writer) throws Exception {
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
        visibleMemberMaps =
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
            new VisibleMemberMap[VisibleMemberMap.NUM_MEMBER_TYPES];
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
        for (int i = 0; i < VisibleMemberMap.NUM_MEMBER_TYPES; i++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
            visibleMemberMaps[i] =
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
                new VisibleMemberMap(
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
                    classDoc,
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
                    i,
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
                    configuration.nodeprecated);
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
        memberSummaryWriters =
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
            new MemberSummaryWriter[VisibleMemberMap.NUM_MEMBER_TYPES];
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
        for (int i = 0; i < VisibleMemberMap.NUM_MEMBER_TYPES; i++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
            if (classDoc.isAnnotationType()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
                memberSummaryWriters[i] =
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
                    visibleMemberMaps[i].noVisibleMembers()?
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
                        null :
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
                        configuration.getWriterFactory().getMemberSummaryWriter(
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
                            (AnnotationTypeWriter) writer, i);
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
            } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
                memberSummaryWriters[i] =
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
                    visibleMemberMaps[i].noVisibleMembers()?
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
                        null :
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
                        configuration.getWriterFactory().getMemberSummaryWriter(
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
                            (ClassWriter) writer, i);
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
        /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
         * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
         */
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
        public String getName() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
                return NAME;
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
        /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
         * Return the specified visible member map.
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
         *
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
         * @param type the type of visible member map to return.
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
         * @return the specified visible member map.
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
         * @throws ArrayIndexOutOfBoundsException when the type is invalid.
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
         * @see VisibleMemberMap
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
         */
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
        public VisibleMemberMap getVisibleMemberMap(int type) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
                return visibleMemberMaps[type];
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
        /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
         * Return the specified member summary writer.
06bc494ca11e Initial load
duke
parents:
diff changeset
   153
         *
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
         * @param type the type of member summary writer to return.
06bc494ca11e Initial load
duke
parents:
diff changeset
   155
         * @return the specified member summary writer.
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
         * @throws ArrayIndexOutOfBoundsException when the type is invalid.
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
         * @see VisibleMemberMap
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
         */
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
        public MemberSummaryWriter getMemberSummaryWriter(int type) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
                return memberSummaryWriters[type];
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
06bc494ca11e Initial load
duke
parents:
diff changeset
   163
        /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   164
         * Returns a list of methods that will be documented for the given class.
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
         * This information can be used for doclet specific documentation
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
         * generation.
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
         *
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
         * @param classDoc the {@link ClassDoc} we want to check.
06bc494ca11e Initial load
duke
parents:
diff changeset
   169
         * @param type the type of members to return.
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
         * @return a list of methods that will be documented.
06bc494ca11e Initial load
duke
parents:
diff changeset
   171
         * @see VisibleMemberMap
06bc494ca11e Initial load
duke
parents:
diff changeset
   172
         */
06bc494ca11e Initial load
duke
parents:
diff changeset
   173
        public List members(int type) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   174
                return visibleMemberMaps[type].getLeafClassMembers(configuration);
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
         * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   179
         */
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
        public void invokeMethod(
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
                String methodName,
06bc494ca11e Initial load
duke
parents:
diff changeset
   182
                Class[] paramClasses,
06bc494ca11e Initial load
duke
parents:
diff changeset
   183
                Object[] params)
06bc494ca11e Initial load
duke
parents:
diff changeset
   184
                throws Exception {
06bc494ca11e Initial load
duke
parents:
diff changeset
   185
                if (DEBUG) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   186
                        configuration.root.printError(
06bc494ca11e Initial load
duke
parents:
diff changeset
   187
                                "DEBUG: " + this.getClass().getName() + "." + methodName);
06bc494ca11e Initial load
duke
parents:
diff changeset
   188
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   189
                Method method = this.getClass().getMethod(methodName, paramClasses);
06bc494ca11e Initial load
duke
parents:
diff changeset
   190
                method.invoke(this, params);
06bc494ca11e Initial load
duke
parents:
diff changeset
   191
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   192
06bc494ca11e Initial load
duke
parents:
diff changeset
   193
        /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   194
         * Return true it there are any members to summarize.
06bc494ca11e Initial load
duke
parents:
diff changeset
   195
         *
06bc494ca11e Initial load
duke
parents:
diff changeset
   196
         * @return true if there are any members to summarize.
06bc494ca11e Initial load
duke
parents:
diff changeset
   197
         */
06bc494ca11e Initial load
duke
parents:
diff changeset
   198
        public boolean hasMembersToDocument() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   199
        if (classDoc instanceof AnnotationTypeDoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   200
            return ((AnnotationTypeDoc) classDoc).elements().length > 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   201
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   202
                for (int i = 0; i < VisibleMemberMap.NUM_MEMBER_TYPES; i++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   203
                        VisibleMemberMap members = visibleMemberMaps[i];
06bc494ca11e Initial load
duke
parents:
diff changeset
   204
                        if (!members.noVisibleMembers()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   205
                                return true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   206
                        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   207
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   208
                return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   209
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   210
06bc494ca11e Initial load
duke
parents:
diff changeset
   211
        /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   212
         * Build the summary for the enum constants.
06bc494ca11e Initial load
duke
parents:
diff changeset
   213
         */
06bc494ca11e Initial load
duke
parents:
diff changeset
   214
        public void buildEnumConstantsSummary() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   215
                buildSummary(
06bc494ca11e Initial load
duke
parents:
diff changeset
   216
                        memberSummaryWriters[VisibleMemberMap.ENUM_CONSTANTS],
06bc494ca11e Initial load
duke
parents:
diff changeset
   217
                        visibleMemberMaps[VisibleMemberMap.ENUM_CONSTANTS]);
06bc494ca11e Initial load
duke
parents:
diff changeset
   218
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   219
06bc494ca11e Initial load
duke
parents:
diff changeset
   220
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   221
     * Build the summary for the optional members.
06bc494ca11e Initial load
duke
parents:
diff changeset
   222
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   223
    public void buildAnnotationTypeOptionalMemberSummary() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   224
        buildSummary(
06bc494ca11e Initial load
duke
parents:
diff changeset
   225
            memberSummaryWriters[VisibleMemberMap.ANNOTATION_TYPE_MEMBER_OPTIONAL],
06bc494ca11e Initial load
duke
parents:
diff changeset
   226
                visibleMemberMaps[VisibleMemberMap.ANNOTATION_TYPE_MEMBER_OPTIONAL]);
06bc494ca11e Initial load
duke
parents:
diff changeset
   227
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   228
06bc494ca11e Initial load
duke
parents:
diff changeset
   229
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   230
     * Build the summary for the optional members.
06bc494ca11e Initial load
duke
parents:
diff changeset
   231
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   232
    public void buildAnnotationTypeRequiredMemberSummary() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   233
        buildSummary(
06bc494ca11e Initial load
duke
parents:
diff changeset
   234
            memberSummaryWriters[VisibleMemberMap.ANNOTATION_TYPE_MEMBER_REQUIRED],
06bc494ca11e Initial load
duke
parents:
diff changeset
   235
                visibleMemberMaps[VisibleMemberMap.ANNOTATION_TYPE_MEMBER_REQUIRED]);
06bc494ca11e Initial load
duke
parents:
diff changeset
   236
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   237
06bc494ca11e Initial load
duke
parents:
diff changeset
   238
        /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   239
         * Build the summary for the fields.
06bc494ca11e Initial load
duke
parents:
diff changeset
   240
         */
06bc494ca11e Initial load
duke
parents:
diff changeset
   241
        public void buildFieldsSummary() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   242
                buildSummary(
06bc494ca11e Initial load
duke
parents:
diff changeset
   243
                        memberSummaryWriters[VisibleMemberMap.FIELDS],
06bc494ca11e Initial load
duke
parents:
diff changeset
   244
                        visibleMemberMaps[VisibleMemberMap.FIELDS]);
06bc494ca11e Initial load
duke
parents:
diff changeset
   245
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   246
06bc494ca11e Initial load
duke
parents:
diff changeset
   247
        /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   248
         * Build the inherited summary for the fields.
06bc494ca11e Initial load
duke
parents:
diff changeset
   249
         */
06bc494ca11e Initial load
duke
parents:
diff changeset
   250
        public void buildFieldsInheritedSummary() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   251
                buildInheritedSummary(
06bc494ca11e Initial load
duke
parents:
diff changeset
   252
                        memberSummaryWriters[VisibleMemberMap.FIELDS],
06bc494ca11e Initial load
duke
parents:
diff changeset
   253
                        visibleMemberMaps[VisibleMemberMap.FIELDS]);
06bc494ca11e Initial load
duke
parents:
diff changeset
   254
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   255
06bc494ca11e Initial load
duke
parents:
diff changeset
   256
        /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   257
         * Build the summary for the nested classes.
06bc494ca11e Initial load
duke
parents:
diff changeset
   258
         */
06bc494ca11e Initial load
duke
parents:
diff changeset
   259
        public void buildNestedClassesSummary() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   260
                buildSummary(
06bc494ca11e Initial load
duke
parents:
diff changeset
   261
                        memberSummaryWriters[VisibleMemberMap.INNERCLASSES],
06bc494ca11e Initial load
duke
parents:
diff changeset
   262
                        visibleMemberMaps[VisibleMemberMap.INNERCLASSES]);
06bc494ca11e Initial load
duke
parents:
diff changeset
   263
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   264
06bc494ca11e Initial load
duke
parents:
diff changeset
   265
        /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   266
         * Build the inherited summary for the nested classes.
06bc494ca11e Initial load
duke
parents:
diff changeset
   267
         */
06bc494ca11e Initial load
duke
parents:
diff changeset
   268
        public void buildNestedClassesInheritedSummary() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   269
                buildInheritedSummary(
06bc494ca11e Initial load
duke
parents:
diff changeset
   270
                        memberSummaryWriters[VisibleMemberMap.INNERCLASSES],
06bc494ca11e Initial load
duke
parents:
diff changeset
   271
                        visibleMemberMaps[VisibleMemberMap.INNERCLASSES]);
06bc494ca11e Initial load
duke
parents:
diff changeset
   272
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   273
06bc494ca11e Initial load
duke
parents:
diff changeset
   274
        /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   275
         * Build the method summary.
06bc494ca11e Initial load
duke
parents:
diff changeset
   276
         */
06bc494ca11e Initial load
duke
parents:
diff changeset
   277
        public void buildMethodsSummary() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   278
                buildSummary(
06bc494ca11e Initial load
duke
parents:
diff changeset
   279
                        memberSummaryWriters[VisibleMemberMap.METHODS],
06bc494ca11e Initial load
duke
parents:
diff changeset
   280
                        visibleMemberMaps[VisibleMemberMap.METHODS]);
06bc494ca11e Initial load
duke
parents:
diff changeset
   281
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   282
06bc494ca11e Initial load
duke
parents:
diff changeset
   283
        /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   284
         * Build the inherited method summary.
06bc494ca11e Initial load
duke
parents:
diff changeset
   285
         */
06bc494ca11e Initial load
duke
parents:
diff changeset
   286
        public void buildMethodsInheritedSummary() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   287
                buildInheritedSummary(
06bc494ca11e Initial load
duke
parents:
diff changeset
   288
                        memberSummaryWriters[VisibleMemberMap.METHODS],
06bc494ca11e Initial load
duke
parents:
diff changeset
   289
                        visibleMemberMaps[VisibleMemberMap.METHODS]);
06bc494ca11e Initial load
duke
parents:
diff changeset
   290
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   291
06bc494ca11e Initial load
duke
parents:
diff changeset
   292
        /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   293
         * Build the constructor summary.
06bc494ca11e Initial load
duke
parents:
diff changeset
   294
         */
06bc494ca11e Initial load
duke
parents:
diff changeset
   295
        public void buildConstructorsSummary() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   296
                buildSummary(
06bc494ca11e Initial load
duke
parents:
diff changeset
   297
                        memberSummaryWriters[VisibleMemberMap.CONSTRUCTORS],
06bc494ca11e Initial load
duke
parents:
diff changeset
   298
                        visibleMemberMaps[VisibleMemberMap.CONSTRUCTORS]);
06bc494ca11e Initial load
duke
parents:
diff changeset
   299
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   300
06bc494ca11e Initial load
duke
parents:
diff changeset
   301
        /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   302
         * Build the member summary for the given members.
06bc494ca11e Initial load
duke
parents:
diff changeset
   303
         *
06bc494ca11e Initial load
duke
parents:
diff changeset
   304
         * @param writer           the summary writer to write the output.
06bc494ca11e Initial load
duke
parents:
diff changeset
   305
         * @param visibleMemberMap the given members to summarize.
06bc494ca11e Initial load
duke
parents:
diff changeset
   306
         */
06bc494ca11e Initial load
duke
parents:
diff changeset
   307
        private void buildSummary(MemberSummaryWriter writer,
06bc494ca11e Initial load
duke
parents:
diff changeset
   308
            VisibleMemberMap visibleMemberMap) {
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   309
        List<ProgramElementDoc> members = new ArrayList<ProgramElementDoc>(visibleMemberMap.getLeafClassMembers(
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   310
            configuration));
06bc494ca11e Initial load
duke
parents:
diff changeset
   311
        if (members.size() > 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   312
            Collections.sort(members);
06bc494ca11e Initial load
duke
parents:
diff changeset
   313
            writer.writeMemberSummaryHeader(classDoc);
06bc494ca11e Initial load
duke
parents:
diff changeset
   314
            for (int i = 0; i < members.size(); i++) {
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   315
                ProgramElementDoc member = members.get(i);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   316
                Tag[] firstSentenceTags = member.firstSentenceTags();
06bc494ca11e Initial load
duke
parents:
diff changeset
   317
                if (member instanceof MethodDoc && firstSentenceTags.length == 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   318
                    //Inherit comments from overriden or implemented method if
06bc494ca11e Initial load
duke
parents:
diff changeset
   319
                    //necessary.
06bc494ca11e Initial load
duke
parents:
diff changeset
   320
                    DocFinder.Output inheritedDoc =
06bc494ca11e Initial load
duke
parents:
diff changeset
   321
                        DocFinder.search(new DocFinder.Input((MethodDoc) member));
06bc494ca11e Initial load
duke
parents:
diff changeset
   322
                    if (inheritedDoc.holder != null &&
06bc494ca11e Initial load
duke
parents:
diff changeset
   323
                            inheritedDoc.holder.firstSentenceTags().length > 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   324
                        firstSentenceTags = inheritedDoc.holder.firstSentenceTags();
06bc494ca11e Initial load
duke
parents:
diff changeset
   325
                    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   326
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   327
                writer.writeMemberSummary(classDoc, member, firstSentenceTags,
06bc494ca11e Initial load
duke
parents:
diff changeset
   328
                    i == 0, i == members.size() - 1);
06bc494ca11e Initial load
duke
parents:
diff changeset
   329
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   330
            writer.writeMemberSummaryFooter(classDoc);
06bc494ca11e Initial load
duke
parents:
diff changeset
   331
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   332
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   333
06bc494ca11e Initial load
duke
parents:
diff changeset
   334
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   335
     * Build the inherited member summary for the given methods.
06bc494ca11e Initial load
duke
parents:
diff changeset
   336
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   337
     * @param writer           the writer for this member summary.
06bc494ca11e Initial load
duke
parents:
diff changeset
   338
     * @param visibleMemberMap the map for the members to document.
06bc494ca11e Initial load
duke
parents:
diff changeset
   339
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   340
        private void buildInheritedSummary(MemberSummaryWriter writer,
06bc494ca11e Initial load
duke
parents:
diff changeset
   341
            VisibleMemberMap visibleMemberMap) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   342
        for (Iterator iter = visibleMemberMap.getVisibleClassesList().iterator();
06bc494ca11e Initial load
duke
parents:
diff changeset
   343
                iter.hasNext();) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   344
            ClassDoc inhclass = (ClassDoc) (iter.next());
06bc494ca11e Initial load
duke
parents:
diff changeset
   345
            if (! (inhclass.isPublic() ||
06bc494ca11e Initial load
duke
parents:
diff changeset
   346
                Util.isLinkable(inhclass, configuration))) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   347
                continue;
06bc494ca11e Initial load
duke
parents:
diff changeset
   348
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   349
            if (inhclass == classDoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   350
                continue;
06bc494ca11e Initial load
duke
parents:
diff changeset
   351
            }
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   352
            List<ProgramElementDoc> inhmembers = visibleMemberMap.getMembersFor(inhclass);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   353
            if (inhmembers.size() > 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   354
                Collections.sort(inhmembers);
06bc494ca11e Initial load
duke
parents:
diff changeset
   355
                writer.writeInheritedMemberSummaryHeader(inhclass);
06bc494ca11e Initial load
duke
parents:
diff changeset
   356
                for (int j = 0; j < inhmembers.size(); ++j) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   357
                    writer.writeInheritedMemberSummary(
06bc494ca11e Initial load
duke
parents:
diff changeset
   358
                        inhclass.isPackagePrivate() &&
06bc494ca11e Initial load
duke
parents:
diff changeset
   359
                            ! Util.isLinkable(inhclass, configuration) ?
06bc494ca11e Initial load
duke
parents:
diff changeset
   360
                            classDoc : inhclass,
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   361
                        inhmembers.get(j),
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   362
                        j == 0,
06bc494ca11e Initial load
duke
parents:
diff changeset
   363
                        j == inhmembers.size() - 1);
06bc494ca11e Initial load
duke
parents:
diff changeset
   364
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   365
                writer.writeInheritedMemberSummaryFooter(inhclass);
06bc494ca11e Initial load
duke
parents:
diff changeset
   366
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   367
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   368
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   369
}