duke@1: /* ohair@798: * Copyright (c) 1998, 2010, 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@233: import com.sun.javadoc.*; duke@1: import com.sun.tools.doclets.internal.toolkit.*; duke@1: import com.sun.tools.doclets.internal.toolkit.taglets.*; bpatel@766: import com.sun.tools.doclets.formats.html.markup.*; duke@1: duke@1: /** duke@1: * Generate serialized form for Serializable/Externalizable methods. duke@1: * Documentation denoted by the serialData tag is processed. duke@1: * duke@1: * @author Joe Fialli bpatel@766: * @author Bhavesh Patel (Modified) duke@1: */ duke@1: public class HtmlSerialMethodWriter extends MethodWriterImpl implements duke@1: SerializedFormWriter.SerialMethodWriter{ duke@1: duke@1: public HtmlSerialMethodWriter(SubWriterHolderWriter writer, duke@1: ClassDoc classdoc) { duke@1: super(writer, classdoc); duke@1: } duke@1: bpatel@766: /** bpatel@766: * Return the header for serializable methods section. bpatel@766: * bpatel@766: * @return a content tree for the header bpatel@766: */ bpatel@766: public Content getSerializableMethodsHeader() { bpatel@766: HtmlTree ul = new HtmlTree(HtmlTag.UL); bpatel@766: ul.addStyle(HtmlStyle.blockList); bpatel@766: return ul; duke@1: } duke@1: bpatel@766: /** bpatel@766: * Return the header for serializable methods content section. bpatel@766: * bpatel@766: * @param isLastContent true if the cotent being documented is the last content. bpatel@766: * @return a content tree for the header bpatel@766: */ bpatel@766: public Content getMethodsContentHeader(boolean isLastContent) { bpatel@766: HtmlTree li = new HtmlTree(HtmlTag.LI); bpatel@766: if (isLastContent) bpatel@766: li.addStyle(HtmlStyle.blockListLast); bpatel@766: else bpatel@766: li.addStyle(HtmlStyle.blockList); bpatel@766: return li; duke@1: } duke@1: bpatel@766: /** bpatel@766: * Add serializable methods. bpatel@766: * bpatel@766: * @param heading the heading for the section bpatel@766: * @param serializableMethodContent the tree to be added to the serializable methods bpatel@766: * content tree bpatel@766: * @return a content tree for the serializable methods content bpatel@766: */ bpatel@766: public Content getSerializableMethods(String heading, Content serializableMethodContent) { bpatel@766: Content li = HtmlTree.LI(HtmlStyle.blockList, writer.getMarkerAnchor( bpatel@766: "serialized_methods")); bpatel@766: Content headingContent = new StringContent(heading); bpatel@766: Content serialHeading = HtmlTree.HEADING(HtmlConstants.SERIALIZED_MEMBER_HEADING, bpatel@766: headingContent); bpatel@766: li.addContent(serialHeading); bpatel@766: li.addContent(serializableMethodContent); bpatel@766: return li; duke@1: } duke@1: bpatel@766: /** bpatel@766: * Return the no customization message. bpatel@766: * bpatel@766: * @param msg the message to be displayed bpatel@766: * @return no customization message content bpatel@766: */ bpatel@766: public Content getNoCustomizationMsg(String msg) { bpatel@766: Content noCustomizationMsg = new StringContent(msg); bpatel@766: return noCustomizationMsg; duke@1: } duke@1: bpatel@766: /** bpatel@766: * Add the member header. bpatel@766: * bpatel@766: * @param member the method document to be listed bpatel@766: * @param methodsContentTree the content tree to which the member header will be added bpatel@766: */ bpatel@766: public void addMemberHeader(MethodDoc member, Content methodsContentTree) { bpatel@766: methodsContentTree.addContent(writer.getMarkerAnchor( bpatel@766: writer.getAnchor(member))); bpatel@766: methodsContentTree.addContent(getHead(member)); bpatel@766: methodsContentTree.addContent(getSignature(member)); duke@1: } duke@1: bpatel@766: /** bpatel@766: * Add the deprecated information for this member. bpatel@766: * bpatel@766: * @param member the method to document. bpatel@766: * @param methodsContentTree the tree to which the deprecated info will be added bpatel@766: */ bpatel@766: public void addDeprecatedMemberInfo(MethodDoc member, Content methodsContentTree) { bpatel@766: addDeprecatedInfo(member, methodsContentTree); duke@1: } duke@1: bpatel@766: /** bpatel@766: * Add the description text for this member. bpatel@766: * bpatel@766: * @param member the method to document. bpatel@766: * @param methodsContentTree the tree to which the deprecated info will be added bpatel@766: */ bpatel@766: public void addMemberDescription(MethodDoc member, Content methodsContentTree) { bpatel@766: addComment(member, methodsContentTree); bpatel@766: } bpatel@766: bpatel@766: /** bpatel@766: * Add the tag information for this member. bpatel@766: * bpatel@766: * @param member the method to document. bpatel@766: * @param methodsContentTree the tree to which the member tags info will be added bpatel@766: */ bpatel@766: public void addMemberTags(MethodDoc member, Content methodsContentTree) { duke@1: TagletOutputImpl output = new TagletOutputImpl(""); duke@1: TagletManager tagletManager = duke@1: ConfigurationImpl.getInstance().tagletManager; duke@1: TagletWriter.genTagOuput(tagletManager, member, duke@1: tagletManager.getSerializedFormTags(), duke@1: writer.getTagletWriterInstance(false), output); bpatel@233: String outputString = output.toString().trim(); bpatel@766: Content dlTags = new HtmlTree(HtmlTag.DL); bpatel@233: if (!outputString.isEmpty()) { bpatel@766: Content tagContent = new RawHtml(outputString); bpatel@766: dlTags.addContent(tagContent); bpatel@233: } bpatel@766: methodsContentTree.addContent(dlTags); jjg@74: MethodDoc method = member; duke@1: if (method.name().compareTo("writeExternal") == 0 duke@1: && method.tags("serialData").length == 0) { duke@1: serialWarning(member.position(), "doclet.MissingSerialDataTag", duke@1: method.containingClass().qualifiedName(), method.name()); duke@1: } duke@1: } duke@1: duke@1: protected void printTypeLinkNoDimension(Type type) { duke@1: ClassDoc cd = type.asClassDoc(); duke@1: if (type.isPrimitive() || cd.isPackagePrivate()) { duke@1: print(type.typeName()); duke@1: } else { duke@1: writer.printLink(new LinkInfoImpl( duke@1: LinkInfoImpl.CONTEXT_SERIAL_MEMBER,type)); duke@1: } duke@1: } duke@1: }