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

Sat, 07 Nov 2020 10:30:02 +0800

author
aoqi
date
Sat, 07 Nov 2020 10:30:02 +0800
changeset 3938
93012e2a5d1d
parent 2525
2eb010b6cb22
permissions
-rw-r--r--

Added tag mips-jdk8u275-b01 for changeset eb6ee6a5f2fe

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation. Oracle designates this
aoqi@0 8 * particular file as subject to the "Classpath" exception as provided
aoqi@0 9 * by Oracle in the LICENSE file that accompanied this code.
aoqi@0 10 *
aoqi@0 11 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 14 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 15 * accompanied this code).
aoqi@0 16 *
aoqi@0 17 * You should have received a copy of the GNU General Public License version
aoqi@0 18 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 20 *
aoqi@0 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 22 * or visit www.oracle.com if you need additional information or have any
aoqi@0 23 * questions.
aoqi@0 24 */
aoqi@0 25
aoqi@0 26 package com.sun.tools.doclets.formats.html;
aoqi@0 27
aoqi@0 28 import java.io.*;
aoqi@0 29 import com.sun.javadoc.*;
aoqi@0 30 import com.sun.tools.doclets.formats.html.markup.*;
aoqi@0 31 import com.sun.tools.doclets.internal.toolkit.*;
aoqi@0 32 import com.sun.tools.doclets.internal.toolkit.util.DocPaths;
aoqi@0 33 import com.sun.tools.doclets.internal.toolkit.util.DocletAbortException;
aoqi@0 34
aoqi@0 35 /**
aoqi@0 36 * Generate the Serialized Form Information Page.
aoqi@0 37 *
aoqi@0 38 * <p><b>This is NOT part of any supported API.
aoqi@0 39 * If you write code that depends on this, you do so at your own risk.
aoqi@0 40 * This code and its internal interfaces are subject to change or
aoqi@0 41 * deletion without notice.</b>
aoqi@0 42 *
aoqi@0 43 * @author Atul M Dambalkar
aoqi@0 44 */
aoqi@0 45 public class SerializedFormWriterImpl extends SubWriterHolderWriter
aoqi@0 46 implements SerializedFormWriter {
aoqi@0 47
aoqi@0 48 /**
aoqi@0 49 * @param configuration the configuration data for the doclet
aoqi@0 50 * @throws IOException
aoqi@0 51 * @throws DocletAbortException
aoqi@0 52 */
aoqi@0 53 public SerializedFormWriterImpl(ConfigurationImpl configuration)
aoqi@0 54 throws IOException {
aoqi@0 55 super(configuration, DocPaths.SERIALIZED_FORM);
aoqi@0 56 }
aoqi@0 57
aoqi@0 58 /**
aoqi@0 59 * Get the given header.
aoqi@0 60 *
aoqi@0 61 * @param header the header to write
aoqi@0 62 * @return the body content tree
aoqi@0 63 */
aoqi@0 64 public Content getHeader(String header) {
aoqi@0 65 Content bodyTree = getBody(true, getWindowTitle(header));
aoqi@0 66 addTop(bodyTree);
aoqi@0 67 addNavLinks(true, bodyTree);
aoqi@0 68 Content h1Content = new StringContent(header);
aoqi@0 69 Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
aoqi@0 70 HtmlStyle.title, h1Content);
aoqi@0 71 Content div = HtmlTree.DIV(HtmlStyle.header, heading);
aoqi@0 72 bodyTree.addContent(div);
aoqi@0 73 return bodyTree;
aoqi@0 74 }
aoqi@0 75
aoqi@0 76 /**
aoqi@0 77 * Get the serialized form summaries header.
aoqi@0 78 *
aoqi@0 79 * @return the serialized form summary header tree
aoqi@0 80 */
aoqi@0 81 public Content getSerializedSummariesHeader() {
aoqi@0 82 HtmlTree ul = new HtmlTree(HtmlTag.UL);
aoqi@0 83 ul.addStyle(HtmlStyle.blockList);
aoqi@0 84 return ul;
aoqi@0 85 }
aoqi@0 86
aoqi@0 87 /**
aoqi@0 88 * Get the package serialized form header.
aoqi@0 89 *
aoqi@0 90 * @return the package serialized form header tree
aoqi@0 91 */
aoqi@0 92 public Content getPackageSerializedHeader() {
aoqi@0 93 HtmlTree li = new HtmlTree(HtmlTag.LI);
aoqi@0 94 li.addStyle(HtmlStyle.blockList);
aoqi@0 95 return li;
aoqi@0 96 }
aoqi@0 97
aoqi@0 98 /**
aoqi@0 99 * Get the given package header.
aoqi@0 100 *
aoqi@0 101 * @param packageName the package header to write
aoqi@0 102 * @return a content tree for the package header
aoqi@0 103 */
aoqi@0 104 public Content getPackageHeader(String packageName) {
aoqi@0 105 Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true,
aoqi@0 106 packageLabel);
aoqi@0 107 heading.addContent(getSpace());
aoqi@0 108 heading.addContent(packageName);
aoqi@0 109 return heading;
aoqi@0 110 }
aoqi@0 111
aoqi@0 112 /**
aoqi@0 113 * Get the serialized class header.
aoqi@0 114 *
aoqi@0 115 * @return a content tree for the serialized class header
aoqi@0 116 */
aoqi@0 117 public Content getClassSerializedHeader() {
aoqi@0 118 HtmlTree ul = new HtmlTree(HtmlTag.UL);
aoqi@0 119 ul.addStyle(HtmlStyle.blockList);
aoqi@0 120 return ul;
aoqi@0 121 }
aoqi@0 122
aoqi@0 123 /**
aoqi@0 124 * Get the serializable class heading.
aoqi@0 125 *
aoqi@0 126 * @param classDoc the class being processed
aoqi@0 127 * @return a content tree for the class header
aoqi@0 128 */
aoqi@0 129 public Content getClassHeader(ClassDoc classDoc) {
aoqi@0 130 Content classLink = (classDoc.isPublic() || classDoc.isProtected()) ?
aoqi@0 131 getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.DEFAULT, classDoc)
aoqi@0 132 .label(configuration.getClassName(classDoc))) :
aoqi@0 133 new StringContent(classDoc.qualifiedName());
aoqi@0 134 Content li = HtmlTree.LI(HtmlStyle.blockList, getMarkerAnchor(
aoqi@0 135 classDoc.qualifiedName()));
aoqi@0 136 Content superClassLink =
aoqi@0 137 classDoc.superclassType() != null ?
aoqi@0 138 getLink(new LinkInfoImpl(configuration,
aoqi@0 139 LinkInfoImpl.Kind.SERIALIZED_FORM,
aoqi@0 140 classDoc.superclassType())) :
aoqi@0 141 null;
aoqi@0 142
aoqi@0 143 //Print the heading.
aoqi@0 144 Content className = superClassLink == null ?
aoqi@0 145 configuration.getResource(
aoqi@0 146 "doclet.Class_0_implements_serializable", classLink) :
aoqi@0 147 configuration.getResource(
aoqi@0 148 "doclet.Class_0_extends_implements_serializable", classLink,
aoqi@0 149 superClassLink);
aoqi@0 150 li.addContent(HtmlTree.HEADING(HtmlConstants.SERIALIZED_MEMBER_HEADING,
aoqi@0 151 className));
aoqi@0 152 return li;
aoqi@0 153 }
aoqi@0 154
aoqi@0 155 /**
aoqi@0 156 * Get the serial UID info header.
aoqi@0 157 *
aoqi@0 158 * @return a content tree for the serial uid info header
aoqi@0 159 */
aoqi@0 160 public Content getSerialUIDInfoHeader() {
aoqi@0 161 HtmlTree dl = new HtmlTree(HtmlTag.DL);
aoqi@0 162 dl.addStyle(HtmlStyle.nameValue);
aoqi@0 163 return dl;
aoqi@0 164 }
aoqi@0 165
aoqi@0 166 /**
aoqi@0 167 * Adds the serial UID info.
aoqi@0 168 *
aoqi@0 169 * @param header the header that will show up before the UID.
aoqi@0 170 * @param serialUID the serial UID to print.
aoqi@0 171 * @param serialUidTree the serial UID content tree to which the serial UID
aoqi@0 172 * content will be added
aoqi@0 173 */
aoqi@0 174 public void addSerialUIDInfo(String header, String serialUID,
aoqi@0 175 Content serialUidTree) {
aoqi@0 176 Content headerContent = new StringContent(header);
aoqi@0 177 serialUidTree.addContent(HtmlTree.DT(headerContent));
aoqi@0 178 Content serialContent = new StringContent(serialUID);
aoqi@0 179 serialUidTree.addContent(HtmlTree.DD(serialContent));
aoqi@0 180 }
aoqi@0 181
aoqi@0 182 /**
aoqi@0 183 * Get the class serialize content header.
aoqi@0 184 *
aoqi@0 185 * @return a content tree for the class serialize content header
aoqi@0 186 */
aoqi@0 187 public Content getClassContentHeader() {
aoqi@0 188 HtmlTree ul = new HtmlTree(HtmlTag.UL);
aoqi@0 189 ul.addStyle(HtmlStyle.blockList);
aoqi@0 190 return ul;
aoqi@0 191 }
aoqi@0 192
aoqi@0 193 /**
aoqi@0 194 * Get the serialized content tree section.
aoqi@0 195 *
aoqi@0 196 * @param serializedTreeContent the serialized content tree to be added
aoqi@0 197 * @return a div content tree
aoqi@0 198 */
aoqi@0 199 public Content getSerializedContent(Content serializedTreeContent) {
aoqi@0 200 Content divContent = HtmlTree.DIV(HtmlStyle.serializedFormContainer,
aoqi@0 201 serializedTreeContent);
aoqi@0 202 return divContent;
aoqi@0 203 }
aoqi@0 204
aoqi@0 205 /**
aoqi@0 206 * Add the footer.
aoqi@0 207 *
aoqi@0 208 * @param serializedTree the serialized tree to be added
aoqi@0 209 */
aoqi@0 210 public void addFooter(Content serializedTree) {
aoqi@0 211 addNavLinks(false, serializedTree);
aoqi@0 212 addBottom(serializedTree);
aoqi@0 213 }
aoqi@0 214
aoqi@0 215 /**
aoqi@0 216 * {@inheritDoc}
aoqi@0 217 */
aoqi@0 218 public void printDocument(Content serializedTree) throws IOException {
aoqi@0 219 printHtmlDocument(null, true, serializedTree);
aoqi@0 220 }
aoqi@0 221
aoqi@0 222 /**
aoqi@0 223 * Return an instance of a SerialFieldWriter.
aoqi@0 224 *
aoqi@0 225 * @return an instance of a SerialFieldWriter.
aoqi@0 226 */
aoqi@0 227 public SerialFieldWriter getSerialFieldWriter(ClassDoc classDoc) {
aoqi@0 228 return new HtmlSerialFieldWriter(this, classDoc);
aoqi@0 229 }
aoqi@0 230
aoqi@0 231 /**
aoqi@0 232 * Return an instance of a SerialMethodWriter.
aoqi@0 233 *
aoqi@0 234 * @return an instance of a SerialMethodWriter.
aoqi@0 235 */
aoqi@0 236 public SerialMethodWriter getSerialMethodWriter(ClassDoc classDoc) {
aoqi@0 237 return new HtmlSerialMethodWriter(this, classDoc);
aoqi@0 238 }
aoqi@0 239 }

mercurial