KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > core > util > IClassFileReader


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.core.util;
12
13 /**
14  * Description of a .class file. This class reifies the internal structure of a .class
15  * file following the JVM specifications.
16  * <p>
17  * Note that several changes were introduced with J2SE 1.5.
18  * Class file reader implementations should use support these
19  * new class file attributes by returning objects implementing
20  * the appropriate specialized attribute interfaces. Class
21  * file reader clients can search for these new attributes
22  * and downcast to the new interfaces as appropriate.
23  * </p>
24  *
25  * This interface may be implemented by clients.
26  *
27  * @since 2.0
28  */

29 public interface IClassFileReader {
30     /**
31      * This value should be used to read completely each part of a .class file.
32      */

33     int ALL = 0xFFFF;
34     
35     /**
36      * This value should be used to read only the constant pool entries of a .class file.
37      */

38     int CONSTANT_POOL = 0x0001;
39
40     /**
41      * This value should be used to read the constant pool entries and
42      * the method infos of a .class file.
43      */

44     int METHOD_INFOS = 0x0002 + CONSTANT_POOL;
45
46     /**
47      * This value should be used to read the constant pool entries and
48      * the field infos of a .class file.
49      */

50     int FIELD_INFOS = 0x0004 + CONSTANT_POOL;
51
52     /**
53      * This value should be used to read the constant pool entries and
54      * the super interface names of a .class file.
55      */

56     int SUPER_INTERFACES = 0x0008 + CONSTANT_POOL;
57
58     /**
59      * This value should be used to read the constant pool entries and
60      * the attributes of a .class file.
61      */

62     int CLASSFILE_ATTRIBUTES = 0x0010 + CONSTANT_POOL;
63
64     /**
65      * This value should be used to read the method bodies.
66      * It has to be used with METHOD_INFOS.
67      */

68     int METHOD_BODIES = 0x0020;
69
70     /**
71      * This value should be used to read the whole contents of the .class file except the
72      * method bodies.
73      */

74     int ALL_BUT_METHOD_BODIES = ALL & ~METHOD_BODIES;
75     
76     /**
77      * Answer back the access flag of the .class file.
78      *
79      * @return the access flag of the .class file
80      */

81     int getAccessFlags();
82     
83     /**
84      * Answer back the array of field infos of the .class file,
85      * an empty array if none.
86      *
87      * @return the array of field infos of the .class file, an empty array if none
88      */

89     IFieldInfo[] getFieldInfos();
90
91     /**
92      * Answer back the names of interfaces implemented by this .class file,
93      * an empty array if none. The names are returned as described in the
94      * JVM specifications.
95      *
96      * @return the names of interfaces implemented by this .class file, an empty array if none
97      */

98     char[][] getInterfaceNames();
99
100     /**
101      * Answer back the indexes in the constant pool of interfaces implemented
102      * by this .class file, an empty array if none.
103      *
104      * @return the indexes in the constant pool of interfaces implemented
105      * by this .class file, an empty array if none
106      */

107     int[] getInterfaceIndexes();
108
109     /**
110      * Answer back the inner classes attribute of this .class file, null if none.
111      *
112      * @return the inner classes attribute of this .class file, null if none
113      */

114     IInnerClassesAttribute getInnerClassesAttribute();
115
116     /**
117      * Answer back the array of method infos of this .class file,
118      * an empty array if none.
119      *
120      * @return the array of method infos of this .class file,
121      * an empty array if none
122      */

123     IMethodInfo[] getMethodInfos();
124
125     /**
126      * Answer back the qualified name of the .class file.
127      * The name is returned as described in the JVM specifications.
128      *
129      * @return the qualified name of the .class file
130      */

131     char[] getClassName();
132
133     /**
134      * Answer back the index of the class name in the constant pool
135      * of the .class file.
136      *
137      * @return the index of the class name in the constant pool
138      */

139     int getClassIndex();
140         
141     /**
142      * Answer back the qualified name of the superclass of this .class file.
143      * The name is returned as described in the JVM specifications. Answer null if
144      * getSuperclassIndex() is zero.
145      *
146      * @return the qualified name of the superclass of this .class file, null if getSuperclassIndex() is zero
147      */

148     char[] getSuperclassName();
149
150     /**
151      * Answer back the index of the superclass name in the constant pool
152      * of the .class file. Answer 0 if this .class file represents java.lang.Object.
153      *
154      * @return the index of the superclass name in the constant pool
155      * of the .class file, 0 if this .class file represents java.lang.Object.
156      */

157     int getSuperclassIndex();
158
159     /**
160      * Answer true if this .class file represents an class, false otherwise.
161      *
162      * @return true if this .class file represents an class, false otherwise
163      */

164     boolean isClass();
165
166     /**
167      * Answer true if this .class file represents an interface, false otherwise.
168      *
169      * @return true if this .class file represents an interface, false otherwise
170      */

171     boolean isInterface();
172
173     /**
174      * Answer the source file attribute, if it exists, null otherwise.
175      *
176      * @return the source file attribute, if it exists, null otherwise
177      */

178     ISourceAttribute getSourceFileAttribute();
179
180     /**
181      * Answer the constant pool of this .class file.
182      *
183      * @return the constant pool of this .class file
184      */

185     IConstantPool getConstantPool();
186     
187     /**
188      * Answer the minor version of this .class file.
189      *
190      * @return the minor version of this .class file
191      */

192     int getMinorVersion();
193
194     /**
195      * Answer the major version of this .class file.
196      *
197      * @return the major version of this .class file
198      */

199     int getMajorVersion();
200
201     /**
202      * Answer back the attribute number of the .class file.
203      *
204      * @return the attribute number of the .class file
205      */

206     int getAttributeCount();
207     
208     /**
209      * Answer back the collection of all attributes of the field info. It
210      * includes SyntheticAttribute, ConstantValueAttributes, etc. Answers an empty
211      * array if none.
212      *
213      * @return the collection of all attributes of the field info. It
214      * includes SyntheticAttribute, ConstantValueAttributes, etc. Answers an empty
215      * array if none
216      */

217     IClassFileAttribute[] getAttributes();
218     
219     /**
220      * Answer back the magic number.
221      *
222      * @return the magic number
223      */

224     int getMagic();
225     
226     /**
227      * Answer back the number of field infos.
228      *
229      * @return the number of field infos
230      */

231     int getFieldsCount();
232
233     /**
234      * Answer back the number of method infos.
235      *
236      * @return the number of method infos
237      */

238     int getMethodsCount();
239 }
240
Popular Tags