1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeFieldWriterImpl.java Wed Sep 18 17:13:26 2013 -0700 1.3 @@ -0,0 +1,301 @@ 1.4 +/* 1.5 + * Copyright (c) 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 field 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 Bhavesh Patel 1.46 + */ 1.47 +public class AnnotationTypeFieldWriterImpl extends AbstractMemberWriter 1.48 + implements AnnotationTypeFieldWriter, MemberSummaryWriter { 1.49 + 1.50 + /** 1.51 + * Construct a new AnnotationTypeFieldWriterImpl. 1.52 + * 1.53 + * @param writer the writer that will write the output. 1.54 + * @param annotationType the AnnotationType that holds this member. 1.55 + */ 1.56 + public AnnotationTypeFieldWriterImpl(SubWriterHolderWriter writer, 1.57 + AnnotationTypeDoc annotationType) { 1.58 + super(writer, annotationType); 1.59 + } 1.60 + 1.61 + /** 1.62 + * {@inheritDoc} 1.63 + */ 1.64 + public Content getMemberSummaryHeader(ClassDoc classDoc, 1.65 + Content memberSummaryTree) { 1.66 + memberSummaryTree.addContent( 1.67 + HtmlConstants.START_OF_ANNOTATION_TYPE_FIELD_SUMMARY); 1.68 + Content memberTree = writer.getMemberTreeHeader(); 1.69 + writer.addSummaryHeader(this, classDoc, memberTree); 1.70 + return memberTree; 1.71 + } 1.72 + 1.73 + /** 1.74 + * {@inheritDoc} 1.75 + */ 1.76 + public Content getMemberTreeHeader() { 1.77 + return writer.getMemberTreeHeader(); 1.78 + } 1.79 + 1.80 + /** 1.81 + * {@inheritDoc} 1.82 + */ 1.83 + public void addAnnotationFieldDetailsMarker(Content memberDetails) { 1.84 + memberDetails.addContent(HtmlConstants.START_OF_ANNOTATION_TYPE_FIELD_DETAILS); 1.85 + } 1.86 + 1.87 + /** 1.88 + * {@inheritDoc} 1.89 + */ 1.90 + public void addAnnotationDetailsTreeHeader(ClassDoc classDoc, 1.91 + Content memberDetailsTree) { 1.92 + if (!writer.printedAnnotationFieldHeading) { 1.93 + memberDetailsTree.addContent(writer.getMarkerAnchor( 1.94 + "annotation_type_field_detail")); 1.95 + Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING, 1.96 + writer.fieldDetailsLabel); 1.97 + memberDetailsTree.addContent(heading); 1.98 + writer.printedAnnotationFieldHeading = true; 1.99 + } 1.100 + } 1.101 + 1.102 + /** 1.103 + * {@inheritDoc} 1.104 + */ 1.105 + public Content getAnnotationDocTreeHeader(MemberDoc member, 1.106 + Content annotationDetailsTree) { 1.107 + annotationDetailsTree.addContent( 1.108 + writer.getMarkerAnchor(member.name())); 1.109 + Content annotationDocTree = writer.getMemberTreeHeader(); 1.110 + Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING); 1.111 + heading.addContent(member.name()); 1.112 + annotationDocTree.addContent(heading); 1.113 + return annotationDocTree; 1.114 + } 1.115 + 1.116 + /** 1.117 + * {@inheritDoc} 1.118 + */ 1.119 + public Content getSignature(MemberDoc member) { 1.120 + Content pre = new HtmlTree(HtmlTag.PRE); 1.121 + writer.addAnnotationInfo(member, pre); 1.122 + addModifiers(member, pre); 1.123 + Content link = 1.124 + writer.getLink(new LinkInfoImpl(configuration, 1.125 + LinkInfoImpl.Kind.MEMBER, getType(member))); 1.126 + pre.addContent(link); 1.127 + pre.addContent(writer.getSpace()); 1.128 + if (configuration.linksource) { 1.129 + Content memberName = new StringContent(member.name()); 1.130 + writer.addSrcLink(member, memberName, pre); 1.131 + } else { 1.132 + addName(member.name(), pre); 1.133 + } 1.134 + return pre; 1.135 + } 1.136 + 1.137 + /** 1.138 + * {@inheritDoc} 1.139 + */ 1.140 + public void addDeprecated(MemberDoc member, Content annotationDocTree) { 1.141 + addDeprecatedInfo(member, annotationDocTree); 1.142 + } 1.143 + 1.144 + /** 1.145 + * {@inheritDoc} 1.146 + */ 1.147 + public void addComments(MemberDoc member, Content annotationDocTree) { 1.148 + addComment(member, annotationDocTree); 1.149 + } 1.150 + 1.151 + /** 1.152 + * {@inheritDoc} 1.153 + */ 1.154 + public void addTags(MemberDoc member, Content annotationDocTree) { 1.155 + writer.addTagsInfo(member, annotationDocTree); 1.156 + } 1.157 + 1.158 + /** 1.159 + * {@inheritDoc} 1.160 + */ 1.161 + public Content getAnnotationDetails(Content annotationDetailsTree) { 1.162 + return getMemberTree(annotationDetailsTree); 1.163 + } 1.164 + 1.165 + /** 1.166 + * {@inheritDoc} 1.167 + */ 1.168 + public Content getAnnotationDoc(Content annotationDocTree, 1.169 + boolean isLastContent) { 1.170 + return getMemberTree(annotationDocTree, isLastContent); 1.171 + } 1.172 + 1.173 + /** 1.174 + * Close the writer. 1.175 + */ 1.176 + public void close() throws IOException { 1.177 + writer.close(); 1.178 + } 1.179 + 1.180 + /** 1.181 + * {@inheritDoc} 1.182 + */ 1.183 + public void addSummaryLabel(Content memberTree) { 1.184 + Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING, 1.185 + writer.getResource("doclet.Field_Summary")); 1.186 + memberTree.addContent(label); 1.187 + } 1.188 + 1.189 + /** 1.190 + * {@inheritDoc} 1.191 + */ 1.192 + public String getTableSummary() { 1.193 + return configuration.getText("doclet.Member_Table_Summary", 1.194 + configuration.getText("doclet.Field_Summary"), 1.195 + configuration.getText("doclet.fields")); 1.196 + } 1.197 + 1.198 + /** 1.199 + * {@inheritDoc} 1.200 + */ 1.201 + public Content getCaption() { 1.202 + return configuration.getResource("doclet.Fields"); 1.203 + } 1.204 + 1.205 + /** 1.206 + * {@inheritDoc} 1.207 + */ 1.208 + public String[] getSummaryTableHeader(ProgramElementDoc member) { 1.209 + String[] header = new String[] { 1.210 + writer.getModifierTypeHeader(), 1.211 + configuration.getText("doclet.0_and_1", 1.212 + configuration.getText("doclet.Fields"), 1.213 + configuration.getText("doclet.Description")) 1.214 + }; 1.215 + return header; 1.216 + } 1.217 + 1.218 + /** 1.219 + * {@inheritDoc} 1.220 + */ 1.221 + public void addSummaryAnchor(ClassDoc cd, Content memberTree) { 1.222 + memberTree.addContent(writer.getMarkerAnchor( 1.223 + "annotation_type_field_summary")); 1.224 + } 1.225 + 1.226 + /** 1.227 + * {@inheritDoc} 1.228 + */ 1.229 + public void addInheritedSummaryAnchor(ClassDoc cd, Content inheritedTree) { 1.230 + } 1.231 + 1.232 + /** 1.233 + * {@inheritDoc} 1.234 + */ 1.235 + public void addInheritedSummaryLabel(ClassDoc cd, Content inheritedTree) { 1.236 + } 1.237 + 1.238 + /** 1.239 + * {@inheritDoc} 1.240 + */ 1.241 + protected void addSummaryLink(LinkInfoImpl.Kind context, ClassDoc cd, ProgramElementDoc member, 1.242 + Content tdSummary) { 1.243 + Content strong = HtmlTree.SPAN(HtmlStyle.strong, 1.244 + writer.getDocLink(context, (MemberDoc) member, member.name(), false)); 1.245 + Content code = HtmlTree.CODE(strong); 1.246 + tdSummary.addContent(code); 1.247 + } 1.248 + 1.249 + /** 1.250 + * {@inheritDoc} 1.251 + */ 1.252 + protected void addInheritedSummaryLink(ClassDoc cd, 1.253 + ProgramElementDoc member, Content linksTree) { 1.254 + //Not applicable. 1.255 + } 1.256 + 1.257 + /** 1.258 + * {@inheritDoc} 1.259 + */ 1.260 + protected void addSummaryType(ProgramElementDoc member, Content tdSummaryType) { 1.261 + MemberDoc m = (MemberDoc)member; 1.262 + addModifierAndType(m, getType(m), tdSummaryType); 1.263 + } 1.264 + 1.265 + /** 1.266 + * {@inheritDoc} 1.267 + */ 1.268 + protected Content getDeprecatedLink(ProgramElementDoc member) { 1.269 + return writer.getDocLink(LinkInfoImpl.Kind.MEMBER, 1.270 + (MemberDoc) member, ((MemberDoc)member).qualifiedName()); 1.271 + } 1.272 + 1.273 + /** 1.274 + * {@inheritDoc} 1.275 + */ 1.276 + protected Content getNavSummaryLink(ClassDoc cd, boolean link) { 1.277 + if (link) { 1.278 + return writer.getHyperLink("annotation_type_field_summary", 1.279 + writer.getResource("doclet.navField")); 1.280 + } else { 1.281 + return writer.getResource("doclet.navField"); 1.282 + } 1.283 + } 1.284 + 1.285 + /** 1.286 + * {@inheritDoc} 1.287 + */ 1.288 + protected void addNavDetailLink(boolean link, Content liNav) { 1.289 + if (link) { 1.290 + liNav.addContent(writer.getHyperLink("annotation_type_field_detail", 1.291 + writer.getResource("doclet.navField"))); 1.292 + } else { 1.293 + liNav.addContent(writer.getResource("doclet.navField")); 1.294 + } 1.295 + } 1.296 + 1.297 + private Type getType(MemberDoc member) { 1.298 + if (member instanceof FieldDoc) { 1.299 + return ((FieldDoc) member).type(); 1.300 + } else { 1.301 + return ((MethodDoc) member).returnType(); 1.302 + } 1.303 + } 1.304 +}