author | mcimadamore |
Tue, 13 Jan 2009 13:27:14 +0000 | |
changeset 1789 | 7ac8c0815000 |
parent 1264 | 076a3cde30d5 |
child 5520 | 86e4b9a9da40 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
1264 | 2 |
* Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved. |
10 | 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. Sun designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
|
22 |
* CA 95054 USA or visit www.sun.com if you need additional information or |
|
23 |
* have any questions. |
|
24 |
*/ |
|
25 |
||
26 |
package com.sun.tools.doclets.internal.toolkit.builders; |
|
27 |
||
28 |
||
29 |
import com.sun.tools.doclets.internal.toolkit.util.*; |
|
30 |
import com.sun.tools.doclets.internal.toolkit.*; |
|
31 |
import com.sun.javadoc.*; |
|
32 |
import java.util.*; |
|
33 |
import java.lang.reflect.*; |
|
34 |
||
35 |
/** |
|
36 |
* Builds documentation for optional annotation type members. |
|
37 |
* |
|
38 |
* This code is not part of an API. |
|
39 |
* It is implementation that is subject to change. |
|
40 |
* Do not use it as an API |
|
41 |
* |
|
42 |
* @author Jamie Ho |
|
43 |
* @since 1.5 |
|
44 |
*/ |
|
45 |
public class AnnotationTypeOptionalMemberBuilder extends |
|
46 |
AnnotationTypeRequiredMemberBuilder { |
|
47 |
||
48 |
||
49 |
/** |
|
50 |
* Construct a new AnnotationTypeMemberBuilder. |
|
51 |
* |
|
52 |
* @param configuration the current configuration of the |
|
53 |
* doclet. |
|
54 |
*/ |
|
55 |
private AnnotationTypeOptionalMemberBuilder(Configuration configuration) { |
|
56 |
super(configuration); |
|
57 |
} |
|
58 |
||
59 |
||
60 |
/** |
|
61 |
* Construct a new AnnotationTypeMemberBuilder. |
|
62 |
* |
|
63 |
* @param configuration the current configuration of the doclet. |
|
64 |
* @param classDoc the class whoses members are being documented. |
|
65 |
* @param writer the doclet specific writer. |
|
66 |
*/ |
|
67 |
public static AnnotationTypeOptionalMemberBuilder getInstance( |
|
68 |
Configuration configuration, ClassDoc classDoc, |
|
69 |
AnnotationTypeOptionalMemberWriter writer) { |
|
70 |
AnnotationTypeOptionalMemberBuilder builder = |
|
71 |
new AnnotationTypeOptionalMemberBuilder(configuration); |
|
72 |
builder.classDoc = classDoc; |
|
73 |
builder.writer = writer; |
|
74 |
builder.visibleMemberMap = new VisibleMemberMap(classDoc, |
|
75 |
VisibleMemberMap.ANNOTATION_TYPE_MEMBER_OPTIONAL, configuration.nodeprecated); |
|
868 | 76 |
builder.members = new ArrayList<ProgramElementDoc>( |
10 | 77 |
builder.visibleMemberMap.getMembersFor(classDoc)); |
78 |
if (configuration.getMemberComparator() != null) { |
|
79 |
Collections.sort(builder.members, |
|
80 |
configuration.getMemberComparator()); |
|
81 |
} |
|
82 |
return builder; |
|
83 |
} |
|
84 |
||
85 |
/** |
|
86 |
* {@inheritDoc} |
|
87 |
*/ |
|
88 |
public String getName() { |
|
89 |
return "AnnotationTypeOptionalMemberDetails"; |
|
90 |
} |
|
91 |
||
92 |
/** |
|
93 |
* Build the member documentation. |
|
94 |
* |
|
95 |
* @param elements the XML elements that specify how to construct this |
|
96 |
* documentation. |
|
97 |
*/ |
|
1789
7ac8c0815000
6765045: Remove rawtypes warnings from langtools
mcimadamore
parents:
1264
diff
changeset
|
98 |
public void buildAnnotationTypeOptionalMember(List<?> elements) { |
10 | 99 |
if (writer == null) { |
100 |
return; |
|
101 |
} |
|
102 |
for (currentMemberIndex = 0; currentMemberIndex < members.size(); |
|
103 |
currentMemberIndex++) { |
|
104 |
build(elements); |
|
105 |
} |
|
106 |
} |
|
107 |
||
108 |
/** |
|
109 |
* {@inheritDoc} |
|
110 |
*/ |
|
1789
7ac8c0815000
6765045: Remove rawtypes warnings from langtools
mcimadamore
parents:
1264
diff
changeset
|
111 |
public void invokeMethod(String methodName, Class<?>[] paramClasses, |
10 | 112 |
Object[] params) |
113 |
throws Exception { |
|
114 |
if (DEBUG) { |
|
115 |
configuration.root.printError("DEBUG: " + this.getClass().getName() |
|
116 |
+ "." + methodName); |
|
117 |
} |
|
118 |
Method method = this.getClass().getMethod(methodName, paramClasses); |
|
119 |
method.invoke(this, params); |
|
120 |
} |
|
121 |
||
122 |
/** |
|
123 |
* Document the default value for this optional member. |
|
124 |
*/ |
|
125 |
public void buildDefaultValueInfo() { |
|
126 |
((AnnotationTypeOptionalMemberWriter) writer).writeDefaultValueInfo( |
|
127 |
(MemberDoc) members.get(currentMemberIndex)); |
|
128 |
} |
|
129 |
||
130 |
/** |
|
131 |
* {@inheritDoc} |
|
132 |
*/ |
|
133 |
public AnnotationTypeRequiredMemberWriter getWriter() { |
|
134 |
return writer; |
|
135 |
} |
|
136 |
} |