Thu, 15 Nov 2012 19:54:20 -0800
8002079: update DocFile to use a JavaFileManager
Reviewed-by: darcy
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 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 li = HtmlTree.LI(HtmlStyle.blockList, writer.getMarkerAnchor(
89 "serialized_methods"));
90 Content headingContent = new StringContent(heading);
91 Content serialHeading = HtmlTree.HEADING(HtmlConstants.SERIALIZED_MEMBER_HEADING,
92 headingContent);
93 li.addContent(serialHeading);
94 li.addContent(serializableMethodContent);
95 return li;
96 }
98 /**
99 * Return the no customization message.
100 *
101 * @param msg the message to be displayed
102 * @return no customization message content
103 */
104 public Content getNoCustomizationMsg(String msg) {
105 Content noCustomizationMsg = new StringContent(msg);
106 return noCustomizationMsg;
107 }
109 /**
110 * Add the member header.
111 *
112 * @param member the method document to be listed
113 * @param methodsContentTree the content tree to which the member header will be added
114 */
115 public void addMemberHeader(MethodDoc member, Content methodsContentTree) {
116 methodsContentTree.addContent(writer.getMarkerAnchor(
117 writer.getAnchor(member)));
118 methodsContentTree.addContent(getHead(member));
119 methodsContentTree.addContent(getSignature(member));
120 }
122 /**
123 * Add the deprecated information for this member.
124 *
125 * @param member the method to document.
126 * @param methodsContentTree the tree to which the deprecated info will be added
127 */
128 public void addDeprecatedMemberInfo(MethodDoc member, Content methodsContentTree) {
129 addDeprecatedInfo(member, methodsContentTree);
130 }
132 /**
133 * Add the description text for this member.
134 *
135 * @param member the method to document.
136 * @param methodsContentTree the tree to which the deprecated info will be added
137 */
138 public void addMemberDescription(MethodDoc member, Content methodsContentTree) {
139 addComment(member, methodsContentTree);
140 }
142 /**
143 * Add the tag information for this member.
144 *
145 * @param member the method to document.
146 * @param methodsContentTree the tree to which the member tags info will be added
147 */
148 public void addMemberTags(MethodDoc member, Content methodsContentTree) {
149 TagletOutputImpl output = new TagletOutputImpl("");
150 TagletManager tagletManager =
151 configuration.tagletManager;
152 TagletWriter.genTagOuput(tagletManager, member,
153 tagletManager.getSerializedFormTags(),
154 writer.getTagletWriterInstance(false), output);
155 String outputString = output.toString().trim();
156 Content dlTags = new HtmlTree(HtmlTag.DL);
157 if (!outputString.isEmpty()) {
158 Content tagContent = new RawHtml(outputString);
159 dlTags.addContent(tagContent);
160 }
161 methodsContentTree.addContent(dlTags);
162 MethodDoc method = member;
163 if (method.name().compareTo("writeExternal") == 0
164 && method.tags("serialData").length == 0) {
165 serialWarning(member.position(), "doclet.MissingSerialDataTag",
166 method.containingClass().qualifiedName(), method.name());
167 }
168 }
169 }