langtools/src/share/classes/com/sun/tools/doclets/formats/html/SerializedFormWriterImpl.java
author bpatel
Thu, 08 Jan 2009 16:26:59 -0800
changeset 1787 1aa079321cd2
parent 10 06bc494ca11e
child 5520 86e4b9a9da40
permissions -rw-r--r--
6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong Reviewed-by: jjg
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 1998-2005 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.formats.html;
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
import com.sun.javadoc.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
import java.io.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
 * Generate the Serialized Form Information Page.
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
 * @author Atul M Dambalkar
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
public class SerializedFormWriterImpl extends SubWriterHolderWriter
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
    implements com.sun.tools.doclets.internal.toolkit.SerializedFormWriter {
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
    private static final String FILE_NAME = "serialized-form.html";
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
     * @throws IOException
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
     * @throws DocletAbortException
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
    public SerializedFormWriterImpl() throws IOException {
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
        super(ConfigurationImpl.getInstance(), FILE_NAME);
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
     * Writes the given header.
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
     * @param header the header to write.
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
    public void writeHeader(String header) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
        printHtmlHeader(header, null, true);
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
        printTop();
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
        navLinks(true);
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
        hr();
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
        center();
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
        h1();
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
        print(header);
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
        h1End();
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
        centerEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
     * Write the given package header.
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
     * @param packageName the package header to write.
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
    public void writePackageHeader(String packageName) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
        hr(4, "noshade");
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
        tableHeader();
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
        thAlign("center");
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
        font("+2");
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 10
diff changeset
    76
        strongText("doclet.Package");
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
        print(' ');
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 10
diff changeset
    78
        strong(packageName);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
        tableFooter();
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
     * Write the serial UID info.
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
     * @param header the header that will show up before the UID.
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
     * @param serialUID the serial UID to print.
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
    public void writeSerialUIDInfo(String header, String serialUID) {
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 10
diff changeset
    89
        strong(header + " ");
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
        println(serialUID);
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
        p();
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
     * Write the footer.
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
    public void writeFooter() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
        p();
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
        hr();
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
        navLinks(false);
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
        printBottom();
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
        printBodyHtmlEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
    }
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
     * Write the serializable class heading.
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
     * @param classDoc the class being processed.
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
    public void writeClassHeader(ClassDoc classDoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
        String classLink = (classDoc.isPublic() || classDoc.isProtected())?
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
            getLink(new LinkInfoImpl(classDoc,
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
                configuration.getClassName(classDoc))):
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
            classDoc.qualifiedName();
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
        p();
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
        anchor(classDoc.qualifiedName());
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
        String superClassLink =
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
            classDoc.superclassType() != null ?
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
                getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_SERIALIZED_FORM,
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
                    classDoc.superclassType())) :
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
                null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
        //Print the heading.
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
        String className = superClassLink == null ?
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
            configuration.getText(
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
                "doclet.Class_0_implements_serializable", classLink) :
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
            configuration.getText(
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
                "doclet.Class_0_extends_implements_serializable", classLink,
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
                    superClassLink);
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
        tableHeader();
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
        thAlignColspan("left", 2);
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
        font("+2");
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 10
diff changeset
   134
        strong(className);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
        tableFooter();
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
        p();
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
    private void tableHeader() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
        tableIndexSummary();
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
        trBgcolorStyle("#CCCCFF", "TableSubHeadingColor");
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
    private void tableFooter() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
        fontEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
        thEnd(); trEnd(); tableEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
     * Return an instance of a SerialFieldWriter.
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
     * @return an instance of a SerialFieldWriter.
06bc494ca11e Initial load
duke
parents:
diff changeset
   153
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
    public SerialFieldWriter getSerialFieldWriter(ClassDoc classDoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   155
        return new HtmlSerialFieldWriter(this, classDoc);
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
     * Return an instance of a SerialMethodWriter.
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
     * @return an instance of a SerialMethodWriter.
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   163
    public SerialMethodWriter getSerialMethodWriter(ClassDoc classDoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   164
        return new HtmlSerialMethodWriter(this, classDoc);
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
}