langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java
author mcimadamore
Tue, 13 Jan 2009 13:27:14 +0000
changeset 1789 7ac8c0815000
parent 1787 1aa079321cd2
child 2216 b124d5c924eb
permissions -rw-r--r--
6765045: Remove rawtypes warnings from langtools Summary: Removed all occurrences of rawtypes warnings from langtools Reviewed-by: jjg, bpatel
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
1264
076a3cde30d5 6754988: Update copyright year
xdono
parents: 868
diff changeset
     2
 * Copyright 1997-2008 Sun Microsystems, Inc.  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
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.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.util.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
import com.sun.tools.doclets.internal.toolkit.taglets.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
import com.sun.javadoc.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
import java.util.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
import java.lang.reflect.Modifier;
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
 * The base class for member writers.
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
 * @author Robert Field
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
 * @author Atul M Dambalkar
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
 * @author Jamie Ho (Re-write)
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
public abstract class AbstractMemberWriter {
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
    protected boolean printedSummaryHeader = false;
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
    protected final SubWriterHolderWriter writer;
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
    protected final ClassDoc classdoc;
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
    public final boolean nodepr;
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
    public AbstractMemberWriter(SubWriterHolderWriter writer,
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
                             ClassDoc classdoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
        this.writer = writer;
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
        this.nodepr = configuration().nodeprecated;
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
        this.classdoc = classdoc;
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
    public AbstractMemberWriter(SubWriterHolderWriter writer) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
        this(writer, null);
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
    /*** abstracts ***/
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
    public abstract void printSummaryLabel(ClassDoc cd);
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
    public abstract void printInheritedSummaryLabel(ClassDoc cd);
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
    public abstract void printSummaryAnchor(ClassDoc cd);
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
    public abstract void printInheritedSummaryAnchor(ClassDoc cd);
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
    protected abstract void printSummaryType(ProgramElementDoc member);
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
    protected void writeSummaryLink(ClassDoc cd, ProgramElementDoc member) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
        writeSummaryLink(LinkInfoImpl.CONTEXT_MEMBER, cd, member);
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
    protected abstract void writeSummaryLink(int context,
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
                                             ClassDoc cd,
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
                                             ProgramElementDoc member);
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
    protected abstract void writeInheritedSummaryLink(ClassDoc cd,
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
                                                     ProgramElementDoc member);
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
    protected abstract void writeDeprecatedLink(ProgramElementDoc member);
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
    protected abstract void printNavSummaryLink(ClassDoc cd, boolean link);
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
    protected abstract void printNavDetailLink(boolean link);
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
    /***  ***/
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
    protected void print(String str) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
        writer.print(str);
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
        writer.displayLength += str.length();
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
    protected void print(char ch) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
        writer.print(ch);
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
        writer.displayLength++;
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 1264
diff changeset
   101
    protected void strong(String str) {
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 1264
diff changeset
   102
        writer.strong(str);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
        writer.displayLength += str.length();
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
     * Return a string describing the access modifier flags.
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
     * Don't include native or synchronized.
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
     * The modifier names are returned in canonical order, as
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
     * specified by <em>The Java Language Specification</em>.
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
    protected String modifierString(MemberDoc member) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
        int ms = member.modifierSpecifier();
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
        int no = Modifier.NATIVE | Modifier.SYNCHRONIZED;
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
    return Modifier.toString(ms & ~no);
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
    protected String typeString(MemberDoc member) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
        String type = "";
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
        if (member instanceof MethodDoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
            type = ((MethodDoc)member).returnType().toString();
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
        } else if (member instanceof FieldDoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
            type = ((FieldDoc)member).type().toString();
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
        return type;
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
    protected void printModifiers(MemberDoc member) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
        String mod = modifierString(member);
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
        // According to JLS, we should not be showing public modifier for
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
        // interface methods.
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
        if ((member.isField() || member.isMethod()) &&
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
            writer instanceof ClassWriterImpl &&
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
             ((ClassWriterImpl) writer).getClassDoc().isInterface()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
            mod = Util.replaceText(mod, "public", "").trim();
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
        if(mod.length() > 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
            print(mod);
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
            print(' ');
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
    protected String makeSpace(int len) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
        if (len <= 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
            return "";
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
        StringBuffer sb = new StringBuffer(len);
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
        for(int i = 0; i < len; i++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
            sb.append(' ');
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
        return sb.toString();
06bc494ca11e Initial load
duke
parents:
diff changeset
   153
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
06bc494ca11e Initial load
duke
parents:
diff changeset
   155
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
     * Print 'static' if static and type link.
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
    protected void printStaticAndType(boolean isStatic, Type type) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
        writer.printTypeSummaryHeader();
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
        if (isStatic) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
            print("static");
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   163
        writer.space();
06bc494ca11e Initial load
duke
parents:
diff changeset
   164
        if (type != null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
            writer.printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER,
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
                type));
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
        writer.printTypeSummaryFooter();
06bc494ca11e Initial load
duke
parents:
diff changeset
   169
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
06bc494ca11e Initial load
duke
parents:
diff changeset
   171
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   172
     * Print the modifier and type for the member in the member summary.
06bc494ca11e Initial load
duke
parents:
diff changeset
   173
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   174
     * @param member the member to print the type for.
06bc494ca11e Initial load
duke
parents:
diff changeset
   175
     * @param type   the type to print.
06bc494ca11e Initial load
duke
parents:
diff changeset
   176
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   177
    protected void printModifierAndType(ProgramElementDoc member, Type type) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   178
        writer.printTypeSummaryHeader();
06bc494ca11e Initial load
duke
parents:
diff changeset
   179
        printModifier(member);
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
        if (type == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
            writer.space();
06bc494ca11e Initial load
duke
parents:
diff changeset
   182
            if (member.isClass()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   183
                print("class");
06bc494ca11e Initial load
duke
parents:
diff changeset
   184
            } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   185
                print("interface");
06bc494ca11e Initial load
duke
parents:
diff changeset
   186
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   187
        } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   188
            if (member instanceof ExecutableMemberDoc &&
06bc494ca11e Initial load
duke
parents:
diff changeset
   189
                    ((ExecutableMemberDoc) member).typeParameters().length > 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   190
                //Code to avoid ugly wrapping in member summary table.
06bc494ca11e Initial load
duke
parents:
diff changeset
   191
                writer.table(0,0,0);
06bc494ca11e Initial load
duke
parents:
diff changeset
   192
                writer.trAlignVAlign("right", "");
06bc494ca11e Initial load
duke
parents:
diff changeset
   193
                writer.tdNowrap();
06bc494ca11e Initial load
duke
parents:
diff changeset
   194
                writer.font("-1");
06bc494ca11e Initial load
duke
parents:
diff changeset
   195
                writer.code();
06bc494ca11e Initial load
duke
parents:
diff changeset
   196
                int displayLength = ((AbstractExecutableMemberWriter) this).
06bc494ca11e Initial load
duke
parents:
diff changeset
   197
                writeTypeParameters((ExecutableMemberDoc) member);
06bc494ca11e Initial load
duke
parents:
diff changeset
   198
                if (displayLength > 10) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   199
                    writer.br();
06bc494ca11e Initial load
duke
parents:
diff changeset
   200
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   201
                writer.printLink(new LinkInfoImpl(
06bc494ca11e Initial load
duke
parents:
diff changeset
   202
                    LinkInfoImpl.CONTEXT_SUMMARY_RETURN_TYPE, type));
06bc494ca11e Initial load
duke
parents:
diff changeset
   203
                writer.codeEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   204
                writer.fontEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   205
                writer.tdEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   206
                writer.trEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   207
                writer.tableEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   208
            } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   209
                writer.space();
06bc494ca11e Initial load
duke
parents:
diff changeset
   210
                writer.printLink(new LinkInfoImpl(
06bc494ca11e Initial load
duke
parents:
diff changeset
   211
                    LinkInfoImpl.CONTEXT_SUMMARY_RETURN_TYPE, type));
06bc494ca11e Initial load
duke
parents:
diff changeset
   212
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   213
06bc494ca11e Initial load
duke
parents:
diff changeset
   214
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   215
        writer.printTypeSummaryFooter();
06bc494ca11e Initial load
duke
parents:
diff changeset
   216
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   217
06bc494ca11e Initial load
duke
parents:
diff changeset
   218
    private void printModifier(ProgramElementDoc member) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   219
        if (member.isProtected()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   220
            print("protected ");
06bc494ca11e Initial load
duke
parents:
diff changeset
   221
        } else if (member.isPrivate()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   222
            print("private ");
06bc494ca11e Initial load
duke
parents:
diff changeset
   223
        } else if (!member.isPublic()) { // Package private
06bc494ca11e Initial load
duke
parents:
diff changeset
   224
            writer.printText("doclet.Package_private");
06bc494ca11e Initial load
duke
parents:
diff changeset
   225
            print(" ");
06bc494ca11e Initial load
duke
parents:
diff changeset
   226
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   227
        if (member.isMethod() && ((MethodDoc)member).isAbstract()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   228
            print("abstract ");
06bc494ca11e Initial load
duke
parents:
diff changeset
   229
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   230
        if (member.isStatic()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   231
            print("static");
06bc494ca11e Initial load
duke
parents:
diff changeset
   232
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   233
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   234
06bc494ca11e Initial load
duke
parents:
diff changeset
   235
    protected void printComment(ProgramElementDoc member) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   236
        if (member.inlineTags().length > 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   237
            writer.dd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   238
            writer.printInlineComment(member);
06bc494ca11e Initial load
duke
parents:
diff changeset
   239
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   240
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   241
06bc494ca11e Initial load
duke
parents:
diff changeset
   242
    protected String name(ProgramElementDoc member) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   243
        return member.name();
06bc494ca11e Initial load
duke
parents:
diff changeset
   244
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   245
06bc494ca11e Initial load
duke
parents:
diff changeset
   246
    protected void printHead(MemberDoc member) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   247
        writer.h3();
06bc494ca11e Initial load
duke
parents:
diff changeset
   248
        writer.print(member.name());
06bc494ca11e Initial load
duke
parents:
diff changeset
   249
        writer.h3End();
06bc494ca11e Initial load
duke
parents:
diff changeset
   250
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   251
06bc494ca11e Initial load
duke
parents:
diff changeset
   252
    protected void printFullComment(ProgramElementDoc member) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   253
        if(configuration().nocomment){
06bc494ca11e Initial load
duke
parents:
diff changeset
   254
            return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   255
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   256
        writer.dl();
06bc494ca11e Initial load
duke
parents:
diff changeset
   257
        print(((TagletOutputImpl)
06bc494ca11e Initial load
duke
parents:
diff changeset
   258
            (new DeprecatedTaglet()).getTagletOutput(member,
06bc494ca11e Initial load
duke
parents:
diff changeset
   259
            writer.getTagletWriterInstance(false))).toString());
06bc494ca11e Initial load
duke
parents:
diff changeset
   260
        printCommentAndTags(member);
06bc494ca11e Initial load
duke
parents:
diff changeset
   261
        writer.dlEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   262
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   263
06bc494ca11e Initial load
duke
parents:
diff changeset
   264
    protected void printCommentAndTags(ProgramElementDoc member) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   265
        printComment(member);
06bc494ca11e Initial load
duke
parents:
diff changeset
   266
        writer.printTags(member);
06bc494ca11e Initial load
duke
parents:
diff changeset
   267
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   268
06bc494ca11e Initial load
duke
parents:
diff changeset
   269
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   270
     * Forward to containing writer
06bc494ca11e Initial load
duke
parents:
diff changeset
   271
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   272
    public void printSummaryHeader(ClassDoc cd) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   273
        printedSummaryHeader = true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   274
        writer.printSummaryHeader(this, cd);
06bc494ca11e Initial load
duke
parents:
diff changeset
   275
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   276
06bc494ca11e Initial load
duke
parents:
diff changeset
   277
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   278
     * Forward to containing writer
06bc494ca11e Initial load
duke
parents:
diff changeset
   279
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   280
    public void printInheritedSummaryHeader(ClassDoc cd) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   281
        writer.printInheritedSummaryHeader(this, cd);
06bc494ca11e Initial load
duke
parents:
diff changeset
   282
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   283
06bc494ca11e Initial load
duke
parents:
diff changeset
   284
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   285
     * Forward to containing writer
06bc494ca11e Initial load
duke
parents:
diff changeset
   286
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   287
    public void printInheritedSummaryFooter(ClassDoc cd) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   288
        writer.printInheritedSummaryFooter(this, cd);
06bc494ca11e Initial load
duke
parents:
diff changeset
   289
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   290
06bc494ca11e Initial load
duke
parents:
diff changeset
   291
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   292
     * Forward to containing writer
06bc494ca11e Initial load
duke
parents:
diff changeset
   293
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   294
    public void printSummaryFooter(ClassDoc cd) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   295
        writer.printSummaryFooter(this, cd);
06bc494ca11e Initial load
duke
parents:
diff changeset
   296
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   297
06bc494ca11e Initial load
duke
parents:
diff changeset
   298
   /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   299
    * Return true if the given <code>ProgramElement</code> is inherited
06bc494ca11e Initial load
duke
parents:
diff changeset
   300
    * by the class that is being documented.
06bc494ca11e Initial load
duke
parents:
diff changeset
   301
    *
06bc494ca11e Initial load
duke
parents:
diff changeset
   302
    * @param ped The <code>ProgramElement</code> being checked.
06bc494ca11e Initial load
duke
parents:
diff changeset
   303
    * return true if the <code>ProgramElement</code> is being inherited and
06bc494ca11e Initial load
duke
parents:
diff changeset
   304
    * false otherwise.
06bc494ca11e Initial load
duke
parents:
diff changeset
   305
    */
06bc494ca11e Initial load
duke
parents:
diff changeset
   306
    protected boolean isInherited(ProgramElementDoc ped){
06bc494ca11e Initial load
duke
parents:
diff changeset
   307
        if(ped.isPrivate() || (ped.isPackagePrivate() &&
06bc494ca11e Initial load
duke
parents:
diff changeset
   308
            ! ped.containingPackage().equals(classdoc.containingPackage()))){
06bc494ca11e Initial load
duke
parents:
diff changeset
   309
            return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   310
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   311
        return true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   312
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   313
06bc494ca11e Initial load
duke
parents:
diff changeset
   314
06bc494ca11e Initial load
duke
parents:
diff changeset
   315
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   316
     * Generate the code for listing the deprecated APIs. Create the table
06bc494ca11e Initial load
duke
parents:
diff changeset
   317
     * format for listing the API. Call methods from the sub-class to complete
06bc494ca11e Initial load
duke
parents:
diff changeset
   318
     * the generation.
06bc494ca11e Initial load
duke
parents:
diff changeset
   319
     */
1789
7ac8c0815000 6765045: Remove rawtypes warnings from langtools
mcimadamore
parents: 1787
diff changeset
   320
    protected void printDeprecatedAPI(List<Doc> deprmembers, String headingKey) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   321
        if (deprmembers.size() > 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   322
            writer.tableIndexSummary();
06bc494ca11e Initial load
duke
parents:
diff changeset
   323
            writer.tableHeaderStart("#CCCCFF");
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 1264
diff changeset
   324
            writer.strongText(headingKey);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   325
            writer.tableHeaderEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   326
            for (int i = 0; i < deprmembers.size(); i++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   327
                ProgramElementDoc member =(ProgramElementDoc)deprmembers.get(i);
06bc494ca11e Initial load
duke
parents:
diff changeset
   328
                writer.trBgcolorStyle("white", "TableRowColor");
06bc494ca11e Initial load
duke
parents:
diff changeset
   329
                writer.summaryRow(0);
06bc494ca11e Initial load
duke
parents:
diff changeset
   330
                writeDeprecatedLink(member);
06bc494ca11e Initial load
duke
parents:
diff changeset
   331
                writer.br();
06bc494ca11e Initial load
duke
parents:
diff changeset
   332
                writer.printNbsps();
06bc494ca11e Initial load
duke
parents:
diff changeset
   333
                if (member.tags("deprecated").length > 0)
06bc494ca11e Initial load
duke
parents:
diff changeset
   334
                    writer.printInlineDeprecatedComment(member, member.tags("deprecated")[0]);
06bc494ca11e Initial load
duke
parents:
diff changeset
   335
                writer.space();
06bc494ca11e Initial load
duke
parents:
diff changeset
   336
                writer.summaryRowEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   337
                writer.trEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   338
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   339
            writer.tableEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   340
            writer.space();
06bc494ca11e Initial load
duke
parents:
diff changeset
   341
            writer.p();
06bc494ca11e Initial load
duke
parents:
diff changeset
   342
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   343
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   344
06bc494ca11e Initial load
duke
parents:
diff changeset
   345
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   346
     * Print use info.
06bc494ca11e Initial load
duke
parents:
diff changeset
   347
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   348
    protected void printUseInfo(List<? extends ProgramElementDoc> mems, String heading) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   349
        if (mems == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   350
            return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   351
        }
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   352
        List<? extends ProgramElementDoc> members = mems;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   353
        if (members.size() > 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   354
            writer.tableIndexSummary();
06bc494ca11e Initial load
duke
parents:
diff changeset
   355
            writer.tableUseInfoHeaderStart("#CCCCFF");
06bc494ca11e Initial load
duke
parents:
diff changeset
   356
            writer.print(heading);
06bc494ca11e Initial load
duke
parents:
diff changeset
   357
            writer.tableHeaderEnd();
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   358
            for (Iterator<? extends ProgramElementDoc> it = members.iterator(); it.hasNext(); ) {
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   359
                ProgramElementDoc pgmdoc = it.next();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   360
                ClassDoc cd = pgmdoc.containingClass();
06bc494ca11e Initial load
duke
parents:
diff changeset
   361
06bc494ca11e Initial load
duke
parents:
diff changeset
   362
                writer.printSummaryLinkType(this, pgmdoc);
06bc494ca11e Initial load
duke
parents:
diff changeset
   363
                if (cd != null && !(pgmdoc instanceof ConstructorDoc)
06bc494ca11e Initial load
duke
parents:
diff changeset
   364
                               && !(pgmdoc instanceof ClassDoc)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   365
                    // Add class context
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 1264
diff changeset
   366
                    writer.strong(cd.name() + ".");
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   367
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   368
                writeSummaryLink(
06bc494ca11e Initial load
duke
parents:
diff changeset
   369
                    pgmdoc instanceof ClassDoc ?
06bc494ca11e Initial load
duke
parents:
diff changeset
   370
                        LinkInfoImpl.CONTEXT_CLASS_USE : LinkInfoImpl.CONTEXT_MEMBER,
06bc494ca11e Initial load
duke
parents:
diff changeset
   371
                    cd, pgmdoc);
06bc494ca11e Initial load
duke
parents:
diff changeset
   372
                writer.printSummaryLinkComment(this, pgmdoc);
06bc494ca11e Initial load
duke
parents:
diff changeset
   373
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   374
            writer.tableEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   375
            writer.space();
06bc494ca11e Initial load
duke
parents:
diff changeset
   376
            writer.p();
06bc494ca11e Initial load
duke
parents:
diff changeset
   377
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   378
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   379
1789
7ac8c0815000 6765045: Remove rawtypes warnings from langtools
mcimadamore
parents: 1787
diff changeset
   380
    protected void navDetailLink(List<?> members) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   381
            printNavDetailLink(members.size() > 0? true: false);
06bc494ca11e Initial load
duke
parents:
diff changeset
   382
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   383
06bc494ca11e Initial load
duke
parents:
diff changeset
   384
1789
7ac8c0815000 6765045: Remove rawtypes warnings from langtools
mcimadamore
parents: 1787
diff changeset
   385
    protected void navSummaryLink(List<?> members,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   386
            VisibleMemberMap visibleMemberMap) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   387
        if (members.size() > 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   388
            printNavSummaryLink(null, true);
06bc494ca11e Initial load
duke
parents:
diff changeset
   389
            return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   390
        } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   391
            ClassDoc icd = classdoc.superclass();
06bc494ca11e Initial load
duke
parents:
diff changeset
   392
            while (icd != null) {
1789
7ac8c0815000 6765045: Remove rawtypes warnings from langtools
mcimadamore
parents: 1787
diff changeset
   393
                List<?> inhmembers = visibleMemberMap.getMembersFor(icd);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   394
                if (inhmembers.size() > 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   395
                    printNavSummaryLink(icd, true);
06bc494ca11e Initial load
duke
parents:
diff changeset
   396
                    return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   397
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   398
                icd = icd.superclass();
06bc494ca11e Initial load
duke
parents:
diff changeset
   399
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   400
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   401
        printNavSummaryLink(null, false);
06bc494ca11e Initial load
duke
parents:
diff changeset
   402
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   403
06bc494ca11e Initial load
duke
parents:
diff changeset
   404
    protected void serialWarning(SourcePosition pos, String key, String a1, String a2) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   405
        if (configuration().serialwarn) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   406
            ConfigurationImpl.getInstance().getDocletSpecificMsg().warning(pos, key, a1, a2);
06bc494ca11e Initial load
duke
parents:
diff changeset
   407
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   408
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   409
06bc494ca11e Initial load
duke
parents:
diff changeset
   410
    public ProgramElementDoc[] eligibleMembers(ProgramElementDoc[] members) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   411
        return nodepr? Util.excludeDeprecatedMembers(members): members;
06bc494ca11e Initial load
duke
parents:
diff changeset
   412
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   413
06bc494ca11e Initial load
duke
parents:
diff changeset
   414
    public ConfigurationImpl configuration() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   415
        return writer.configuration;
06bc494ca11e Initial load
duke
parents:
diff changeset
   416
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   417
06bc494ca11e Initial load
duke
parents:
diff changeset
   418
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   419
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   420
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   421
    public void writeMemberSummary(ClassDoc classDoc, ProgramElementDoc member,
06bc494ca11e Initial load
duke
parents:
diff changeset
   422
        Tag[] firstSentenceTags, boolean isFirst, boolean isLast) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   423
        writer.printSummaryLinkType(this, member);
06bc494ca11e Initial load
duke
parents:
diff changeset
   424
        writeSummaryLink(classDoc, member);
06bc494ca11e Initial load
duke
parents:
diff changeset
   425
        writer.printSummaryLinkComment(this, member, firstSentenceTags);
06bc494ca11e Initial load
duke
parents:
diff changeset
   426
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   427
}