src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialMethodWriter.java

Tue, 09 Oct 2012 19:10:00 -0700

author
jjg
date
Tue, 09 Oct 2012 19:10:00 -0700
changeset 1357
c75be5bc5283
parent 798
4868a36f6fd8
child 1359
25e14ad23cef
permissions
-rw-r--r--

8000663: clean up langtools imports
Reviewed-by: darcy

     1 /*
     2  * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     8  * particular file as subject to the "Classpath" exception as provided
     9  * by Oracle in the LICENSE file that accompanied this code.
    10  *
    11  * This code is distributed in the hope that it will be useful, but WITHOUT
    12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    14  * version 2 for more details (a copy is included in the LICENSE file that
    15  * accompanied this code).
    16  *
    17  * You should have received a copy of the GNU General Public License version
    18  * 2 along with this work; if not, write to the Free Software Foundation,
    19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    20  *
    21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    22  * or visit www.oracle.com if you need additional information or have any
    23  * questions.
    24  */
    26 package com.sun.tools.doclets.formats.html;
    28 import com.sun.javadoc.*;
    29 import com.sun.tools.doclets.formats.html.markup.*;
    30 import com.sun.tools.doclets.internal.toolkit.*;
    31 import com.sun.tools.doclets.internal.toolkit.taglets.*;
    33 /**
    34  * Generate serialized form for Serializable/Externalizable methods.
    35  * Documentation denoted by the <code>serialData</code> tag is processed.
    36  *
    37  * @author Joe Fialli
    38  * @author Bhavesh Patel (Modified)
    39  */
    40 public class HtmlSerialMethodWriter extends MethodWriterImpl implements
    41         SerializedFormWriter.SerialMethodWriter{
    43     public HtmlSerialMethodWriter(SubWriterHolderWriter writer,
    44             ClassDoc classdoc) {
    45         super(writer, classdoc);
    46     }
    48     /**
    49      * Return the header for serializable methods section.
    50      *
    51      * @return a content tree for the header
    52      */
    53     public Content getSerializableMethodsHeader() {
    54         HtmlTree ul = new HtmlTree(HtmlTag.UL);
    55         ul.addStyle(HtmlStyle.blockList);
    56         return ul;
    57     }
    59     /**
    60      * Return the header for serializable methods content section.
    61      *
    62      * @param isLastContent true if the cotent being documented is the last content.
    63      * @return a content tree for the header
    64      */
    65     public Content getMethodsContentHeader(boolean isLastContent) {
    66         HtmlTree li = new HtmlTree(HtmlTag.LI);
    67         if (isLastContent)
    68             li.addStyle(HtmlStyle.blockListLast);
    69         else
    70             li.addStyle(HtmlStyle.blockList);
    71         return li;
    72     }
    74     /**
    75      * Add serializable methods.
    76      *
    77      * @param heading the heading for the section
    78      * @param serializableMethodContent the tree to be added to the serializable methods
    79      *        content tree
    80      * @return a content tree for the serializable methods content
    81      */
    82     public Content getSerializableMethods(String heading, Content serializableMethodContent) {
    83         Content li = HtmlTree.LI(HtmlStyle.blockList, writer.getMarkerAnchor(
    84                 "serialized_methods"));
    85         Content headingContent = new StringContent(heading);
    86         Content serialHeading = HtmlTree.HEADING(HtmlConstants.SERIALIZED_MEMBER_HEADING,
    87                 headingContent);
    88         li.addContent(serialHeading);
    89         li.addContent(serializableMethodContent);
    90         return li;
    91     }
    93     /**
    94      * Return the no customization message.
    95      *
    96      * @param msg the message to be displayed
    97      * @return no customization message content
    98      */
    99     public Content getNoCustomizationMsg(String msg) {
   100         Content noCustomizationMsg = new StringContent(msg);
   101         return noCustomizationMsg;
   102     }
   104     /**
   105      * Add the member header.
   106      *
   107      * @param member the method document to be listed
   108      * @param methodsContentTree the content tree to which the member header will be added
   109      */
   110     public void addMemberHeader(MethodDoc member, Content methodsContentTree) {
   111         methodsContentTree.addContent(writer.getMarkerAnchor(
   112                 writer.getAnchor(member)));
   113         methodsContentTree.addContent(getHead(member));
   114         methodsContentTree.addContent(getSignature(member));
   115     }
   117     /**
   118      * Add the deprecated information for this member.
   119      *
   120      * @param member the method to document.
   121      * @param methodsContentTree the tree to which the deprecated info will be added
   122      */
   123     public void addDeprecatedMemberInfo(MethodDoc member, Content methodsContentTree) {
   124         addDeprecatedInfo(member, methodsContentTree);
   125     }
   127     /**
   128      * Add the description text for this member.
   129      *
   130      * @param member the method to document.
   131      * @param methodsContentTree the tree to which the deprecated info will be added
   132      */
   133     public void addMemberDescription(MethodDoc member, Content methodsContentTree) {
   134         addComment(member, methodsContentTree);
   135     }
   137     /**
   138      * Add the tag information for this member.
   139      *
   140      * @param member the method to document.
   141      * @param methodsContentTree the tree to which the member tags info will be added
   142      */
   143     public void addMemberTags(MethodDoc member, Content methodsContentTree) {
   144         TagletOutputImpl output = new TagletOutputImpl("");
   145         TagletManager tagletManager =
   146             ConfigurationImpl.getInstance().tagletManager;
   147         TagletWriter.genTagOuput(tagletManager, member,
   148             tagletManager.getSerializedFormTags(),
   149             writer.getTagletWriterInstance(false), output);
   150         String outputString = output.toString().trim();
   151         Content dlTags = new HtmlTree(HtmlTag.DL);
   152         if (!outputString.isEmpty()) {
   153             Content tagContent = new RawHtml(outputString);
   154             dlTags.addContent(tagContent);
   155         }
   156         methodsContentTree.addContent(dlTags);
   157         MethodDoc method = member;
   158         if (method.name().compareTo("writeExternal") == 0
   159                 && method.tags("serialData").length == 0) {
   160             serialWarning(member.position(), "doclet.MissingSerialDataTag",
   161                 method.containingClass().qualifiedName(), method.name());
   162         }
   163     }
   165     protected void printTypeLinkNoDimension(Type type) {
   166         ClassDoc cd = type.asClassDoc();
   167         if (type.isPrimitive() || cd.isPackagePrivate()) {
   168             print(type.typeName());
   169         } else {
   170             writer.printLink(new LinkInfoImpl(
   171                 LinkInfoImpl.CONTEXT_SERIAL_MEMBER,type));
   172         }
   173     }
   174 }

mercurial