src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeRequiredMemberBuilder.java

Sun, 24 Feb 2013 11:36:58 -0800

author
jjg
date
Sun, 24 Feb 2013 11:36:58 -0800
changeset 1606
ccbe7ffdd867
parent 1410
bfec2a1cc869
child 2035
a2a5ad0853ed
permissions
-rw-r--r--

7112427: The doclet needs to be able to generate JavaFX documentation.
Reviewed-by: jjg
Contributed-by: jan.valenta@oracle.com

duke@1 1 /*
jjg@1606 2 * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
duke@1 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@1 4 *
duke@1 5 * This code is free software; you can redistribute it and/or modify it
duke@1 6 * under the terms of the GNU General Public License version 2 only, as
ohair@554 7 * published by the Free Software Foundation. Oracle designates this
duke@1 8 * particular file as subject to the "Classpath" exception as provided
ohair@554 9 * by Oracle in the LICENSE file that accompanied this code.
duke@1 10 *
duke@1 11 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@1 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@1 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@1 14 * version 2 for more details (a copy is included in the LICENSE file that
duke@1 15 * accompanied this code).
duke@1 16 *
duke@1 17 * You should have received a copy of the GNU General Public License version
duke@1 18 * 2 along with this work; if not, write to the Free Software Foundation,
duke@1 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@1 20 *
ohair@554 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ohair@554 22 * or visit www.oracle.com if you need additional information or have any
ohair@554 23 * questions.
duke@1 24 */
duke@1 25
duke@1 26 package com.sun.tools.doclets.internal.toolkit.builders;
duke@1 27
bpatel@766 28 import java.util.*;
jjg@1357 29
jjg@1357 30 import com.sun.javadoc.*;
jjg@1357 31 import com.sun.tools.doclets.internal.toolkit.*;
duke@1 32 import com.sun.tools.doclets.internal.toolkit.util.*;
duke@1 33
duke@1 34 /**
duke@1 35 * Builds documentation for required annotation type members.
duke@1 36 *
jjg@1359 37 * <p><b>This is NOT part of any supported API.
jjg@1359 38 * If you write code that depends on this, you do so at your own risk.
jjg@1359 39 * This code and its internal interfaces are subject to change or
jjg@1359 40 * deletion without notice.</b>
duke@1 41 *
duke@1 42 * @author Jamie Ho
bpatel@766 43 * @author Bhavesh Patel (Modified)
duke@1 44 * @since 1.5
duke@1 45 */
duke@1 46 public class AnnotationTypeRequiredMemberBuilder extends AbstractMemberBuilder {
duke@1 47
duke@1 48 /**
duke@1 49 * The annotation type whose members are being documented.
duke@1 50 */
duke@1 51 protected ClassDoc classDoc;
duke@1 52
duke@1 53 /**
duke@1 54 * The visible members for the given class.
duke@1 55 */
duke@1 56 protected VisibleMemberMap visibleMemberMap;
duke@1 57
duke@1 58 /**
duke@1 59 * The writer to output the member documentation.
duke@1 60 */
duke@1 61 protected AnnotationTypeRequiredMemberWriter writer;
duke@1 62
duke@1 63 /**
duke@1 64 * The list of members being documented.
duke@1 65 */
jjg@74 66 protected List<ProgramElementDoc> members;
duke@1 67
duke@1 68 /**
duke@1 69 * The index of the current member that is being documented at this point
duke@1 70 * in time.
duke@1 71 */
duke@1 72 protected int currentMemberIndex;
duke@1 73
duke@1 74 /**
duke@1 75 * Construct a new AnnotationTypeRequiredMemberBuilder.
duke@1 76 *
jjg@1410 77 * @param context the build context.
jjg@1410 78 * @param classDoc the class whose members are being documented.
jjg@1410 79 * @param writer the doclet specific writer.
duke@1 80 */
jjg@1410 81 protected AnnotationTypeRequiredMemberBuilder(Context context,
jjg@1410 82 ClassDoc classDoc,
jjg@1410 83 AnnotationTypeRequiredMemberWriter writer,
jjg@1410 84 int memberType) {
jjg@1410 85 super(context);
jjg@1410 86 this.classDoc = classDoc;
jjg@1410 87 this.writer = writer;
jjg@1410 88 this.visibleMemberMap = new VisibleMemberMap(classDoc, memberType,
jjg@1606 89 configuration);
jjg@1410 90 this.members = new ArrayList<ProgramElementDoc>(
jjg@1410 91 this.visibleMemberMap.getMembersFor(classDoc));
jjg@1410 92 if (configuration.getMemberComparator() != null) {
jjg@1410 93 Collections.sort(this.members, configuration.getMemberComparator());
jjg@1410 94 }
duke@1 95 }
duke@1 96
duke@1 97
duke@1 98 /**
duke@1 99 * Construct a new AnnotationTypeMemberBuilder.
duke@1 100 *
jjg@1410 101 * @param context the build context.
jjg@1410 102 * @param classDoc the class whose members are being documented.
duke@1 103 * @param writer the doclet specific writer.
duke@1 104 */
duke@1 105 public static AnnotationTypeRequiredMemberBuilder getInstance(
jjg@1410 106 Context context, ClassDoc classDoc,
duke@1 107 AnnotationTypeRequiredMemberWriter writer) {
jjg@1410 108 return new AnnotationTypeRequiredMemberBuilder(context, classDoc,
jjg@1410 109 writer,
jjg@1410 110 VisibleMemberMap.ANNOTATION_TYPE_MEMBER_REQUIRED);
duke@1 111 }
duke@1 112
duke@1 113 /**
duke@1 114 * {@inheritDoc}
duke@1 115 */
duke@1 116 public String getName() {
duke@1 117 return "AnnotationTypeRequiredMemberDetails";
duke@1 118 }
duke@1 119
duke@1 120 /**
duke@1 121 * Returns a list of members that will be documented for the given class.
duke@1 122 * This information can be used for doclet specific documentation
duke@1 123 * generation.
duke@1 124 *
duke@1 125 * @param classDoc the {@link ClassDoc} we want to check.
duke@1 126 * @return a list of members that will be documented.
duke@1 127 */
mcimadamore@184 128 public List<ProgramElementDoc> members(ClassDoc classDoc) {
duke@1 129 return visibleMemberMap.getMembersFor(classDoc);
duke@1 130 }
duke@1 131
duke@1 132 /**
duke@1 133 * Returns the visible member map for the members of this class.
duke@1 134 *
duke@1 135 * @return the visible member map for the members of this class.
duke@1 136 */
duke@1 137 public VisibleMemberMap getVisibleMemberMap() {
duke@1 138 return visibleMemberMap;
duke@1 139 }
duke@1 140
duke@1 141 /**
duke@1 142 * summaryOrder.size()
duke@1 143 */
duke@1 144 public boolean hasMembersToDocument() {
duke@1 145 return members.size() > 0;
duke@1 146 }
duke@1 147
duke@1 148 /**
bpatel@766 149 * Build the annotation type required member documentation.
bpatel@766 150 *
bpatel@766 151 * @param node the XML element that specifies which components to document
bpatel@766 152 * @param memberDetailsTree the content tree to which the documentation will be added
bpatel@766 153 */
bpatel@766 154 public void buildAnnotationTypeRequiredMember(XMLNode node, Content memberDetailsTree) {
bpatel@766 155 buildAnnotationTypeMember(node, memberDetailsTree);
bpatel@766 156 }
bpatel@766 157
bpatel@766 158 /**
duke@1 159 * Build the member documentation.
duke@1 160 *
bpatel@766 161 * @param node the XML element that specifies which components to document
bpatel@766 162 * @param memberDetailsTree the content tree to which the documentation will be added
duke@1 163 */
bpatel@766 164 public void buildAnnotationTypeMember(XMLNode node, Content memberDetailsTree) {
duke@1 165 if (writer == null) {
duke@1 166 return;
duke@1 167 }
bpatel@766 168 int size = members.size();
bpatel@766 169 if (size > 0) {
bpatel@766 170 writer.addAnnotationDetailsTreeHeader(
bpatel@766 171 classDoc, memberDetailsTree);
bpatel@766 172 for (currentMemberIndex = 0; currentMemberIndex < size;
duke@1 173 currentMemberIndex++) {
bpatel@766 174 Content annotationDocTree = writer.getAnnotationDocTreeHeader(
bpatel@766 175 (MemberDoc) members.get(currentMemberIndex),
bpatel@766 176 memberDetailsTree);
bpatel@766 177 buildChildren(node, annotationDocTree);
bpatel@766 178 memberDetailsTree.addContent(writer.getAnnotationDoc(
bpatel@766 179 annotationDocTree, (currentMemberIndex == size - 1)));
bpatel@766 180 }
duke@1 181 }
duke@1 182 }
duke@1 183
duke@1 184 /**
bpatel@766 185 * Build the signature.
bpatel@766 186 *
bpatel@766 187 * @param node the XML element that specifies which components to document
bpatel@766 188 * @param annotationDocTree the content tree to which the documentation will be added
duke@1 189 */
bpatel@766 190 public void buildSignature(XMLNode node, Content annotationDocTree) {
bpatel@766 191 annotationDocTree.addContent(
bpatel@766 192 writer.getSignature((MemberDoc) members.get(currentMemberIndex)));
duke@1 193 }
duke@1 194
duke@1 195 /**
duke@1 196 * Build the deprecation information.
bpatel@766 197 *
bpatel@766 198 * @param node the XML element that specifies which components to document
bpatel@766 199 * @param annotationDocTree the content tree to which the documentation will be added
duke@1 200 */
bpatel@766 201 public void buildDeprecationInfo(XMLNode node, Content annotationDocTree) {
bpatel@766 202 writer.addDeprecated((MemberDoc) members.get(currentMemberIndex),
bpatel@766 203 annotationDocTree);
duke@1 204 }
duke@1 205
duke@1 206 /**
duke@1 207 * Build the comments for the member. Do nothing if
duke@1 208 * {@link Configuration#nocomment} is set to true.
bpatel@766 209 *
bpatel@766 210 * @param node the XML element that specifies which components to document
bpatel@766 211 * @param annotationDocTree the content tree to which the documentation will be added
duke@1 212 */
bpatel@766 213 public void buildMemberComments(XMLNode node, Content annotationDocTree) {
duke@1 214 if(! configuration.nocomment){
bpatel@766 215 writer.addComments((MemberDoc) members.get(currentMemberIndex),
bpatel@766 216 annotationDocTree);
duke@1 217 }
duke@1 218 }
duke@1 219
duke@1 220 /**
duke@1 221 * Build the tag information.
bpatel@766 222 *
bpatel@766 223 * @param node the XML element that specifies which components to document
bpatel@766 224 * @param annotationDocTree the content tree to which the documentation will be added
duke@1 225 */
bpatel@766 226 public void buildTagInfo(XMLNode node, Content annotationDocTree) {
bpatel@766 227 writer.addTags((MemberDoc) members.get(currentMemberIndex),
bpatel@766 228 annotationDocTree);
duke@1 229 }
duke@1 230
duke@1 231 /**
duke@1 232 * Return the annotation type required member writer for this builder.
duke@1 233 *
duke@1 234 * @return the annotation type required member constant writer for this
duke@1 235 * builder.
duke@1 236 */
duke@1 237 public AnnotationTypeRequiredMemberWriter getWriter() {
duke@1 238 return writer;
duke@1 239 }
duke@1 240 }

mercurial