Sat, 07 Nov 2020 10:30:02 +0800
Added tag mips-jdk8u275-b01 for changeset eb6ee6a5f2fe
aoqi@0 | 1 | /* |
aoqi@0 | 2 | * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. |
aoqi@0 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
aoqi@0 | 4 | * |
aoqi@0 | 5 | * This code is free software; you can redistribute it and/or modify it |
aoqi@0 | 6 | * under the terms of the GNU General Public License version 2 only, as |
aoqi@0 | 7 | * published by the Free Software Foundation. Oracle designates this |
aoqi@0 | 8 | * particular file as subject to the "Classpath" exception as provided |
aoqi@0 | 9 | * by Oracle in the LICENSE file that accompanied this code. |
aoqi@0 | 10 | * |
aoqi@0 | 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
aoqi@0 | 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
aoqi@0 | 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
aoqi@0 | 14 | * version 2 for more details (a copy is included in the LICENSE file that |
aoqi@0 | 15 | * accompanied this code). |
aoqi@0 | 16 | * |
aoqi@0 | 17 | * You should have received a copy of the GNU General Public License version |
aoqi@0 | 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
aoqi@0 | 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
aoqi@0 | 20 | * |
aoqi@0 | 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
aoqi@0 | 22 | * or visit www.oracle.com if you need additional information or have any |
aoqi@0 | 23 | * questions. |
aoqi@0 | 24 | */ |
aoqi@0 | 25 | |
aoqi@0 | 26 | package com.sun.tools.doclets.internal.toolkit.builders; |
aoqi@0 | 27 | |
aoqi@0 | 28 | import java.io.*; |
aoqi@0 | 29 | import java.util.*; |
aoqi@0 | 30 | |
aoqi@0 | 31 | import com.sun.javadoc.*; |
aoqi@0 | 32 | import com.sun.tools.doclets.internal.toolkit.*; |
aoqi@0 | 33 | import com.sun.tools.doclets.internal.toolkit.util.*; |
aoqi@0 | 34 | |
aoqi@0 | 35 | /** |
aoqi@0 | 36 | * Builds the summary for a given annotation type. |
aoqi@0 | 37 | * |
aoqi@0 | 38 | * <p><b>This is NOT part of any supported API. |
aoqi@0 | 39 | * If you write code that depends on this, you do so at your own risk. |
aoqi@0 | 40 | * This code and its internal interfaces are subject to change or |
aoqi@0 | 41 | * deletion without notice.</b> |
aoqi@0 | 42 | * |
aoqi@0 | 43 | * @author Jamie Ho |
aoqi@0 | 44 | * @author Bhavesh Patel (Modified) |
aoqi@0 | 45 | * @since 1.5 |
aoqi@0 | 46 | */ |
aoqi@0 | 47 | public class AnnotationTypeBuilder extends AbstractBuilder { |
aoqi@0 | 48 | |
aoqi@0 | 49 | /** |
aoqi@0 | 50 | * The root element of the annotation type XML is {@value}. |
aoqi@0 | 51 | */ |
aoqi@0 | 52 | public static final String ROOT = "AnnotationTypeDoc"; |
aoqi@0 | 53 | |
aoqi@0 | 54 | /** |
aoqi@0 | 55 | * The annotation type being documented. |
aoqi@0 | 56 | */ |
aoqi@0 | 57 | private final AnnotationTypeDoc annotationTypeDoc; |
aoqi@0 | 58 | |
aoqi@0 | 59 | /** |
aoqi@0 | 60 | * The doclet specific writer. |
aoqi@0 | 61 | */ |
aoqi@0 | 62 | private final AnnotationTypeWriter writer; |
aoqi@0 | 63 | |
aoqi@0 | 64 | /** |
aoqi@0 | 65 | * The content tree for the annotation documentation. |
aoqi@0 | 66 | */ |
aoqi@0 | 67 | private Content contentTree; |
aoqi@0 | 68 | |
aoqi@0 | 69 | /** |
aoqi@0 | 70 | * Construct a new ClassBuilder. |
aoqi@0 | 71 | * |
aoqi@0 | 72 | * @param context the build context. |
aoqi@0 | 73 | * @param annotationTypeDoc the class being documented. |
aoqi@0 | 74 | * @param writer the doclet specific writer. |
aoqi@0 | 75 | */ |
aoqi@0 | 76 | private AnnotationTypeBuilder(Context context, |
aoqi@0 | 77 | AnnotationTypeDoc annotationTypeDoc, |
aoqi@0 | 78 | AnnotationTypeWriter writer) { |
aoqi@0 | 79 | super(context); |
aoqi@0 | 80 | this.annotationTypeDoc = annotationTypeDoc; |
aoqi@0 | 81 | this.writer = writer; |
aoqi@0 | 82 | } |
aoqi@0 | 83 | |
aoqi@0 | 84 | /** |
aoqi@0 | 85 | * Construct a new ClassBuilder. |
aoqi@0 | 86 | * |
aoqi@0 | 87 | * @param context the build context. |
aoqi@0 | 88 | * @param annotationTypeDoc the class being documented. |
aoqi@0 | 89 | * @param writer the doclet specific writer. |
aoqi@0 | 90 | */ |
aoqi@0 | 91 | public static AnnotationTypeBuilder getInstance(Context context, |
aoqi@0 | 92 | AnnotationTypeDoc annotationTypeDoc, |
aoqi@0 | 93 | AnnotationTypeWriter writer) |
aoqi@0 | 94 | throws Exception { |
aoqi@0 | 95 | return new AnnotationTypeBuilder(context, annotationTypeDoc, writer); |
aoqi@0 | 96 | } |
aoqi@0 | 97 | |
aoqi@0 | 98 | /** |
aoqi@0 | 99 | * {@inheritDoc} |
aoqi@0 | 100 | */ |
aoqi@0 | 101 | public void build() throws IOException { |
aoqi@0 | 102 | build(layoutParser.parseXML(ROOT), contentTree); |
aoqi@0 | 103 | } |
aoqi@0 | 104 | |
aoqi@0 | 105 | /** |
aoqi@0 | 106 | * {@inheritDoc} |
aoqi@0 | 107 | */ |
aoqi@0 | 108 | public String getName() { |
aoqi@0 | 109 | return ROOT; |
aoqi@0 | 110 | } |
aoqi@0 | 111 | |
aoqi@0 | 112 | /** |
aoqi@0 | 113 | * Build the annotation type documentation. |
aoqi@0 | 114 | * |
aoqi@0 | 115 | * @param node the XML element that specifies which components to document |
aoqi@0 | 116 | * @param contentTree the content tree to which the documentation will be added |
aoqi@0 | 117 | */ |
aoqi@0 | 118 | public void buildAnnotationTypeDoc(XMLNode node, Content contentTree) throws Exception { |
aoqi@0 | 119 | contentTree = writer.getHeader(configuration.getText("doclet.AnnotationType") + |
aoqi@0 | 120 | " " + annotationTypeDoc.name()); |
aoqi@0 | 121 | Content annotationContentTree = writer.getAnnotationContentHeader(); |
aoqi@0 | 122 | buildChildren(node, annotationContentTree); |
aoqi@0 | 123 | contentTree.addContent(annotationContentTree); |
aoqi@0 | 124 | writer.addFooter(contentTree); |
aoqi@0 | 125 | writer.printDocument(contentTree); |
aoqi@0 | 126 | writer.close(); |
aoqi@0 | 127 | copyDocFiles(); |
aoqi@0 | 128 | } |
aoqi@0 | 129 | |
aoqi@0 | 130 | /** |
aoqi@0 | 131 | * Copy the doc files for the current ClassDoc if necessary. |
aoqi@0 | 132 | */ |
aoqi@0 | 133 | private void copyDocFiles() { |
aoqi@0 | 134 | PackageDoc containingPackage = annotationTypeDoc.containingPackage(); |
aoqi@0 | 135 | if((configuration.packages == null || |
aoqi@0 | 136 | Arrays.binarySearch(configuration.packages, |
aoqi@0 | 137 | containingPackage) < 0) && |
aoqi@0 | 138 | ! containingPackagesSeen.contains(containingPackage.name())){ |
aoqi@0 | 139 | //Only copy doc files dir if the containing package is not |
aoqi@0 | 140 | //documented AND if we have not documented a class from the same |
aoqi@0 | 141 | //package already. Otherwise, we are making duplicate copies. |
aoqi@0 | 142 | Util.copyDocFiles(configuration, containingPackage); |
aoqi@0 | 143 | containingPackagesSeen.add(containingPackage.name()); |
aoqi@0 | 144 | } |
aoqi@0 | 145 | } |
aoqi@0 | 146 | |
aoqi@0 | 147 | /** |
aoqi@0 | 148 | * Build the annotation information tree documentation. |
aoqi@0 | 149 | * |
aoqi@0 | 150 | * @param node the XML element that specifies which components to document |
aoqi@0 | 151 | * @param annotationContentTree the content tree to which the documentation will be added |
aoqi@0 | 152 | */ |
aoqi@0 | 153 | public void buildAnnotationTypeInfo(XMLNode node, Content annotationContentTree) { |
aoqi@0 | 154 | Content annotationInfoTree = writer.getAnnotationInfoTreeHeader(); |
aoqi@0 | 155 | buildChildren(node, annotationInfoTree); |
aoqi@0 | 156 | annotationContentTree.addContent(writer.getAnnotationInfo(annotationInfoTree)); |
aoqi@0 | 157 | } |
aoqi@0 | 158 | |
aoqi@0 | 159 | /** |
aoqi@0 | 160 | * If this annotation is deprecated, build the appropriate information. |
aoqi@0 | 161 | * |
aoqi@0 | 162 | * @param node the XML element that specifies which components to document |
aoqi@0 | 163 | * @param annotationInfoTree the content tree to which the documentation will be added |
aoqi@0 | 164 | */ |
aoqi@0 | 165 | public void buildDeprecationInfo (XMLNode node, Content annotationInfoTree) { |
aoqi@0 | 166 | writer.addAnnotationTypeDeprecationInfo(annotationInfoTree); |
aoqi@0 | 167 | } |
aoqi@0 | 168 | |
aoqi@0 | 169 | /** |
aoqi@0 | 170 | * Build the signature of the current annotation type. |
aoqi@0 | 171 | * |
aoqi@0 | 172 | * @param node the XML element that specifies which components to document |
aoqi@0 | 173 | * @param annotationInfoTree the content tree to which the documentation will be added |
aoqi@0 | 174 | */ |
aoqi@0 | 175 | public void buildAnnotationTypeSignature(XMLNode node, Content annotationInfoTree) { |
aoqi@0 | 176 | StringBuilder modifiers = new StringBuilder( |
aoqi@0 | 177 | annotationTypeDoc.modifiers() + " "); |
aoqi@0 | 178 | writer.addAnnotationTypeSignature(Util.replaceText( |
aoqi@0 | 179 | modifiers.toString(), "interface", "@interface"), annotationInfoTree); |
aoqi@0 | 180 | } |
aoqi@0 | 181 | |
aoqi@0 | 182 | /** |
aoqi@0 | 183 | * Build the annotation type description. |
aoqi@0 | 184 | * |
aoqi@0 | 185 | * @param node the XML element that specifies which components to document |
aoqi@0 | 186 | * @param annotationInfoTree the content tree to which the documentation will be added |
aoqi@0 | 187 | */ |
aoqi@0 | 188 | public void buildAnnotationTypeDescription(XMLNode node, Content annotationInfoTree) { |
aoqi@0 | 189 | writer.addAnnotationTypeDescription(annotationInfoTree); |
aoqi@0 | 190 | } |
aoqi@0 | 191 | |
aoqi@0 | 192 | /** |
aoqi@0 | 193 | * Build the tag information for the current annotation type. |
aoqi@0 | 194 | * |
aoqi@0 | 195 | * @param node the XML element that specifies which components to document |
aoqi@0 | 196 | * @param annotationInfoTree the content tree to which the documentation will be added |
aoqi@0 | 197 | */ |
aoqi@0 | 198 | public void buildAnnotationTypeTagInfo(XMLNode node, Content annotationInfoTree) { |
aoqi@0 | 199 | writer.addAnnotationTypeTagInfo(annotationInfoTree); |
aoqi@0 | 200 | } |
aoqi@0 | 201 | |
aoqi@0 | 202 | /** |
aoqi@0 | 203 | * Build the member summary contents of the page. |
aoqi@0 | 204 | * |
aoqi@0 | 205 | * @param node the XML element that specifies which components to document |
aoqi@0 | 206 | * @param annotationContentTree the content tree to which the documentation will be added |
aoqi@0 | 207 | */ |
aoqi@0 | 208 | public void buildMemberSummary(XMLNode node, Content annotationContentTree) |
aoqi@0 | 209 | throws Exception { |
aoqi@0 | 210 | Content memberSummaryTree = writer.getMemberTreeHeader(); |
aoqi@0 | 211 | configuration.getBuilderFactory(). |
aoqi@0 | 212 | getMemberSummaryBuilder(writer).buildChildren(node, memberSummaryTree); |
aoqi@0 | 213 | annotationContentTree.addContent(writer.getMemberSummaryTree(memberSummaryTree)); |
aoqi@0 | 214 | } |
aoqi@0 | 215 | |
aoqi@0 | 216 | /** |
aoqi@0 | 217 | * Build the member details contents of the page. |
aoqi@0 | 218 | * |
aoqi@0 | 219 | * @param node the XML element that specifies which components to document |
aoqi@0 | 220 | * @param annotationContentTree the content tree to which the documentation will be added |
aoqi@0 | 221 | */ |
aoqi@0 | 222 | public void buildAnnotationTypeMemberDetails(XMLNode node, Content annotationContentTree) { |
aoqi@0 | 223 | Content memberDetailsTree = writer.getMemberTreeHeader(); |
aoqi@0 | 224 | buildChildren(node, memberDetailsTree); |
aoqi@0 | 225 | if (memberDetailsTree.isValid()) { |
aoqi@0 | 226 | annotationContentTree.addContent(writer.getMemberDetailsTree(memberDetailsTree)); |
aoqi@0 | 227 | } |
aoqi@0 | 228 | } |
aoqi@0 | 229 | |
aoqi@0 | 230 | /** |
aoqi@0 | 231 | * Build the annotation type field documentation. |
aoqi@0 | 232 | * |
aoqi@0 | 233 | * @param node the XML element that specifies which components to document |
aoqi@0 | 234 | * @param memberDetailsTree the content tree to which the documentation will be added |
aoqi@0 | 235 | */ |
aoqi@0 | 236 | public void buildAnnotationTypeFieldDetails(XMLNode node, Content memberDetailsTree) |
aoqi@0 | 237 | throws Exception { |
aoqi@0 | 238 | configuration.getBuilderFactory(). |
aoqi@0 | 239 | getAnnotationTypeFieldsBuilder(writer).buildChildren(node, memberDetailsTree); |
aoqi@0 | 240 | } |
aoqi@0 | 241 | |
aoqi@0 | 242 | /** |
aoqi@0 | 243 | * Build the annotation type optional member documentation. |
aoqi@0 | 244 | * |
aoqi@0 | 245 | * @param node the XML element that specifies which components to document |
aoqi@0 | 246 | * @param memberDetailsTree the content tree to which the documentation will be added |
aoqi@0 | 247 | */ |
aoqi@0 | 248 | public void buildAnnotationTypeOptionalMemberDetails(XMLNode node, Content memberDetailsTree) |
aoqi@0 | 249 | throws Exception { |
aoqi@0 | 250 | configuration.getBuilderFactory(). |
aoqi@0 | 251 | getAnnotationTypeOptionalMemberBuilder(writer).buildChildren(node, memberDetailsTree); |
aoqi@0 | 252 | } |
aoqi@0 | 253 | |
aoqi@0 | 254 | /** |
aoqi@0 | 255 | * Build the annotation type required member documentation. |
aoqi@0 | 256 | * |
aoqi@0 | 257 | * @param node the XML element that specifies which components to document |
aoqi@0 | 258 | * @param memberDetailsTree the content tree to which the documentation will be added |
aoqi@0 | 259 | */ |
aoqi@0 | 260 | public void buildAnnotationTypeRequiredMemberDetails(XMLNode node, Content memberDetailsTree) |
aoqi@0 | 261 | throws Exception { |
aoqi@0 | 262 | configuration.getBuilderFactory(). |
aoqi@0 | 263 | getAnnotationTypeRequiredMemberBuilder(writer).buildChildren(node, memberDetailsTree); |
aoqi@0 | 264 | } |
aoqi@0 | 265 | } |