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

Thu, 31 Aug 2017 15:17:03 +0800

author
aoqi
date
Thu, 31 Aug 2017 15:17:03 +0800
changeset 2525
2eb010b6cb22
parent 2101
933ba3f81a87
parent 0
959103a6100f
permissions
-rw-r--r--

merge

     1 /*
     2  * Copyright (c) 1998, 2013, 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  *  <p><b>This is NOT part of any supported API.
    38  *  If you write code that depends on this, you do so at your own risk.
    39  *  This code and its internal interfaces are subject to change or
    40  *  deletion without notice.</b>
    41  *
    42  * @author Joe Fialli
    43  * @author Bhavesh Patel (Modified)
    44  */
    45 public class HtmlSerialMethodWriter extends MethodWriterImpl implements
    46         SerializedFormWriter.SerialMethodWriter{
    48     public HtmlSerialMethodWriter(SubWriterHolderWriter writer,
    49             ClassDoc classdoc) {
    50         super(writer, classdoc);
    51     }
    53     /**
    54      * Return the header for serializable methods section.
    55      *
    56      * @return a content tree for the header
    57      */
    58     public Content getSerializableMethodsHeader() {
    59         HtmlTree ul = new HtmlTree(HtmlTag.UL);
    60         ul.addStyle(HtmlStyle.blockList);
    61         return ul;
    62     }
    64     /**
    65      * Return the header for serializable methods content section.
    66      *
    67      * @param isLastContent true if the cotent being documented is the last content.
    68      * @return a content tree for the header
    69      */
    70     public Content getMethodsContentHeader(boolean isLastContent) {
    71         HtmlTree li = new HtmlTree(HtmlTag.LI);
    72         if (isLastContent)
    73             li.addStyle(HtmlStyle.blockListLast);
    74         else
    75             li.addStyle(HtmlStyle.blockList);
    76         return li;
    77     }
    79     /**
    80      * Add serializable methods.
    81      *
    82      * @param heading the heading for the section
    83      * @param serializableMethodContent the tree to be added to the serializable methods
    84      *        content tree
    85      * @return a content tree for the serializable methods content
    86      */
    87     public Content getSerializableMethods(String heading, Content serializableMethodContent) {
    88         Content headingContent = new StringContent(heading);
    89         Content serialHeading = HtmlTree.HEADING(HtmlConstants.SERIALIZED_MEMBER_HEADING,
    90                 headingContent);
    91         Content li = HtmlTree.LI(HtmlStyle.blockList, serialHeading);
    92         li.addContent(serializableMethodContent);
    93         return li;
    94     }
    96     /**
    97      * Return the no customization message.
    98      *
    99      * @param msg the message to be displayed
   100      * @return no customization message content
   101      */
   102     public Content getNoCustomizationMsg(String msg) {
   103         Content noCustomizationMsg = new StringContent(msg);
   104         return noCustomizationMsg;
   105     }
   107     /**
   108      * Add the member header.
   109      *
   110      * @param member the method document to be listed
   111      * @param methodsContentTree the content tree to which the member header will be added
   112      */
   113     public void addMemberHeader(MethodDoc member, Content methodsContentTree) {
   114         methodsContentTree.addContent(getHead(member));
   115         methodsContentTree.addContent(getSignature(member));
   116     }
   118     /**
   119      * Add the deprecated information for this member.
   120      *
   121      * @param member the method to document.
   122      * @param methodsContentTree the tree to which the deprecated info will be added
   123      */
   124     public void addDeprecatedMemberInfo(MethodDoc member, Content methodsContentTree) {
   125         addDeprecatedInfo(member, methodsContentTree);
   126     }
   128     /**
   129      * Add the description text for this member.
   130      *
   131      * @param member the method to document.
   132      * @param methodsContentTree the tree to which the deprecated info will be added
   133      */
   134     public void addMemberDescription(MethodDoc member, Content methodsContentTree) {
   135         addComment(member, methodsContentTree);
   136     }
   138     /**
   139      * Add the tag information for this member.
   140      *
   141      * @param member the method to document.
   142      * @param methodsContentTree the tree to which the member tags info will be added
   143      */
   144     public void addMemberTags(MethodDoc member, Content methodsContentTree) {
   145         Content tagContent = new ContentBuilder();
   146         TagletManager tagletManager =
   147             configuration.tagletManager;
   148         TagletWriter.genTagOuput(tagletManager, member,
   149             tagletManager.getSerializedFormTaglets(),
   150             writer.getTagletWriterInstance(false), tagContent);
   151         Content dlTags = new HtmlTree(HtmlTag.DL);
   152         dlTags.addContent(tagContent);
   153         methodsContentTree.addContent(dlTags);  // TODO: what if empty?
   154         MethodDoc method = member;
   155         if (method.name().compareTo("writeExternal") == 0
   156                 && method.tags("serialData").length == 0) {
   157             serialWarning(member.position(), "doclet.MissingSerialDataTag",
   158                 method.containingClass().qualifiedName(), method.name());
   159         }
   160     }
   161 }

mercurial