src/share/classes/com/sun/tools/javadoc/AnnotationTypeDocImpl.java

changeset 1
9a66ca7c79fa
child 113
eff38cc97183
equal deleted inserted replaced
-1:000000000000 1:9a66ca7c79fa
1 /*
2 * Copyright 2003-2005 Sun Microsystems, Inc. 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. 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.javadoc;
27
28 import com.sun.javadoc.*;
29
30 import static com.sun.javadoc.LanguageVersion.*;
31
32 import com.sun.tools.javac.code.Flags;
33 import com.sun.tools.javac.code.Kinds;
34 import com.sun.tools.javac.code.Scope;
35 import com.sun.tools.javac.code.Symbol;
36 import com.sun.tools.javac.code.Symbol.*;
37 import com.sun.tools.javac.tree.JCTree.*;
38 import com.sun.tools.javac.util.List;
39 import com.sun.tools.javac.util.ListBuffer;
40 import com.sun.tools.javac.util.Name;
41 import com.sun.tools.javac.util.Position;
42
43 /**
44 * Represents an annotation type.
45 *
46 * @author Scott Seligman
47 * @since 1.5
48 */
49
50 public class AnnotationTypeDocImpl
51 extends ClassDocImpl implements AnnotationTypeDoc {
52
53 AnnotationTypeDocImpl(DocEnv env, ClassSymbol sym) {
54 this(env, sym, null, null, null);
55 }
56
57 AnnotationTypeDocImpl(DocEnv env, ClassSymbol sym,
58 String doc, JCClassDecl tree, Position.LineMap lineMap) {
59 super(env, sym, doc, tree, lineMap);
60 }
61
62 /**
63 * Returns true, as this is an annotation type.
64 * (For legacy doclets, return false.)
65 */
66 public boolean isAnnotationType() {
67 return !isInterface();
68 }
69
70 /**
71 * Returns false. Though technically an interface, an annotation
72 * type is not considered an interface for this purpose.
73 * (For legacy doclets, returns true.)
74 */
75 public boolean isInterface() {
76 return env.legacyDoclet;
77 }
78
79 /**
80 * Returns an empty array, as all methods are annotation type elements.
81 * (For legacy doclets, returns the elements.)
82 * @see #elements()
83 */
84 public MethodDoc[] methods(boolean filter) {
85 return env.legacyDoclet
86 ? (MethodDoc[])elements()
87 : new MethodDoc[0];
88 }
89
90 /**
91 * Returns the elements of this annotation type.
92 * Returns an empty array if there are none.
93 * Elements are always public, so no need to filter them.
94 */
95 public AnnotationTypeElementDoc[] elements() {
96 Name.Table names = tsym.name.table;
97 List<AnnotationTypeElementDoc> elements = List.nil();
98 for (Scope.Entry e = tsym.members().elems; e != null; e = e.sibling) {
99 if (e.sym != null && e.sym.kind == Kinds.MTH) {
100 MethodSymbol s = (MethodSymbol)e.sym;
101 elements = elements.prepend(env.getAnnotationTypeElementDoc(s));
102 }
103 }
104 return
105 elements.toArray(new AnnotationTypeElementDoc[elements.length()]);
106 }
107 }

mercurial