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

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