langtools/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java
author ohair
Tue, 25 May 2010 15:54:51 -0700
changeset 5520 86e4b9a9da40
parent 2320 5b8c377175f4
child 7614 cfadc977ca75
permissions -rw-r--r--
6943119: Rebrand source copyright notices 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: 2320
diff changeset
     2
 * Copyright (c) 1997, 2004, 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: 2320
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: 2320
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: 2320
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 2320
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 2320
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
2216
b124d5c924eb 6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents: 1787
diff changeset
    28
import java.io.*;
b124d5c924eb 6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents: 1787
diff changeset
    29
b124d5c924eb 6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents: 1787
diff changeset
    30
import com.sun.javadoc.*;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
import com.sun.tools.doclets.internal.toolkit.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
import com.sun.tools.doclets.internal.toolkit.util.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
import com.sun.tools.doclets.internal.toolkit.taglets.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
 * Writes method documentation in HTML format.
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 (rewrite)
2320
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 2216
diff changeset
    41
 * @author Bhavesh Patel (Modified)
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
public class MethodWriterImpl extends AbstractExecutableMemberWriter
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
        implements MethodWriter, MemberSummaryWriter {
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
    private boolean printedSummaryHeader = false;
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
     * Construct a new MethodWriterImpl.
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
     * @param writer the writer for the class that the methods belong to.
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
     * @param classDoc the class being documented.
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
    public MethodWriterImpl(SubWriterHolderWriter writer, ClassDoc classDoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
        super(writer, classDoc);
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
     * Construct a new MethodWriterImpl.
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
     * @param writer The writer for the class that the methods belong to.
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
    public MethodWriterImpl(SubWriterHolderWriter writer) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
        super(writer);
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
     * Write the methods summary header for the given class.
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
     * @param classDoc the class the summary belongs to.
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
    public void writeMemberSummaryHeader(ClassDoc classDoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
        printedSummaryHeader = true;
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
        writer.println();
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
        writer.println("<!-- ========== METHOD SUMMARY =========== -->");
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
        writer.println();
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
        writer.printSummaryHeader(this, classDoc);
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
     * Write the methods summary footer for the given class.
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
     * @param classDoc the class the summary belongs to.
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
    public void writeMemberSummaryFooter(ClassDoc classDoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
        writer.printSummaryFooter(this, classDoc);
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
     * Write the inherited methods summary header for the given class.
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
     * @param classDoc the class the summary belongs to.
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
    public void writeInheritedMemberSummaryHeader(ClassDoc classDoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
        if(! printedSummaryHeader){
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
            //We don't want inherited summary to not be under heading.
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
            writeMemberSummaryHeader(classDoc);
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
            writeMemberSummaryFooter(classDoc);
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
            printedSummaryHeader = true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
        writer.printInheritedSummaryHeader(this, classDoc);
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
    public void writeInheritedMemberSummary(ClassDoc classDoc,
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
        ProgramElementDoc method, boolean isFirst, boolean isLast) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
        writer.printInheritedSummaryMember(this, classDoc, method, isFirst);
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
     * Write the inherited methods summary footer for the given class.
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
     * @param classDoc the class the summary belongs to.
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
    public void writeInheritedMemberSummaryFooter(ClassDoc classDoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
        writer.printInheritedSummaryFooter(this, classDoc);        ;
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
     * Write the header for the method documentation.
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
     * @param classDoc the class that the methods belong to.
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
    public void writeHeader(ClassDoc classDoc, String header) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
        writer.println();
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
        writer.println("<!-- ============ METHOD DETAIL ========== -->");
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
        writer.println();
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
        writer.anchor("method_detail");
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
        writer.printTableHeadingBackground(header);
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
     * Write the method header for the given method.
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
     * @param method the method being documented.
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
     * @param isFirst the flag to indicate whether or not the method is the
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
     *        first to be documented.
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
    public void writeMethodHeader(MethodDoc method, boolean isFirst) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
        if (! isFirst) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
            writer.printMemberHeader();
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
        writer.println();
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
        String erasureAnchor;
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
        if ((erasureAnchor = getErasureAnchor(method)) != null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
            writer.anchor(erasureAnchor);
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
        writer.anchor(method);
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
        writer.h3();
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
        writer.print(method.name());
06bc494ca11e Initial load
duke
parents:
diff changeset
   153
        writer.h3End();
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   155
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
     * Write the signature for the given method.
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
     * @param method the method being documented.
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
    public void writeSignature(MethodDoc method) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
        writer.displayLength = 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   163
        writer.pre();
06bc494ca11e Initial load
duke
parents:
diff changeset
   164
        writer.writeAnnotationInfo(method);
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
        printModifiers(method);
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
        writeTypeParameters(method);
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
        printReturnType(method);
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
        if (configuration().linksource) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   169
            writer.printSrcLink(method, method.name());
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
        } else {
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 10
diff changeset
   171
            strong(method.name());
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   172
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   173
        writeParameters(method);
06bc494ca11e Initial load
duke
parents:
diff changeset
   174
        writeExceptions(method);
06bc494ca11e Initial load
duke
parents:
diff changeset
   175
        writer.preEnd();
2216
b124d5c924eb 6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents: 1787
diff changeset
   176
        assert !writer.getMemberDetailsListPrinted();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   177
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   178
06bc494ca11e Initial load
duke
parents:
diff changeset
   179
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
     * Write the deprecated output for the given method.
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   182
     * @param method the method being documented.
06bc494ca11e Initial load
duke
parents:
diff changeset
   183
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   184
    public void writeDeprecated(MethodDoc method) {
2216
b124d5c924eb 6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents: 1787
diff changeset
   185
        printDeprecated(method);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   186
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   187
06bc494ca11e Initial load
duke
parents:
diff changeset
   188
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   189
     * Write the comments for the given method.
06bc494ca11e Initial load
duke
parents:
diff changeset
   190
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   191
     * @param method the method being documented.
06bc494ca11e Initial load
duke
parents:
diff changeset
   192
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   193
    public void writeComments(Type holder, MethodDoc method) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   194
        ClassDoc holderClassDoc = holder.asClassDoc();
06bc494ca11e Initial load
duke
parents:
diff changeset
   195
        if (method.inlineTags().length > 0) {
2216
b124d5c924eb 6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents: 1787
diff changeset
   196
            writer.printMemberDetailsListStartTag();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   197
            if (holder.asClassDoc().equals(classdoc) ||
06bc494ca11e Initial load
duke
parents:
diff changeset
   198
                (! (holderClassDoc.isPublic() ||
06bc494ca11e Initial load
duke
parents:
diff changeset
   199
                    Util.isLinkable(holderClassDoc, configuration())))) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   200
                writer.dd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   201
                writer.printInlineComment(method);
2216
b124d5c924eb 6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents: 1787
diff changeset
   202
                writer.ddEnd();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   203
            } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   204
                String classlink = writer.codeText(
06bc494ca11e Initial load
duke
parents:
diff changeset
   205
                    writer.getDocLink(LinkInfoImpl.CONTEXT_METHOD_DOC_COPY,
06bc494ca11e Initial load
duke
parents:
diff changeset
   206
                        holder.asClassDoc(), method,
06bc494ca11e Initial load
duke
parents:
diff changeset
   207
                        holder.asClassDoc().isIncluded() ?
06bc494ca11e Initial load
duke
parents:
diff changeset
   208
                            holder.typeName() : holder.qualifiedTypeName(),
06bc494ca11e Initial load
duke
parents:
diff changeset
   209
                        false));
06bc494ca11e Initial load
duke
parents:
diff changeset
   210
                writer.dd();
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 10
diff changeset
   211
                writer.strongText(holder.asClassDoc().isClass()?
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   212
                        "doclet.Description_From_Class":
06bc494ca11e Initial load
duke
parents:
diff changeset
   213
                        "doclet.Description_From_Interface",
06bc494ca11e Initial load
duke
parents:
diff changeset
   214
                    classlink);
06bc494ca11e Initial load
duke
parents:
diff changeset
   215
                writer.ddEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   216
                writer.dd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   217
                writer.printInlineComment(method);
2216
b124d5c924eb 6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents: 1787
diff changeset
   218
                writer.ddEnd();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   219
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   220
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   221
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   222
06bc494ca11e Initial load
duke
parents:
diff changeset
   223
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   224
     * Write the tag output for the given method.
06bc494ca11e Initial load
duke
parents:
diff changeset
   225
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   226
     * @param method the method being documented.
06bc494ca11e Initial load
duke
parents:
diff changeset
   227
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   228
    public void writeTags(MethodDoc method) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   229
        writer.printTags(method);
06bc494ca11e Initial load
duke
parents:
diff changeset
   230
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   231
06bc494ca11e Initial load
duke
parents:
diff changeset
   232
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   233
     * Write the method footer.
06bc494ca11e Initial load
duke
parents:
diff changeset
   234
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   235
    public void writeMethodFooter() {
2216
b124d5c924eb 6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents: 1787
diff changeset
   236
        printMemberFooter();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   237
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   238
06bc494ca11e Initial load
duke
parents:
diff changeset
   239
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   240
     * Write the footer for the method documentation.
06bc494ca11e Initial load
duke
parents:
diff changeset
   241
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   242
     * @param classDoc the class that the methods belong to.
06bc494ca11e Initial load
duke
parents:
diff changeset
   243
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   244
    public void writeFooter(ClassDoc classDoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   245
        //No footer to write for method documentation
06bc494ca11e Initial load
duke
parents:
diff changeset
   246
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   247
06bc494ca11e Initial load
duke
parents:
diff changeset
   248
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   249
     * Close the writer.
06bc494ca11e Initial load
duke
parents:
diff changeset
   250
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   251
    public void close() throws IOException {
06bc494ca11e Initial load
duke
parents:
diff changeset
   252
        writer.close();
06bc494ca11e Initial load
duke
parents:
diff changeset
   253
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   254
06bc494ca11e Initial load
duke
parents:
diff changeset
   255
    public int getMemberKind() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   256
        return VisibleMemberMap.METHODS;
06bc494ca11e Initial load
duke
parents:
diff changeset
   257
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   258
2320
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 2216
diff changeset
   259
    public void printSummaryLabel() {
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 2216
diff changeset
   260
        writer.printText("doclet.Method_Summary");
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 2216
diff changeset
   261
    }
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 2216
diff changeset
   262
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 2216
diff changeset
   263
    public void printTableSummary() {
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 2216
diff changeset
   264
        writer.tableIndexSummary(configuration().getText("doclet.Member_Table_Summary",
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 2216
diff changeset
   265
                configuration().getText("doclet.Method_Summary"),
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 2216
diff changeset
   266
                configuration().getText("doclet.methods")));
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 2216
diff changeset
   267
    }
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 2216
diff changeset
   268
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 2216
diff changeset
   269
    public void printSummaryTableHeader(ProgramElementDoc member) {
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 2216
diff changeset
   270
        String[] header = new String[] {
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 2216
diff changeset
   271
            writer.getModifierTypeHeader(),
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 2216
diff changeset
   272
            configuration().getText("doclet.0_and_1",
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 2216
diff changeset
   273
                    configuration().getText("doclet.Method"),
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 2216
diff changeset
   274
                    configuration().getText("doclet.Description"))
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 2216
diff changeset
   275
        };
5b8c377175f4 6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents: 2216
diff changeset
   276
        writer.summaryTableHeader(header, "col");
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   277
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   278
06bc494ca11e Initial load
duke
parents:
diff changeset
   279
    public void printSummaryAnchor(ClassDoc cd) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   280
        writer.anchor("method_summary");
06bc494ca11e Initial load
duke
parents:
diff changeset
   281
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   282
06bc494ca11e Initial load
duke
parents:
diff changeset
   283
    public void printInheritedSummaryAnchor(ClassDoc cd) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   284
        writer.anchor("methods_inherited_from_class_" +
06bc494ca11e Initial load
duke
parents:
diff changeset
   285
            ConfigurationImpl.getInstance().getClassName(cd));
06bc494ca11e Initial load
duke
parents:
diff changeset
   286
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   287
06bc494ca11e Initial load
duke
parents:
diff changeset
   288
    public void printInheritedSummaryLabel(ClassDoc cd) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   289
        String classlink = writer.getPreQualifiedClassLink(
06bc494ca11e Initial load
duke
parents:
diff changeset
   290
            LinkInfoImpl.CONTEXT_MEMBER, cd, false);
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 10
diff changeset
   291
        writer.strong();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   292
        String key = cd.isClass()?
06bc494ca11e Initial load
duke
parents:
diff changeset
   293
            "doclet.Methods_Inherited_From_Class" :
06bc494ca11e Initial load
duke
parents:
diff changeset
   294
            "doclet.Methods_Inherited_From_Interface";
06bc494ca11e Initial load
duke
parents:
diff changeset
   295
        writer.printText(key, classlink);
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 10
diff changeset
   296
        writer.strongEnd();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   297
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   298
06bc494ca11e Initial load
duke
parents:
diff changeset
   299
    protected void printSummaryType(ProgramElementDoc member) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   300
        MethodDoc meth = (MethodDoc)member;
06bc494ca11e Initial load
duke
parents:
diff changeset
   301
        printModifierAndType(meth, meth.returnType());
06bc494ca11e Initial load
duke
parents:
diff changeset
   302
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   303
06bc494ca11e Initial load
duke
parents:
diff changeset
   304
    protected static void printOverridden(HtmlDocletWriter writer,
06bc494ca11e Initial load
duke
parents:
diff changeset
   305
            Type overriddenType, MethodDoc method) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   306
        if(writer.configuration.nocomment){
06bc494ca11e Initial load
duke
parents:
diff changeset
   307
            return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   308
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   309
        ClassDoc holderClassDoc = overriddenType.asClassDoc();
06bc494ca11e Initial load
duke
parents:
diff changeset
   310
        if (! (holderClassDoc.isPublic() ||
06bc494ca11e Initial load
duke
parents:
diff changeset
   311
            Util.isLinkable(holderClassDoc, writer.configuration()))) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   312
            //This is an implementation detail that should not be documented.
06bc494ca11e Initial load
duke
parents:
diff changeset
   313
            return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   314
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   315
        if (overriddenType.asClassDoc().isIncluded() && ! method.isIncluded()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   316
            //The class is included but the method is not.  That means that it
06bc494ca11e Initial load
duke
parents:
diff changeset
   317
            //is not visible so don't document this.
06bc494ca11e Initial load
duke
parents:
diff changeset
   318
            return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   319
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   320
        String label = "doclet.Overrides";
06bc494ca11e Initial load
duke
parents:
diff changeset
   321
        int context = LinkInfoImpl.CONTEXT_METHOD_OVERRIDES;
06bc494ca11e Initial load
duke
parents:
diff changeset
   322
06bc494ca11e Initial load
duke
parents:
diff changeset
   323
        if (method != null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   324
            if(overriddenType.asClassDoc().isAbstract() && method.isAbstract()){
06bc494ca11e Initial load
duke
parents:
diff changeset
   325
                //Abstract method is implemented from abstract class,
06bc494ca11e Initial load
duke
parents:
diff changeset
   326
                //not overridden
06bc494ca11e Initial load
duke
parents:
diff changeset
   327
                label = "doclet.Specified_By";
06bc494ca11e Initial load
duke
parents:
diff changeset
   328
                context = LinkInfoImpl.CONTEXT_METHOD_SPECIFIED_BY;
06bc494ca11e Initial load
duke
parents:
diff changeset
   329
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   330
            String overriddenTypeLink = writer.codeText(
06bc494ca11e Initial load
duke
parents:
diff changeset
   331
                writer.getLink(new LinkInfoImpl(context, overriddenType)));
06bc494ca11e Initial load
duke
parents:
diff changeset
   332
            String name = method.name();
06bc494ca11e Initial load
duke
parents:
diff changeset
   333
            writer.dt();
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 10
diff changeset
   334
            writer.strongText(label);
2216
b124d5c924eb 6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents: 1787
diff changeset
   335
            writer.dtEnd();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   336
            writer.dd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   337
            String methLink = writer.codeText(
06bc494ca11e Initial load
duke
parents:
diff changeset
   338
                writer.getLink(
06bc494ca11e Initial load
duke
parents:
diff changeset
   339
                    new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER,
06bc494ca11e Initial load
duke
parents:
diff changeset
   340
                        overriddenType.asClassDoc(),
06bc494ca11e Initial load
duke
parents:
diff changeset
   341
                        writer.getAnchor(method), name, false)
06bc494ca11e Initial load
duke
parents:
diff changeset
   342
                ));
06bc494ca11e Initial load
duke
parents:
diff changeset
   343
            writer.printText("doclet.in_class", methLink, overriddenTypeLink);
2216
b124d5c924eb 6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents: 1787
diff changeset
   344
            writer.ddEnd();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   345
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   346
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   347
06bc494ca11e Initial load
duke
parents:
diff changeset
   348
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   349
     * Parse the &lt;Code&gt; tag and return the text.
06bc494ca11e Initial load
duke
parents:
diff changeset
   350
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   351
    protected String parseCodeTag(String tag){
06bc494ca11e Initial load
duke
parents:
diff changeset
   352
        if(tag == null){
06bc494ca11e Initial load
duke
parents:
diff changeset
   353
            return "";
06bc494ca11e Initial load
duke
parents:
diff changeset
   354
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   355
06bc494ca11e Initial load
duke
parents:
diff changeset
   356
        String lc = tag.toLowerCase();
06bc494ca11e Initial load
duke
parents:
diff changeset
   357
        int begin = lc.indexOf("<code>");
06bc494ca11e Initial load
duke
parents:
diff changeset
   358
        int end = lc.indexOf("</code>");
06bc494ca11e Initial load
duke
parents:
diff changeset
   359
        if(begin == -1 || end == -1 || end <= begin){
06bc494ca11e Initial load
duke
parents:
diff changeset
   360
            return tag;
06bc494ca11e Initial load
duke
parents:
diff changeset
   361
        } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   362
            return tag.substring(begin + 6, end);
06bc494ca11e Initial load
duke
parents:
diff changeset
   363
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   364
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   365
06bc494ca11e Initial load
duke
parents:
diff changeset
   366
    protected static void printImplementsInfo(HtmlDocletWriter writer,
06bc494ca11e Initial load
duke
parents:
diff changeset
   367
            MethodDoc method) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   368
        if(writer.configuration.nocomment){
06bc494ca11e Initial load
duke
parents:
diff changeset
   369
            return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   370
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   371
        ImplementedMethods implementedMethodsFinder =
06bc494ca11e Initial load
duke
parents:
diff changeset
   372
            new ImplementedMethods(method, writer.configuration);
06bc494ca11e Initial load
duke
parents:
diff changeset
   373
        MethodDoc[] implementedMethods = implementedMethodsFinder.build();
06bc494ca11e Initial load
duke
parents:
diff changeset
   374
        for (int i = 0; i < implementedMethods.length; i++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   375
            MethodDoc implementedMeth = implementedMethods[i];
06bc494ca11e Initial load
duke
parents:
diff changeset
   376
            Type intfac = implementedMethodsFinder.getMethodHolder(implementedMeth);
06bc494ca11e Initial load
duke
parents:
diff changeset
   377
            String methlink = "";
06bc494ca11e Initial load
duke
parents:
diff changeset
   378
            String intfaclink = writer.codeText(
06bc494ca11e Initial load
duke
parents:
diff changeset
   379
                writer.getLink(new LinkInfoImpl(
06bc494ca11e Initial load
duke
parents:
diff changeset
   380
                    LinkInfoImpl.CONTEXT_METHOD_SPECIFIED_BY, intfac)));
06bc494ca11e Initial load
duke
parents:
diff changeset
   381
            writer.dt();
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 10
diff changeset
   382
            writer.strongText("doclet.Specified_By");
2216
b124d5c924eb 6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents: 1787
diff changeset
   383
            writer.dtEnd();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   384
            writer.dd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   385
            methlink = writer.codeText(writer.getDocLink(
06bc494ca11e Initial load
duke
parents:
diff changeset
   386
                LinkInfoImpl.CONTEXT_MEMBER, implementedMeth,
06bc494ca11e Initial load
duke
parents:
diff changeset
   387
                implementedMeth.name(), false));
06bc494ca11e Initial load
duke
parents:
diff changeset
   388
            writer.printText("doclet.in_interface", methlink, intfaclink);
2216
b124d5c924eb 6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents: 1787
diff changeset
   389
            writer.ddEnd();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   390
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   391
06bc494ca11e Initial load
duke
parents:
diff changeset
   392
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   393
06bc494ca11e Initial load
duke
parents:
diff changeset
   394
    protected void printReturnType(MethodDoc method) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   395
        Type type = method.returnType();
06bc494ca11e Initial load
duke
parents:
diff changeset
   396
        if (type != null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   397
            writer.printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_RETURN_TYPE,
06bc494ca11e Initial load
duke
parents:
diff changeset
   398
                type));
06bc494ca11e Initial load
duke
parents:
diff changeset
   399
            print(' ');
06bc494ca11e Initial load
duke
parents:
diff changeset
   400
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   401
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   402
06bc494ca11e Initial load
duke
parents:
diff changeset
   403
    protected void printNavSummaryLink(ClassDoc cd, boolean link) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   404
        if (link) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   405
            writer.printHyperLink("", (cd == null)?
06bc494ca11e Initial load
duke
parents:
diff changeset
   406
                "method_summary":
06bc494ca11e Initial load
duke
parents:
diff changeset
   407
                "methods_inherited_from_class_" +
06bc494ca11e Initial load
duke
parents:
diff changeset
   408
                ConfigurationImpl.getInstance().getClassName(cd),
06bc494ca11e Initial load
duke
parents:
diff changeset
   409
                ConfigurationImpl.getInstance().getText("doclet.navMethod"));
06bc494ca11e Initial load
duke
parents:
diff changeset
   410
        } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   411
            writer.printText("doclet.navMethod");
06bc494ca11e Initial load
duke
parents:
diff changeset
   412
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   413
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   414
06bc494ca11e Initial load
duke
parents:
diff changeset
   415
    protected void printNavDetailLink(boolean link) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   416
        if (link) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   417
            writer.printHyperLink("", "method_detail",
06bc494ca11e Initial load
duke
parents:
diff changeset
   418
                ConfigurationImpl.getInstance().getText("doclet.navMethod"));
06bc494ca11e Initial load
duke
parents:
diff changeset
   419
        } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   420
            writer.printText("doclet.navMethod");
06bc494ca11e Initial load
duke
parents:
diff changeset
   421
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   422
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   423
}