langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialFieldWriter.java
author mcimadamore
Tue, 13 Jan 2009 13:27:14 +0000
changeset 1789 7ac8c0815000
parent 1787 1aa079321cd2
child 2086 cca2603eab0b
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
/*
06bc494ca11e Initial load
duke
parents:
diff changeset
     2
 * Copyright 1998-2006 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.tools.doclets.internal.toolkit.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
import com.sun.tools.doclets.internal.toolkit.taglets.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
import com.sun.tools.doclets.internal.toolkit.util.*;
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
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
 * Generate serialized form for serializable fields.
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
 * Documentation denoted by the tags <code>serial</code> and
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
 * <code>serialField</code> is processed.
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
 * @author Joe Fialli
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
public class HtmlSerialFieldWriter extends FieldWriterImpl
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
    implements SerializedFormWriter.SerialFieldWriter {
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
    ProgramElementDoc[] members = null;
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
    private boolean printedOverallAnchor = false;
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
    private boolean printedFirstMember = false;
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
    public HtmlSerialFieldWriter(SubWriterHolderWriter writer,
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
                                    ClassDoc classdoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
        super(writer, classdoc);
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
1789
7ac8c0815000 6765045: Remove rawtypes warnings from langtools
mcimadamore
parents: 1787
diff changeset
    54
    public List<FieldDoc> members(ClassDoc cd) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
        return Util.asList(cd.serializableFields());
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
    protected void printTypeLinkNoDimension(Type type) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
        ClassDoc cd = type.asClassDoc();
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
        //Linking to package private classes in serialized for causes
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
        //broken links.  Don't link to them.
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
        if (type.isPrimitive() || cd.isPackagePrivate()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
            print(type.typeName());
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
        } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
            writer.printLink(new LinkInfoImpl(
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
                LinkInfoImpl.CONTEXT_SERIAL_MEMBER, type));
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
    public void writeHeader(String heading) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
        if (! printedOverallAnchor) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
            writer.anchor("serializedForm");
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
            printedOverallAnchor = true;
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
            writer.printTableHeadingBackground(heading);
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
            writer.println();
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
            if (heading.equals(
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
                   configuration().getText("doclet.Serialized_Form_class"))) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
                writer.dl();
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
        } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
            writer.printTableHeadingBackground(heading);
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
            writer.println();
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
    public void writeMemberHeader(ClassDoc fieldType, String fieldTypeStr,
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
            String fieldDimensions, String fieldName) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
        if (printedFirstMember) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
            writer.printMemberHeader();
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
        printedFirstMember = true;
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
        writer.h3();
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
        writer.print(fieldName);
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
        writer.h3End();
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
        writer.pre();
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
        if (fieldType == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
            writer.print(fieldTypeStr);
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
        } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
            writer.printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_SERIAL_MEMBER,
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
                fieldType));
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
        print(fieldDimensions + ' ');
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 10
diff changeset
   103
        strong(fieldName);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
        writer.preEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
        writer.dl();
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
     * Write the deprecated information for this member.
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
     * @param field the field to document.
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
    public void writeMemberDeprecatedInfo(FieldDoc field) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
        print(((TagletOutputImpl)
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
            (new DeprecatedTaglet()).getTagletOutput(field,
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
            writer.getTagletWriterInstance(false))).toString());
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
     * Write the description text for this member.
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
     * @param field the field to document.
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
    public void writeMemberDescription(FieldDoc field) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
        if (field.inlineTags().length > 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
            writer.dd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
            writer.printInlineComment(field);
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
        Tag[] tags = field.tags("serial");
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
        if (tags.length > 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
            writer.dt();
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
            writer.dd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
            writer.printInlineComment(field, tags[0]);
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
     * Write the description text for this member represented by the tag.
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
     * @param serialFieldTag the field to document (represented by tag).
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
    public void writeMemberDescription(SerialFieldTag serialFieldTag) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
        writer.dd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
        writer.print(serialFieldTag.description());
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
        writer.dlEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
     * Write the tag information for this member.
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
     * @param field the field to document.
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   153
    public void writeMemberTags(FieldDoc field) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
        writer.dl();
06bc494ca11e Initial load
duke
parents:
diff changeset
   155
        TagletOutputImpl output = new TagletOutputImpl("");
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
        TagletWriter.genTagOuput(configuration().tagletManager, field,
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
            configuration().tagletManager.getCustomTags(field),
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
                writer.getTagletWriterInstance(false), output);
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
        if (output.toString().length() > 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
            print(output.toString());
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
        writer.dlEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   163
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   164
    public void writeMemberFooter(FieldDoc member) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
        writer.dlEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
}