HtmlSerialMethodWriter.java revision 3233:b5d08bc0d224
1240116Smarcel/* 2240116Smarcel * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved. 3240116Smarcel * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4240116Smarcel * 5240116Smarcel * This code is free software; you can redistribute it and/or modify it 6240116Smarcel * under the terms of the GNU General Public License version 2 only, as 7240116Smarcel * published by the Free Software Foundation. Oracle designates this 8240116Smarcel * particular file as subject to the "Classpath" exception as provided 9240116Smarcel * by Oracle in the LICENSE file that accompanied this code. 10240116Smarcel * 11240116Smarcel * This code is distributed in the hope that it will be useful, but WITHOUT 12240116Smarcel * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13240116Smarcel * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14240116Smarcel * version 2 for more details (a copy is included in the LICENSE file that 15240116Smarcel * accompanied this code). 16240116Smarcel * 17240116Smarcel * You should have received a copy of the GNU General Public License version 18240116Smarcel * 2 along with this work; if not, write to the Free Software Foundation, 19240116Smarcel * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20240116Smarcel * 21240116Smarcel * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22240116Smarcel * or visit www.oracle.com if you need additional information or have any 23240116Smarcel * questions. 24240116Smarcel */ 25240116Smarcel 26273929Sjmmvpackage jdk.javadoc.internal.doclets.formats.html; 27273929Sjmmv 28240116Smarcelimport javax.lang.model.element.ExecutableElement; 29240116Smarcelimport javax.lang.model.element.TypeElement; 30240116Smarcel 31240116Smarcelimport jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder; 32273929Sjmmvimport jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants; 33240116Smarcelimport jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; 34240116Smarcelimport jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; 35240116Smarcelimport jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; 36240116Smarcelimport jdk.javadoc.internal.doclets.formats.html.markup.StringContent; 37240116Smarcelimport jdk.javadoc.internal.doclets.toolkit.Content; 38240116Smarcelimport jdk.javadoc.internal.doclets.toolkit.SerializedFormWriter; 39240116Smarcelimport jdk.javadoc.internal.doclets.toolkit.taglets.TagletManager; 40240116Smarcelimport jdk.javadoc.internal.doclets.toolkit.taglets.TagletWriter; 41240116Smarcel 42240116Smarcel 43240116Smarcel/** 44240116Smarcel * Generate serialized form for Serializable/Externalizable methods. 45240116Smarcel * Documentation denoted by the <code>serialData</code> tag is processed. 46240116Smarcel * 47240116Smarcel * <p><b>This is NOT part of any supported API. 48240116Smarcel * If you write code that depends on this, you do so at your own risk. 49240116Smarcel * This code and its internal interfaces are subject to change or 50240116Smarcel * deletion without notice.</b> 51240116Smarcel * 52240116Smarcel * @author Joe Fialli 53240116Smarcel * @author Bhavesh Patel (Modified) 54240116Smarcel */ 55240116Smarcelpublic class HtmlSerialMethodWriter extends MethodWriterImpl implements 56240116Smarcel SerializedFormWriter.SerialMethodWriter{ 57240116Smarcel 58240116Smarcel public HtmlSerialMethodWriter(SubWriterHolderWriter writer, TypeElement typeElement) { 59240116Smarcel super(writer, typeElement); 60240116Smarcel } 61240116Smarcel 62240116Smarcel /** 63240116Smarcel * Return the header for serializable methods section. 64240116Smarcel * 65240116Smarcel * @return a content tree for the header 66240116Smarcel */ 67240116Smarcel public Content getSerializableMethodsHeader() { 68240116Smarcel HtmlTree ul = new HtmlTree(HtmlTag.UL); 69240116Smarcel ul.addStyle(HtmlStyle.blockList); 70240116Smarcel return ul; 71240116Smarcel } 72240116Smarcel 73240116Smarcel /** 74240116Smarcel * Return the header for serializable methods content section. 75240116Smarcel * 76240116Smarcel * @param isLastContent true if the cotent being documented is the last content. 77240116Smarcel * @return a content tree for the header 78240116Smarcel */ 79240116Smarcel public Content getMethodsContentHeader(boolean isLastContent) { 80240116Smarcel HtmlTree li = new HtmlTree(HtmlTag.LI); 81240116Smarcel if (isLastContent) 82240116Smarcel li.addStyle(HtmlStyle.blockListLast); 83240116Smarcel else 84240116Smarcel li.addStyle(HtmlStyle.blockList); 85240116Smarcel return li; 86240116Smarcel } 87240116Smarcel 88240116Smarcel /** 89240116Smarcel * Add serializable methods. 90240116Smarcel * 91240116Smarcel * @param heading the heading for the section 92240116Smarcel * @param serializableMethodContent the tree to be added to the serializable methods 93240116Smarcel * content tree 94240116Smarcel * @return a content tree for the serializable methods content 95240116Smarcel */ 96240116Smarcel public Content getSerializableMethods(String heading, Content serializableMethodContent) { 97240116Smarcel Content headingContent = new StringContent(heading); 98240116Smarcel Content serialHeading = HtmlTree.HEADING(HtmlConstants.SERIALIZED_MEMBER_HEADING, 99240116Smarcel headingContent); 100240116Smarcel Content li = HtmlTree.LI(HtmlStyle.blockList, serialHeading); 101240116Smarcel li.addContent(serializableMethodContent); 102240116Smarcel return li; 103240116Smarcel } 104240116Smarcel 105240116Smarcel /** 106240116Smarcel * Return the no customization message. 107240116Smarcel * 108240116Smarcel * @param msg the message to be displayed 109240116Smarcel * @return no customization message content 110240116Smarcel */ 111240116Smarcel public Content getNoCustomizationMsg(String msg) { 112240116Smarcel Content noCustomizationMsg = new StringContent(msg); 113240116Smarcel return noCustomizationMsg; 114240116Smarcel } 115240116Smarcel 116240116Smarcel /** 117240116Smarcel * Add the member header. 118240116Smarcel * 119240116Smarcel * @param member the method document to be listed 120240116Smarcel * @param methodsContentTree the content tree to which the member header will be added 121240116Smarcel */ 122240116Smarcel public void addMemberHeader(ExecutableElement member, Content methodsContentTree) { 123240116Smarcel methodsContentTree.addContent(getHead(member)); 124240116Smarcel methodsContentTree.addContent(getSignature(member)); 125240116Smarcel } 126240116Smarcel 127240116Smarcel /** 128240116Smarcel * Add the deprecated information for this member. 129240116Smarcel * 130240116Smarcel * @param member the method to document. 131240116Smarcel * @param methodsContentTree the tree to which the deprecated info will be added 132240116Smarcel */ 133240116Smarcel public void addDeprecatedMemberInfo(ExecutableElement member, Content methodsContentTree) { 134240116Smarcel addDeprecatedInfo(member, methodsContentTree); 135240116Smarcel } 136240116Smarcel 137240116Smarcel /** 138240116Smarcel * Add the description text for this member. 139240116Smarcel * 140240116Smarcel * @param member the method to document. 141240116Smarcel * @param methodsContentTree the tree to which the deprecated info will be added 142240116Smarcel */ 143240116Smarcel public void addMemberDescription(ExecutableElement member, Content methodsContentTree) { 144240116Smarcel addComment(member, methodsContentTree); 145240116Smarcel } 146240116Smarcel 147240116Smarcel /** 148240116Smarcel * Add the tag information for this member. 149240116Smarcel * 150240116Smarcel * @param member the method to document. 151240116Smarcel * @param methodsContentTree the tree to which the member tags info will be added 152240116Smarcel */ 153240116Smarcel public void addMemberTags(ExecutableElement member, Content methodsContentTree) { 154240116Smarcel Content tagContent = new ContentBuilder(); 155240116Smarcel TagletManager tagletManager = 156240116Smarcel configuration.tagletManager; 157240116Smarcel TagletWriter.genTagOutput(tagletManager, member, 158240116Smarcel tagletManager.getSerializedFormTaglets(), 159240116Smarcel writer.getTagletWriterInstance(false), tagContent); 160240116Smarcel Content dlTags = new HtmlTree(HtmlTag.DL); 161240116Smarcel dlTags.addContent(tagContent); 162240116Smarcel methodsContentTree.addContent(dlTags); 163240116Smarcel if (name(member).compareTo("writeExternal") == 0 164240116Smarcel && utils.getSerialDataTrees(member).isEmpty()) { 165240116Smarcel serialWarning(member, "doclet.MissingSerialDataTag", 166240116Smarcel utils.getFullyQualifiedName(member.getEnclosingElement()), name(member)); 167240116Smarcel } 168240116Smarcel } 169240116Smarcel} 170240116Smarcel