KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > polyglot > types > ClassType


1 package polyglot.types;
2
3 import polyglot.util.Enum;
4 import java.util.List JavaDoc;
5
6 /**
7  * A <code>ClassType</code> represents a class, either loaded from a
8  * classpath, parsed from a source file, or obtained from other source.
9  * A <code>ClassType</code> is not necessarily named.
10  */

11 public interface ClassType extends Importable, ReferenceType, MemberInstance
12 {
13     public static class Kind extends Enum JavaDoc {
14         public Kind(String JavaDoc name) {
15             super(name);
16         }
17     }
18
19     public static final Kind TOP_LEVEL = new Kind("top-level");
20     public static final Kind MEMBER = new Kind("member");
21     public static final Kind LOCAL = new Kind("local");
22     public static final Kind ANONYMOUS = new Kind("anonymous");
23
24     /** Get the class's kind. */
25     Kind kind();
26
27     /**
28      * Return true if the class is top-level (i.e., not inner).
29      * Equivalent to kind() == TOP_LEVEL.
30      */

31     boolean isTopLevel();
32
33     /**
34      * Return true if the class is an inner class.
35      * Equivalent to kind() == MEMBER || kind() == LOCAL || kind() == ANONYMOUS.
36      * @deprecated Was incorrectly defined. Use isNested for nested classes,
37      * and isInnerClass for inner classes.
38      */

39     boolean isInner();
40
41     /**
42      * Return true if the class is a nested.
43      * Equivalent to kind() == MEMBER || kind() == LOCAL || kind() == ANONYMOUS.
44      */

45     boolean isNested();
46
47     /**
48      * Return true if the class is an inner class, that is, it is a nested
49      * class that is not explicitly or implicitly declared static; an interface
50      * is never an inner class.
51      */

52     boolean isInnerClass();
53
54     /**
55      * Return true if the class is a member class.
56      * Equivalent to kind() == MEMBER.
57      */

58     boolean isMember();
59
60     /**
61      * Return true if the class is a local class.
62      * Equivalent to kind() == LOCAL.
63      */

64     boolean isLocal();
65
66     /**
67      * Return true if the class is an anonymous class.
68      * Equivalent to kind() == ANONYMOUS.
69      */

70     boolean isAnonymous();
71
72     /**
73      * Return true if the class declaration occurs in a static context.
74      * Is used to determine if a nested class is implicitly static.
75      */

76     boolean inStaticContext();
77     
78     /**
79      * The class's constructors.
80      * A list of <code>ConstructorInstance</code>.
81      * @see polyglot.types.ConstructorInstance
82      */

83     List JavaDoc constructors();
84
85     /**
86      * The class's member classes.
87      * A list of <code>ClassType</code>.
88      * @see polyglot.types.ClassType
89      */

90     List JavaDoc memberClasses();
91
92     /** Returns the member class with the given name, or null. */
93     ClassType memberClassNamed(String JavaDoc name);
94
95     /** Get a field by name, or null. */
96     FieldInstance fieldNamed(String JavaDoc name);
97
98     /** Return true if the class is strictly contained in <code>outer</code>. */
99     boolean isEnclosed(ClassType outer);
100
101     /**
102      * Implementation of <code>isEnclosed</code>.
103      * This method should only be called by the <code>TypeSystem</code>
104      * or by a subclass.
105      */

106     boolean isEnclosedImpl(ClassType outer);
107
108     /** Return true if an object of the class has
109      * an enclosing instance of <code>encl</code>. */

110     boolean hasEnclosingInstance(ClassType encl);
111
112     /**
113      * Implementation of <code>hasEnclosingInstance</code>.
114      * This method should only be called by the <code>TypeSystem</code>
115      * or by a subclass.
116      */

117     boolean hasEnclosingInstanceImpl(ClassType encl);
118
119     /** The class's outer class if this is a nested class, or null. */
120     ClassType outer();
121 }
122
Popular Tags