1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java Wed Apr 27 01:34:52 2016 +0800 1.3 @@ -0,0 +1,305 @@ 1.4 +/* 1.5 + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. Oracle designates this 1.11 + * particular file as subject to the "Classpath" exception as provided 1.12 + * by Oracle in the LICENSE file that accompanied this code. 1.13 + * 1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.17 + * version 2 for more details (a copy is included in the LICENSE file that 1.18 + * accompanied this code). 1.19 + * 1.20 + * You should have received a copy of the GNU General Public License version 1.21 + * 2 along with this work; if not, write to the Free Software Foundation, 1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.23 + * 1.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.25 + * or visit www.oracle.com if you need additional information or have any 1.26 + * questions. 1.27 + */ 1.28 + 1.29 +package com.sun.tools.doclets.formats.html; 1.30 + 1.31 +import java.io.*; 1.32 + 1.33 +import com.sun.javadoc.*; 1.34 +import com.sun.tools.doclets.formats.html.markup.*; 1.35 +import com.sun.tools.doclets.internal.toolkit.*; 1.36 + 1.37 +/** 1.38 + * Writes annotation type required member documentation in HTML format. 1.39 + * 1.40 + * <p><b>This is NOT part of any supported API. 1.41 + * If you write code that depends on this, you do so at your own risk. 1.42 + * This code and its internal interfaces are subject to change or 1.43 + * deletion without notice.</b> 1.44 + * 1.45 + * @author Jamie Ho 1.46 + * @author Bhavesh Patel (Modified) 1.47 + */ 1.48 +public class AnnotationTypeRequiredMemberWriterImpl extends AbstractMemberWriter 1.49 + implements AnnotationTypeRequiredMemberWriter, MemberSummaryWriter { 1.50 + 1.51 + /** 1.52 + * Construct a new AnnotationTypeRequiredMemberWriterImpl. 1.53 + * 1.54 + * @param writer the writer that will write the output. 1.55 + * @param annotationType the AnnotationType that holds this member. 1.56 + */ 1.57 + public AnnotationTypeRequiredMemberWriterImpl(SubWriterHolderWriter writer, 1.58 + AnnotationTypeDoc annotationType) { 1.59 + super(writer, annotationType); 1.60 + } 1.61 + 1.62 + /** 1.63 + * {@inheritDoc} 1.64 + */ 1.65 + public Content getMemberSummaryHeader(ClassDoc classDoc, 1.66 + Content memberSummaryTree) { 1.67 + memberSummaryTree.addContent( 1.68 + HtmlConstants.START_OF_ANNOTATION_TYPE_REQUIRED_MEMBER_SUMMARY); 1.69 + Content memberTree = writer.getMemberTreeHeader(); 1.70 + writer.addSummaryHeader(this, classDoc, memberTree); 1.71 + return memberTree; 1.72 + } 1.73 + 1.74 + /** 1.75 + * {@inheritDoc} 1.76 + */ 1.77 + public Content getMemberTreeHeader() { 1.78 + return writer.getMemberTreeHeader(); 1.79 + } 1.80 + 1.81 + /** 1.82 + * {@inheritDoc} 1.83 + */ 1.84 + public void addAnnotationDetailsMarker(Content memberDetails) { 1.85 + memberDetails.addContent(HtmlConstants.START_OF_ANNOTATION_TYPE_DETAILS); 1.86 + } 1.87 + 1.88 + /** 1.89 + * {@inheritDoc} 1.90 + */ 1.91 + public void addAnnotationDetailsTreeHeader(ClassDoc classDoc, 1.92 + Content memberDetailsTree) { 1.93 + if (!writer.printedAnnotationHeading) { 1.94 + memberDetailsTree.addContent(writer.getMarkerAnchor( 1.95 + SectionName.ANNOTATION_TYPE_ELEMENT_DETAIL)); 1.96 + Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING, 1.97 + writer.annotationTypeDetailsLabel); 1.98 + memberDetailsTree.addContent(heading); 1.99 + writer.printedAnnotationHeading = true; 1.100 + } 1.101 + } 1.102 + 1.103 + /** 1.104 + * {@inheritDoc} 1.105 + */ 1.106 + public Content getAnnotationDocTreeHeader(MemberDoc member, 1.107 + Content annotationDetailsTree) { 1.108 + annotationDetailsTree.addContent( 1.109 + writer.getMarkerAnchor(member.name() + 1.110 + ((ExecutableMemberDoc) member).signature())); 1.111 + Content annotationDocTree = writer.getMemberTreeHeader(); 1.112 + Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING); 1.113 + heading.addContent(member.name()); 1.114 + annotationDocTree.addContent(heading); 1.115 + return annotationDocTree; 1.116 + } 1.117 + 1.118 + /** 1.119 + * {@inheritDoc} 1.120 + */ 1.121 + public Content getSignature(MemberDoc member) { 1.122 + Content pre = new HtmlTree(HtmlTag.PRE); 1.123 + writer.addAnnotationInfo(member, pre); 1.124 + addModifiers(member, pre); 1.125 + Content link = 1.126 + writer.getLink(new LinkInfoImpl(configuration, 1.127 + LinkInfoImpl.Kind.MEMBER, getType(member))); 1.128 + pre.addContent(link); 1.129 + pre.addContent(writer.getSpace()); 1.130 + if (configuration.linksource) { 1.131 + Content memberName = new StringContent(member.name()); 1.132 + writer.addSrcLink(member, memberName, pre); 1.133 + } else { 1.134 + addName(member.name(), pre); 1.135 + } 1.136 + return pre; 1.137 + } 1.138 + 1.139 + /** 1.140 + * {@inheritDoc} 1.141 + */ 1.142 + public void addDeprecated(MemberDoc member, Content annotationDocTree) { 1.143 + addDeprecatedInfo(member, annotationDocTree); 1.144 + } 1.145 + 1.146 + /** 1.147 + * {@inheritDoc} 1.148 + */ 1.149 + public void addComments(MemberDoc member, Content annotationDocTree) { 1.150 + addComment(member, annotationDocTree); 1.151 + } 1.152 + 1.153 + /** 1.154 + * {@inheritDoc} 1.155 + */ 1.156 + public void addTags(MemberDoc member, Content annotationDocTree) { 1.157 + writer.addTagsInfo(member, annotationDocTree); 1.158 + } 1.159 + 1.160 + /** 1.161 + * {@inheritDoc} 1.162 + */ 1.163 + public Content getAnnotationDetails(Content annotationDetailsTree) { 1.164 + return getMemberTree(annotationDetailsTree); 1.165 + } 1.166 + 1.167 + /** 1.168 + * {@inheritDoc} 1.169 + */ 1.170 + public Content getAnnotationDoc(Content annotationDocTree, 1.171 + boolean isLastContent) { 1.172 + return getMemberTree(annotationDocTree, isLastContent); 1.173 + } 1.174 + 1.175 + /** 1.176 + * Close the writer. 1.177 + */ 1.178 + public void close() throws IOException { 1.179 + writer.close(); 1.180 + } 1.181 + 1.182 + /** 1.183 + * {@inheritDoc} 1.184 + */ 1.185 + public void addSummaryLabel(Content memberTree) { 1.186 + Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING, 1.187 + writer.getResource("doclet.Annotation_Type_Required_Member_Summary")); 1.188 + memberTree.addContent(label); 1.189 + } 1.190 + 1.191 + /** 1.192 + * {@inheritDoc} 1.193 + */ 1.194 + public String getTableSummary() { 1.195 + return configuration.getText("doclet.Member_Table_Summary", 1.196 + configuration.getText("doclet.Annotation_Type_Required_Member_Summary"), 1.197 + configuration.getText("doclet.annotation_type_required_members")); 1.198 + } 1.199 + 1.200 + /** 1.201 + * {@inheritDoc} 1.202 + */ 1.203 + public Content getCaption() { 1.204 + return configuration.getResource("doclet.Annotation_Type_Required_Members"); 1.205 + } 1.206 + 1.207 + /** 1.208 + * {@inheritDoc} 1.209 + */ 1.210 + public String[] getSummaryTableHeader(ProgramElementDoc member) { 1.211 + String[] header = new String[] { 1.212 + writer.getModifierTypeHeader(), 1.213 + configuration.getText("doclet.0_and_1", 1.214 + configuration.getText("doclet.Annotation_Type_Required_Member"), 1.215 + configuration.getText("doclet.Description")) 1.216 + }; 1.217 + return header; 1.218 + } 1.219 + 1.220 + /** 1.221 + * {@inheritDoc} 1.222 + */ 1.223 + public void addSummaryAnchor(ClassDoc cd, Content memberTree) { 1.224 + memberTree.addContent(writer.getMarkerAnchor( 1.225 + SectionName.ANNOTATION_TYPE_REQUIRED_ELEMENT_SUMMARY)); 1.226 + } 1.227 + 1.228 + /** 1.229 + * {@inheritDoc} 1.230 + */ 1.231 + public void addInheritedSummaryAnchor(ClassDoc cd, Content inheritedTree) { 1.232 + } 1.233 + 1.234 + /** 1.235 + * {@inheritDoc} 1.236 + */ 1.237 + public void addInheritedSummaryLabel(ClassDoc cd, Content inheritedTree) { 1.238 + } 1.239 + 1.240 + /** 1.241 + * {@inheritDoc} 1.242 + */ 1.243 + protected void addSummaryLink(LinkInfoImpl.Kind context, ClassDoc cd, ProgramElementDoc member, 1.244 + Content tdSummary) { 1.245 + Content memberLink = HtmlTree.SPAN(HtmlStyle.memberNameLink, 1.246 + writer.getDocLink(context, (MemberDoc) member, member.name(), false)); 1.247 + Content code = HtmlTree.CODE(memberLink); 1.248 + tdSummary.addContent(code); 1.249 + } 1.250 + 1.251 + /** 1.252 + * {@inheritDoc} 1.253 + */ 1.254 + protected void addInheritedSummaryLink(ClassDoc cd, 1.255 + ProgramElementDoc member, Content linksTree) { 1.256 + //Not applicable. 1.257 + } 1.258 + 1.259 + /** 1.260 + * {@inheritDoc} 1.261 + */ 1.262 + protected void addSummaryType(ProgramElementDoc member, Content tdSummaryType) { 1.263 + MemberDoc m = (MemberDoc)member; 1.264 + addModifierAndType(m, getType(m), tdSummaryType); 1.265 + } 1.266 + 1.267 + /** 1.268 + * {@inheritDoc} 1.269 + */ 1.270 + protected Content getDeprecatedLink(ProgramElementDoc member) { 1.271 + return writer.getDocLink(LinkInfoImpl.Kind.MEMBER, 1.272 + (MemberDoc) member, ((MemberDoc)member).qualifiedName()); 1.273 + } 1.274 + 1.275 + /** 1.276 + * {@inheritDoc} 1.277 + */ 1.278 + protected Content getNavSummaryLink(ClassDoc cd, boolean link) { 1.279 + if (link) { 1.280 + return writer.getHyperLink( 1.281 + SectionName.ANNOTATION_TYPE_REQUIRED_ELEMENT_SUMMARY, 1.282 + writer.getResource("doclet.navAnnotationTypeRequiredMember")); 1.283 + } else { 1.284 + return writer.getResource("doclet.navAnnotationTypeRequiredMember"); 1.285 + } 1.286 + } 1.287 + 1.288 + /** 1.289 + * {@inheritDoc} 1.290 + */ 1.291 + protected void addNavDetailLink(boolean link, Content liNav) { 1.292 + if (link) { 1.293 + liNav.addContent(writer.getHyperLink( 1.294 + SectionName.ANNOTATION_TYPE_ELEMENT_DETAIL, 1.295 + writer.getResource("doclet.navAnnotationTypeMember"))); 1.296 + } else { 1.297 + liNav.addContent(writer.getResource("doclet.navAnnotationTypeMember")); 1.298 + } 1.299 + } 1.300 + 1.301 + private Type getType(MemberDoc member) { 1.302 + if (member instanceof FieldDoc) { 1.303 + return ((FieldDoc) member).type(); 1.304 + } else { 1.305 + return ((MethodDoc) member).returnType(); 1.306 + } 1.307 + } 1.308 +}