Wed, 31 Oct 2012 13:48:15 -0700
8001664: refactor javadoc to use abstraction to handle files
Reviewed-by: darcy
1 /*
2 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
26 package com.sun.tools.doclets.internal.toolkit.builders;
28 import java.util.*;
30 import com.sun.javadoc.*;
31 import com.sun.tools.doclets.internal.toolkit.*;
32 import com.sun.tools.doclets.internal.toolkit.util.*;
34 /**
35 * Builds documentation for optional annotation type members.
36 *
37 * <p><b>This is NOT part of any supported API.
38 * If you write code that depends on this, you do so at your own risk.
39 * This code and its internal interfaces are subject to change or
40 * deletion without notice.</b>
41 *
42 * @author Jamie Ho
43 * @author Bhavesh Patel (Modified)
44 * @since 1.5
45 */
46 public class AnnotationTypeOptionalMemberBuilder extends
47 AnnotationTypeRequiredMemberBuilder {
50 /**
51 * Construct a new AnnotationTypeMemberBuilder.
52 *
53 * @param configuration the current configuration of the
54 * doclet.
55 */
56 private AnnotationTypeOptionalMemberBuilder(Configuration configuration) {
57 super(configuration);
58 }
61 /**
62 * Construct a new AnnotationTypeMemberBuilder.
63 *
64 * @param configuration the current configuration of the doclet.
65 * @param classDoc the class whoses members are being documented.
66 * @param writer the doclet specific writer.
67 */
68 public static AnnotationTypeOptionalMemberBuilder getInstance(
69 Configuration configuration, ClassDoc classDoc,
70 AnnotationTypeOptionalMemberWriter writer) {
71 AnnotationTypeOptionalMemberBuilder builder =
72 new AnnotationTypeOptionalMemberBuilder(configuration);
73 builder.classDoc = classDoc;
74 builder.writer = writer;
75 builder.visibleMemberMap = new VisibleMemberMap(classDoc,
76 VisibleMemberMap.ANNOTATION_TYPE_MEMBER_OPTIONAL, configuration.nodeprecated);
77 builder.members = new ArrayList<ProgramElementDoc>(
78 builder.visibleMemberMap.getMembersFor(classDoc));
79 if (configuration.getMemberComparator() != null) {
80 Collections.sort(builder.members,
81 configuration.getMemberComparator());
82 }
83 return builder;
84 }
86 /**
87 * {@inheritDoc}
88 */
89 @Override
90 public String getName() {
91 return "AnnotationTypeOptionalMemberDetails";
92 }
94 /**
95 * Build the annotation type optional member documentation.
96 *
97 * @param node the XML element that specifies which components to document
98 * @param memberDetailsTree the content tree to which the documentation will be added
99 */
100 public void buildAnnotationTypeOptionalMember(XMLNode node, Content memberDetailsTree) {
101 buildAnnotationTypeMember(node, memberDetailsTree);
102 }
104 /**
105 * Build the default value for this optional member.
106 *
107 * @param node the XML element that specifies which components to document
108 * @param annotationDocTree the content tree to which the documentation will be added
109 */
110 public void buildDefaultValueInfo(XMLNode node, Content annotationDocTree) {
111 ((AnnotationTypeOptionalMemberWriter) writer).addDefaultValueInfo(
112 (MemberDoc) members.get(currentMemberIndex),
113 annotationDocTree);
114 }
116 /**
117 * {@inheritDoc}
118 */
119 @Override
120 public AnnotationTypeRequiredMemberWriter getWriter() {
121 return writer;
122 }
123 }