1 |
779 |
jeremybenn |
/* gnu.classpath.tools.gjdoc.ClassDocReflectedImpl
|
2 |
|
|
Copyright (C) 2001 Free Software Foundation, Inc.
|
3 |
|
|
|
4 |
|
|
This file is part of GNU Classpath.
|
5 |
|
|
|
6 |
|
|
GNU Classpath is free software; you can redistribute it and/or modify
|
7 |
|
|
it under the terms of the GNU General Public License as published by
|
8 |
|
|
the Free Software Foundation; either version 2, or (at your option)
|
9 |
|
|
any later version.
|
10 |
|
|
|
11 |
|
|
GNU Classpath is distributed in the hope that it will be useful, but
|
12 |
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 |
|
|
General Public License for more details.
|
15 |
|
|
|
16 |
|
|
You should have received a copy of the GNU General Public License
|
17 |
|
|
along with GNU Classpath; see the file COPYING. If not, write to the
|
18 |
|
|
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
19 |
|
|
02111-1307 USA.
|
20 |
|
|
|
21 |
|
|
Linking this library statically or dynamically with other modules is
|
22 |
|
|
making a combined work based on this library. Thus, the terms and
|
23 |
|
|
conditions of the GNU General Public License cover the whole
|
24 |
|
|
combination.
|
25 |
|
|
|
26 |
|
|
As a special exception, the copyright holders of this library give you
|
27 |
|
|
permission to link this library with independent modules to produce an
|
28 |
|
|
executable, regardless of the license terms of these independent
|
29 |
|
|
modules, and to copy and distribute the resulting executable under
|
30 |
|
|
terms of your choice, provided that you also meet, for each linked
|
31 |
|
|
independent module, the terms and conditions of the license of that
|
32 |
|
|
module. An independent module is a module which is not derived from
|
33 |
|
|
or based on this library. If you modify this library, you may extend
|
34 |
|
|
this exception to your version of the library, but you are not
|
35 |
|
|
obligated to do so. If you do not wish to do so, delete this
|
36 |
|
|
exception statement from your version. */
|
37 |
|
|
|
38 |
|
|
package gnu.classpath.tools.gjdoc;
|
39 |
|
|
|
40 |
|
|
import com.sun.javadoc.*;
|
41 |
|
|
import java.util.Map;
|
42 |
|
|
import java.util.HashMap;
|
43 |
|
|
|
44 |
|
|
public class ClassDocReflectedImpl
|
45 |
|
|
implements ClassDoc, WritableType
|
46 |
|
|
{
|
47 |
|
|
private Class clazz;
|
48 |
|
|
private String name;
|
49 |
|
|
private ClassDoc superclassDoc;
|
50 |
|
|
private ClassDoc[] unfilteredInnerClasses;
|
51 |
|
|
private String dimension = "";
|
52 |
|
|
|
53 |
|
|
private static Map reflectionCache = new HashMap();
|
54 |
|
|
|
55 |
|
|
public static ClassDocReflectedImpl newInstance(Class clazz)
|
56 |
|
|
{
|
57 |
|
|
ClassDocReflectedImpl result
|
58 |
|
|
= (ClassDocReflectedImpl)reflectionCache.get(clazz);
|
59 |
|
|
if (null != result) {
|
60 |
|
|
return result;
|
61 |
|
|
}
|
62 |
|
|
else {
|
63 |
|
|
return new ClassDocReflectedImpl(clazz);
|
64 |
|
|
}
|
65 |
|
|
}
|
66 |
|
|
|
67 |
|
|
public ClassDocReflectedImpl(Class clazz)
|
68 |
|
|
{
|
69 |
|
|
reflectionCache.put(clazz, this);
|
70 |
|
|
|
71 |
|
|
//System.err.println("ClassDocReflectedImpl: " + clazz);
|
72 |
|
|
|
73 |
|
|
this.clazz = clazz;
|
74 |
|
|
String className = clazz.getName();
|
75 |
|
|
int ndx = className.lastIndexOf('.');
|
76 |
|
|
if (ndx >= 0) {
|
77 |
|
|
this.name = className.substring(ndx + 1);
|
78 |
|
|
}
|
79 |
|
|
else {
|
80 |
|
|
this.name = className;
|
81 |
|
|
}
|
82 |
|
|
|
83 |
|
|
Class superclass = clazz.getSuperclass();
|
84 |
|
|
if (null != superclass && !clazz.getName().equals("java.lang.Object")) {
|
85 |
|
|
this.superclassDoc = (ClassDocReflectedImpl)reflectionCache.get(superclass);
|
86 |
|
|
if (null == this.superclassDoc) {
|
87 |
|
|
this.superclassDoc = new ClassDocReflectedImpl(superclass);
|
88 |
|
|
}
|
89 |
|
|
}
|
90 |
|
|
|
91 |
|
|
Class[] innerclasses = clazz.getDeclaredClasses();
|
92 |
|
|
this.unfilteredInnerClasses = new ClassDoc[innerclasses.length];
|
93 |
|
|
for (int i=0; i<innerclasses.length; ++i) {
|
94 |
|
|
this.unfilteredInnerClasses[i] = (ClassDocReflectedImpl)reflectionCache.get(innerclasses[i]);
|
95 |
|
|
if (null == this.unfilteredInnerClasses[i]) {
|
96 |
|
|
this.unfilteredInnerClasses[i] = new ClassDocReflectedImpl(innerclasses[i]);
|
97 |
|
|
//System.err.println("adding " + this.unfilteredInnerClasses[i] + " [" + innerclasses[i] + "] as inner class of " + this + " [" + clazz + "]");
|
98 |
|
|
}
|
99 |
|
|
}
|
100 |
|
|
}
|
101 |
|
|
|
102 |
|
|
public ConstructorDoc[] constructors() { return new ConstructorDoc[0]; }
|
103 |
|
|
public ConstructorDoc[] constructors(boolean filtered) { return new ConstructorDoc[0]; }
|
104 |
|
|
public boolean definesSerializableFields() { return false; }
|
105 |
|
|
public FieldDoc[] fields() { return new FieldDoc[0]; }
|
106 |
|
|
public FieldDoc[] fields(boolean filtered) { return new FieldDoc[0]; }
|
107 |
|
|
public ClassDoc findClass(java.lang.String className) { return null; }
|
108 |
|
|
public ClassDoc[] importedClasses() { return new ClassDoc[0]; }
|
109 |
|
|
public PackageDoc[] importedPackages() { return new PackageDoc[0]; }
|
110 |
|
|
public ClassDoc[] innerClasses() { return new ClassDoc[0]; }
|
111 |
|
|
public ClassDoc[] innerClasses(boolean filtered)
|
112 |
|
|
{
|
113 |
|
|
if (filtered) {
|
114 |
|
|
return new ClassDoc[0];
|
115 |
|
|
}
|
116 |
|
|
else {
|
117 |
|
|
return unfilteredInnerClasses;
|
118 |
|
|
}
|
119 |
|
|
}
|
120 |
|
|
|
121 |
|
|
public ClassDoc[] interfaces() { return new ClassDoc[0]; }
|
122 |
|
|
public boolean isAbstract() { return false; }
|
123 |
|
|
public boolean isExternalizable() { return false; }
|
124 |
|
|
public boolean isSerializable() { return false; }
|
125 |
|
|
public MethodDoc[] methods() { return new MethodDoc[0]; }
|
126 |
|
|
public MethodDoc[] methods(boolean filtered) { return new MethodDoc[0]; }
|
127 |
|
|
public FieldDoc[] serializableFields() { return new FieldDoc[0]; }
|
128 |
|
|
public MethodDoc[] serializationMethods() { return new MethodDoc[0]; }
|
129 |
|
|
public boolean subclassOf(ClassDoc cd) { return false; }
|
130 |
|
|
public ClassDoc superclass() {
|
131 |
|
|
return superclassDoc;
|
132 |
|
|
}
|
133 |
|
|
public ClassDoc containingClass()
|
134 |
|
|
{
|
135 |
|
|
Class declaringClass = clazz.getDeclaringClass();
|
136 |
|
|
if (null != declaringClass) {
|
137 |
|
|
return new ClassDocReflectedImpl(declaringClass);
|
138 |
|
|
}
|
139 |
|
|
else {
|
140 |
|
|
return null;
|
141 |
|
|
}
|
142 |
|
|
}
|
143 |
|
|
public PackageDoc containingPackage()
|
144 |
|
|
{
|
145 |
|
|
Class outerClass = clazz;
|
146 |
|
|
while (null != outerClass.getDeclaringClass()) {
|
147 |
|
|
outerClass = outerClass.getDeclaringClass();
|
148 |
|
|
}
|
149 |
|
|
|
150 |
|
|
String packageName = outerClass.getName();
|
151 |
|
|
int ndx = packageName.lastIndexOf('.');
|
152 |
|
|
if (ndx > 0) {
|
153 |
|
|
packageName = packageName.substring(0, ndx);
|
154 |
|
|
}
|
155 |
|
|
else {
|
156 |
|
|
packageName = "";
|
157 |
|
|
}
|
158 |
|
|
PackageDoc result = Main.getRootDoc().findOrCreatePackageDoc(packageName);
|
159 |
|
|
return result;
|
160 |
|
|
}
|
161 |
|
|
|
162 |
|
|
public boolean isFinal() { return false; }
|
163 |
|
|
public boolean isPackagePrivate() { return false; }
|
164 |
|
|
public boolean isPrivate() { return false; }
|
165 |
|
|
public boolean isProtected() { return false; }
|
166 |
|
|
public boolean isPublic() { return false; }
|
167 |
|
|
public boolean isStatic() { return false; }
|
168 |
|
|
public String modifiers() { return ""; }
|
169 |
|
|
public int modifierSpecifier() { return 0; }
|
170 |
|
|
public String qualifiedName() { return clazz.getName().replace('$', '.'); }
|
171 |
|
|
public String commentText() { return null; }
|
172 |
|
|
public Tag[] firstSentenceTags() { return new Tag[0]; }
|
173 |
|
|
public String getRawCommentText() { return null; }
|
174 |
|
|
public Tag[] inlineTags() { return new Tag[0]; }
|
175 |
|
|
public boolean isClass() { return false; }
|
176 |
|
|
public boolean isConstructor() { return false; }
|
177 |
|
|
public boolean isError() { return false; }
|
178 |
|
|
public boolean isException() { return false; }
|
179 |
|
|
public boolean isField() { return false; }
|
180 |
|
|
public boolean isIncluded() { return false; }
|
181 |
|
|
public boolean isInterface() { return false; }
|
182 |
|
|
public boolean isMethod() { return false; }
|
183 |
|
|
public boolean isOrdinaryClass() { return false; }
|
184 |
|
|
public String name() { return name; }
|
185 |
|
|
public SourcePosition position() { return null; }
|
186 |
|
|
public SeeTag[] seeTags() { return new SeeTag[0]; }
|
187 |
|
|
public void setRawCommentText(java.lang.String rawDocumentation) {}
|
188 |
|
|
public Tag[] tags() { return new Tag[0]; }
|
189 |
|
|
public Tag[] tags(java.lang.String tagname) { return new Tag[0]; }
|
190 |
|
|
public String typeName() { return name; }
|
191 |
|
|
public String qualifiedTypeName() { return qualifiedName(); }
|
192 |
|
|
public ClassDoc asClassDoc() { return this; }
|
193 |
|
|
public TypeVariable asTypeVariable() { return null; }
|
194 |
|
|
public boolean isPrimitive() { return false; }
|
195 |
|
|
|
196 |
|
|
public String toString() { return "ClassDocReflectedImpl{"+qualifiedName()+"}"; }
|
197 |
|
|
|
198 |
|
|
public int compareTo(java.lang.Object o) {
|
199 |
|
|
if (o instanceof Doc) {
|
200 |
|
|
return Main.getInstance().getCollator().compare(name(), ((Doc)o).name());
|
201 |
|
|
}
|
202 |
|
|
else {
|
203 |
|
|
return 0;
|
204 |
|
|
}
|
205 |
|
|
}
|
206 |
|
|
|
207 |
|
|
public String dimension() { return dimension; }
|
208 |
|
|
|
209 |
|
|
public void setDimension(String dimension) {
|
210 |
|
|
this.dimension = dimension;
|
211 |
|
|
}
|
212 |
|
|
|
213 |
|
|
public Object clone() throws CloneNotSupportedException {
|
214 |
|
|
return super.clone();
|
215 |
|
|
}
|
216 |
|
|
|
217 |
|
|
public TypeVariable[] typeParameters() { return new TypeVariable[0]; }
|
218 |
|
|
|
219 |
|
|
}
|