Wed, 01 Dec 2010 11:02:38 -0800
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
Reviewed-by: jjg
1 /*
2 * Copyright (c) 2003, 2008, 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.*;
29 import com.sun.tools.doclets.internal.toolkit.util.*;
30 import com.sun.tools.doclets.internal.toolkit.*;
31 import com.sun.javadoc.*;
33 /**
34 * Builds documentation for optional annotation type members.
35 *
36 * This code is not part of an API.
37 * It is implementation that is subject to change.
38 * Do not use it as an API
39 *
40 * @author Jamie Ho
41 * @author Bhavesh Patel (Modified)
42 * @since 1.5
43 */
44 public class AnnotationTypeOptionalMemberBuilder extends
45 AnnotationTypeRequiredMemberBuilder {
48 /**
49 * Construct a new AnnotationTypeMemberBuilder.
50 *
51 * @param configuration the current configuration of the
52 * doclet.
53 */
54 private AnnotationTypeOptionalMemberBuilder(Configuration configuration) {
55 super(configuration);
56 }
59 /**
60 * Construct a new AnnotationTypeMemberBuilder.
61 *
62 * @param configuration the current configuration of the doclet.
63 * @param classDoc the class whoses members are being documented.
64 * @param writer the doclet specific writer.
65 */
66 public static AnnotationTypeOptionalMemberBuilder getInstance(
67 Configuration configuration, ClassDoc classDoc,
68 AnnotationTypeOptionalMemberWriter writer) {
69 AnnotationTypeOptionalMemberBuilder builder =
70 new AnnotationTypeOptionalMemberBuilder(configuration);
71 builder.classDoc = classDoc;
72 builder.writer = writer;
73 builder.visibleMemberMap = new VisibleMemberMap(classDoc,
74 VisibleMemberMap.ANNOTATION_TYPE_MEMBER_OPTIONAL, configuration.nodeprecated);
75 builder.members = new ArrayList<ProgramElementDoc>(
76 builder.visibleMemberMap.getMembersFor(classDoc));
77 if (configuration.getMemberComparator() != null) {
78 Collections.sort(builder.members,
79 configuration.getMemberComparator());
80 }
81 return builder;
82 }
84 /**
85 * {@inheritDoc}
86 */
87 @Override
88 public String getName() {
89 return "AnnotationTypeOptionalMemberDetails";
90 }
92 /**
93 * Build the annotation type optional member documentation.
94 *
95 * @param node the XML element that specifies which components to document
96 * @param memberDetailsTree the content tree to which the documentation will be added
97 */
98 public void buildAnnotationTypeOptionalMember(XMLNode node, Content memberDetailsTree) {
99 buildAnnotationTypeMember(node, memberDetailsTree);
100 }
102 /**
103 * Build the default value for this optional member.
104 *
105 * @param node the XML element that specifies which components to document
106 * @param annotationDocTree the content tree to which the documentation will be added
107 */
108 public void buildDefaultValueInfo(XMLNode node, Content annotationDocTree) {
109 ((AnnotationTypeOptionalMemberWriter) writer).addDefaultValueInfo(
110 (MemberDoc) members.get(currentMemberIndex),
111 annotationDocTree);
112 }
114 /**
115 * {@inheritDoc}
116 */
117 @Override
118 public AnnotationTypeRequiredMemberWriter getWriter() {
119 return writer;
120 }
121 }