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

Sat, 13 Apr 2013 18:48:29 -0700

author
bpatel
date
Sat, 13 Apr 2013 18:48:29 -0700
changeset 1691
f10cffab99b4
parent 1410
bfec2a1cc869
child 1735
8ea30d59ac41
permissions
-rw-r--r--

8009686: Generated javadoc documentation should be able to display type annotation on an array
Reviewed-by: jjg

     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 java.io.*;
    29 import com.sun.javadoc.*;
    30 import com.sun.tools.doclets.formats.html.markup.*;
    31 import com.sun.tools.doclets.internal.toolkit.*;
    32 import com.sun.tools.doclets.internal.toolkit.util.DocPaths;
    33 import com.sun.tools.doclets.internal.toolkit.util.DocletAbortException;
    35 /**
    36  * Generate the Serialized Form Information Page.
    37  *
    38  *  <p><b>This is NOT part of any supported API.
    39  *  If you write code that depends on this, you do so at your own risk.
    40  *  This code and its internal interfaces are subject to change or
    41  *  deletion without notice.</b>
    42  *
    43  * @author Atul M Dambalkar
    44  */
    45 public class SerializedFormWriterImpl extends SubWriterHolderWriter
    46     implements SerializedFormWriter {
    48     /**
    49      * @param configuration the configuration data for the doclet
    50      * @throws IOException
    51      * @throws DocletAbortException
    52      */
    53     public SerializedFormWriterImpl(ConfigurationImpl configuration)
    54             throws IOException {
    55         super(configuration, DocPaths.SERIALIZED_FORM);
    56     }
    58     /**
    59      * Get the given header.
    60      *
    61      * @param header the header to write
    62      * @return the body content tree
    63      */
    64     public Content getHeader(String header) {
    65         Content bodyTree = getBody(true, getWindowTitle(header));
    66         addTop(bodyTree);
    67         addNavLinks(true, bodyTree);
    68         Content h1Content = new StringContent(header);
    69         Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
    70                 HtmlStyle.title, h1Content);
    71         Content div = HtmlTree.DIV(HtmlStyle.header, heading);
    72         bodyTree.addContent(div);
    73         return bodyTree;
    74     }
    76     /**
    77      * Get the serialized form summaries header.
    78      *
    79      * @return the serialized form summary header tree
    80      */
    81     public Content getSerializedSummariesHeader() {
    82         HtmlTree ul = new HtmlTree(HtmlTag.UL);
    83         ul.addStyle(HtmlStyle.blockList);
    84         return ul;
    85     }
    87     /**
    88      * Get the package serialized form header.
    89      *
    90      * @return the package serialized form header tree
    91      */
    92     public Content getPackageSerializedHeader() {
    93         HtmlTree li = new HtmlTree(HtmlTag.LI);
    94         li.addStyle(HtmlStyle.blockList);
    95         return li;
    96     }
    98     /**
    99      * Get the given package header.
   100      *
   101      * @param packageName the package header to write
   102      * @return a content tree for the package header
   103      */
   104     public Content getPackageHeader(String packageName) {
   105         Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true,
   106                 packageLabel);
   107         heading.addContent(getSpace());
   108         heading.addContent(packageName);
   109         return heading;
   110     }
   112     /**
   113      * Get the serialized class header.
   114      *
   115      * @return a content tree for the serialized class header
   116      */
   117     public Content getClassSerializedHeader() {
   118         HtmlTree ul = new HtmlTree(HtmlTag.UL);
   119         ul.addStyle(HtmlStyle.blockList);
   120         return ul;
   121     }
   123     /**
   124      * Get the serializable class heading.
   125      *
   126      * @param classDoc the class being processed
   127      * @return a content tree for the class header
   128      */
   129     public Content getClassHeader(ClassDoc classDoc) {
   130         String classLink = (classDoc.isPublic() || classDoc.isProtected())?
   131             getLink(new LinkInfoImpl(configuration, classDoc,
   132             configuration.getClassName(classDoc))):
   133             classDoc.qualifiedName();
   134         Content li = HtmlTree.LI(HtmlStyle.blockList, getMarkerAnchor(
   135                 classDoc.qualifiedName()));
   136         String superClassLink =
   137             classDoc.superclassType() != null ?
   138                 getLink(new LinkInfoImpl(configuration,
   139                         LinkInfoImpl.CONTEXT_SERIALIZED_FORM,
   140                         classDoc.superclassType())) :
   141                 null;
   143         //Print the heading.
   144         String className = superClassLink == null ?
   145             configuration.getText(
   146             "doclet.Class_0_implements_serializable", classLink) :
   147             configuration.getText(
   148             "doclet.Class_0_extends_implements_serializable", classLink,
   149             superClassLink);
   150         Content classNameContent = new RawHtml(className);
   151         li.addContent(HtmlTree.HEADING(HtmlConstants.SERIALIZED_MEMBER_HEADING,
   152                 classNameContent));
   153         return li;
   154     }
   156     /**
   157      * Get the serial UID info header.
   158      *
   159      * @return a content tree for the serial uid info header
   160      */
   161     public Content getSerialUIDInfoHeader() {
   162         HtmlTree dl = new HtmlTree(HtmlTag.DL);
   163         dl.addStyle(HtmlStyle.nameValue);
   164         return dl;
   165     }
   167     /**
   168      * Adds the serial UID info.
   169      *
   170      * @param header the header that will show up before the UID.
   171      * @param serialUID the serial UID to print.
   172      * @param serialUidTree the serial UID content tree to which the serial UID
   173      *                      content will be added
   174      */
   175     public void addSerialUIDInfo(String header, String serialUID,
   176             Content serialUidTree) {
   177         Content headerContent = new StringContent(header);
   178         serialUidTree.addContent(HtmlTree.DT(headerContent));
   179         Content serialContent = new StringContent(serialUID);
   180         serialUidTree.addContent(HtmlTree.DD(serialContent));
   181     }
   183     /**
   184      * Get the class serialize content header.
   185      *
   186      * @return a content tree for the class serialize content header
   187      */
   188     public Content getClassContentHeader() {
   189         HtmlTree ul = new HtmlTree(HtmlTag.UL);
   190         ul.addStyle(HtmlStyle.blockList);
   191         return ul;
   192     }
   194     /**
   195      * Get the serialized content tree section.
   196      *
   197      * @param serializedTreeContent the serialized content tree to be added
   198      * @return a div content tree
   199      */
   200     public Content getSerializedContent(Content serializedTreeContent) {
   201         Content divContent = HtmlTree.DIV(HtmlStyle.serializedFormContainer,
   202                 serializedTreeContent);
   203         return divContent;
   204     }
   206     /**
   207      * Add the footer.
   208      *
   209      * @param serializedTree the serialized tree to be added
   210      */
   211     public void addFooter(Content serializedTree) {
   212         addNavLinks(false, serializedTree);
   213         addBottom(serializedTree);
   214     }
   216     /**
   217      * {@inheritDoc}
   218      */
   219     public void printDocument(Content serializedTree) throws IOException {
   220         printHtmlDocument(null, true, serializedTree);
   221     }
   223     /**
   224      * Return an instance of a SerialFieldWriter.
   225      *
   226      * @return an instance of a SerialFieldWriter.
   227      */
   228     public SerialFieldWriter getSerialFieldWriter(ClassDoc classDoc) {
   229         return new HtmlSerialFieldWriter(this, classDoc);
   230     }
   232     /**
   233      * Return an instance of a SerialMethodWriter.
   234      *
   235      * @return an instance of a SerialMethodWriter.
   236      */
   237     public SerialMethodWriter getSerialMethodWriter(ClassDoc classDoc) {
   238         return new HtmlSerialMethodWriter(this, classDoc);
   239     }
   240 }

mercurial