aoqi@0: /* aoqi@0: * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. aoqi@0: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: * aoqi@0: * This code is free software; you can redistribute it and/or modify it aoqi@0: * under the terms of the GNU General Public License version 2 only, as aoqi@0: * published by the Free Software Foundation. Oracle designates this aoqi@0: * particular file as subject to the "Classpath" exception as provided aoqi@0: * by Oracle in the LICENSE file that accompanied this code. aoqi@0: * aoqi@0: * This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: * version 2 for more details (a copy is included in the LICENSE file that aoqi@0: * accompanied this code). aoqi@0: * aoqi@0: * You should have received a copy of the GNU General Public License version aoqi@0: * 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: * aoqi@0: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: * or visit www.oracle.com if you need additional information or have any aoqi@0: * questions. aoqi@0: */ aoqi@0: aoqi@0: package com.sun.tools.doclets.formats.html; aoqi@0: aoqi@0: import java.io.*; aoqi@0: import com.sun.javadoc.*; aoqi@0: import com.sun.tools.doclets.formats.html.markup.*; aoqi@0: import com.sun.tools.doclets.internal.toolkit.*; aoqi@0: import com.sun.tools.doclets.internal.toolkit.util.DocPaths; aoqi@0: import com.sun.tools.doclets.internal.toolkit.util.DocletAbortException; aoqi@0: aoqi@0: /** aoqi@0: * Generate the Serialized Form Information Page. aoqi@0: * aoqi@0: *

This is NOT part of any supported API. aoqi@0: * If you write code that depends on this, you do so at your own risk. aoqi@0: * This code and its internal interfaces are subject to change or aoqi@0: * deletion without notice. aoqi@0: * aoqi@0: * @author Atul M Dambalkar aoqi@0: */ aoqi@0: public class SerializedFormWriterImpl extends SubWriterHolderWriter aoqi@0: implements SerializedFormWriter { aoqi@0: aoqi@0: /** aoqi@0: * @param configuration the configuration data for the doclet aoqi@0: * @throws IOException aoqi@0: * @throws DocletAbortException aoqi@0: */ aoqi@0: public SerializedFormWriterImpl(ConfigurationImpl configuration) aoqi@0: throws IOException { aoqi@0: super(configuration, DocPaths.SERIALIZED_FORM); aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * Get the given header. aoqi@0: * aoqi@0: * @param header the header to write aoqi@0: * @return the body content tree aoqi@0: */ aoqi@0: public Content getHeader(String header) { aoqi@0: Content bodyTree = getBody(true, getWindowTitle(header)); aoqi@0: addTop(bodyTree); aoqi@0: addNavLinks(true, bodyTree); aoqi@0: Content h1Content = new StringContent(header); aoqi@0: Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true, aoqi@0: HtmlStyle.title, h1Content); aoqi@0: Content div = HtmlTree.DIV(HtmlStyle.header, heading); aoqi@0: bodyTree.addContent(div); aoqi@0: return bodyTree; aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * Get the serialized form summaries header. aoqi@0: * aoqi@0: * @return the serialized form summary header tree aoqi@0: */ aoqi@0: public Content getSerializedSummariesHeader() { aoqi@0: HtmlTree ul = new HtmlTree(HtmlTag.UL); aoqi@0: ul.addStyle(HtmlStyle.blockList); aoqi@0: return ul; aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * Get the package serialized form header. aoqi@0: * aoqi@0: * @return the package serialized form header tree aoqi@0: */ aoqi@0: public Content getPackageSerializedHeader() { aoqi@0: HtmlTree li = new HtmlTree(HtmlTag.LI); aoqi@0: li.addStyle(HtmlStyle.blockList); aoqi@0: return li; aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * Get the given package header. aoqi@0: * aoqi@0: * @param packageName the package header to write aoqi@0: * @return a content tree for the package header aoqi@0: */ aoqi@0: public Content getPackageHeader(String packageName) { aoqi@0: Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true, aoqi@0: packageLabel); aoqi@0: heading.addContent(getSpace()); aoqi@0: heading.addContent(packageName); aoqi@0: return heading; aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * Get the serialized class header. aoqi@0: * aoqi@0: * @return a content tree for the serialized class header aoqi@0: */ aoqi@0: public Content getClassSerializedHeader() { aoqi@0: HtmlTree ul = new HtmlTree(HtmlTag.UL); aoqi@0: ul.addStyle(HtmlStyle.blockList); aoqi@0: return ul; aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * Get the serializable class heading. aoqi@0: * aoqi@0: * @param classDoc the class being processed aoqi@0: * @return a content tree for the class header aoqi@0: */ aoqi@0: public Content getClassHeader(ClassDoc classDoc) { aoqi@0: Content classLink = (classDoc.isPublic() || classDoc.isProtected()) ? aoqi@0: getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.DEFAULT, classDoc) aoqi@0: .label(configuration.getClassName(classDoc))) : aoqi@0: new StringContent(classDoc.qualifiedName()); aoqi@0: Content li = HtmlTree.LI(HtmlStyle.blockList, getMarkerAnchor( aoqi@0: classDoc.qualifiedName())); aoqi@0: Content superClassLink = aoqi@0: classDoc.superclassType() != null ? aoqi@0: getLink(new LinkInfoImpl(configuration, aoqi@0: LinkInfoImpl.Kind.SERIALIZED_FORM, aoqi@0: classDoc.superclassType())) : aoqi@0: null; aoqi@0: aoqi@0: //Print the heading. aoqi@0: Content className = superClassLink == null ? aoqi@0: configuration.getResource( aoqi@0: "doclet.Class_0_implements_serializable", classLink) : aoqi@0: configuration.getResource( aoqi@0: "doclet.Class_0_extends_implements_serializable", classLink, aoqi@0: superClassLink); aoqi@0: li.addContent(HtmlTree.HEADING(HtmlConstants.SERIALIZED_MEMBER_HEADING, aoqi@0: className)); aoqi@0: return li; aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * Get the serial UID info header. aoqi@0: * aoqi@0: * @return a content tree for the serial uid info header aoqi@0: */ aoqi@0: public Content getSerialUIDInfoHeader() { aoqi@0: HtmlTree dl = new HtmlTree(HtmlTag.DL); aoqi@0: dl.addStyle(HtmlStyle.nameValue); aoqi@0: return dl; aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * Adds the serial UID info. aoqi@0: * aoqi@0: * @param header the header that will show up before the UID. aoqi@0: * @param serialUID the serial UID to print. aoqi@0: * @param serialUidTree the serial UID content tree to which the serial UID aoqi@0: * content will be added aoqi@0: */ aoqi@0: public void addSerialUIDInfo(String header, String serialUID, aoqi@0: Content serialUidTree) { aoqi@0: Content headerContent = new StringContent(header); aoqi@0: serialUidTree.addContent(HtmlTree.DT(headerContent)); aoqi@0: Content serialContent = new StringContent(serialUID); aoqi@0: serialUidTree.addContent(HtmlTree.DD(serialContent)); aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * Get the class serialize content header. aoqi@0: * aoqi@0: * @return a content tree for the class serialize content header aoqi@0: */ aoqi@0: public Content getClassContentHeader() { aoqi@0: HtmlTree ul = new HtmlTree(HtmlTag.UL); aoqi@0: ul.addStyle(HtmlStyle.blockList); aoqi@0: return ul; aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * Get the serialized content tree section. aoqi@0: * aoqi@0: * @param serializedTreeContent the serialized content tree to be added aoqi@0: * @return a div content tree aoqi@0: */ aoqi@0: public Content getSerializedContent(Content serializedTreeContent) { aoqi@0: Content divContent = HtmlTree.DIV(HtmlStyle.serializedFormContainer, aoqi@0: serializedTreeContent); aoqi@0: return divContent; aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * Add the footer. aoqi@0: * aoqi@0: * @param serializedTree the serialized tree to be added aoqi@0: */ aoqi@0: public void addFooter(Content serializedTree) { aoqi@0: addNavLinks(false, serializedTree); aoqi@0: addBottom(serializedTree); aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * {@inheritDoc} aoqi@0: */ aoqi@0: public void printDocument(Content serializedTree) throws IOException { aoqi@0: printHtmlDocument(null, true, serializedTree); aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * Return an instance of a SerialFieldWriter. aoqi@0: * aoqi@0: * @return an instance of a SerialFieldWriter. aoqi@0: */ aoqi@0: public SerialFieldWriter getSerialFieldWriter(ClassDoc classDoc) { aoqi@0: return new HtmlSerialFieldWriter(this, classDoc); aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * Return an instance of a SerialMethodWriter. aoqi@0: * aoqi@0: * @return an instance of a SerialMethodWriter. aoqi@0: */ aoqi@0: public SerialMethodWriter getSerialMethodWriter(ClassDoc classDoc) { aoqi@0: return new HtmlSerialMethodWriter(this, classDoc); aoqi@0: } aoqi@0: }