001: /*******************************************************************************
002: * Copyright (c) 2000, 2006 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * IBM Corporation - initial API and implementation
010: *******************************************************************************/package org.eclipse.jdt.core.util;
011:
012: /**
013: * Description of a .class file. This class reifies the internal structure of a .class
014: * file following the JVM specifications.
015: * <p>
016: * Note that several changes were introduced with J2SE 1.5.
017: * Class file reader implementations should use support these
018: * new class file attributes by returning objects implementing
019: * the appropriate specialized attribute interfaces. Class
020: * file reader clients can search for these new attributes
021: * and downcast to the new interfaces as appropriate.
022: * </p>
023: *
024: * This interface may be implemented by clients.
025: *
026: * @since 2.0
027: */
028: public interface IClassFileReader {
029: /**
030: * This value should be used to read completely each part of a .class file.
031: */
032: int ALL = 0xFFFF;
033:
034: /**
035: * This value should be used to read only the constant pool entries of a .class file.
036: */
037: int CONSTANT_POOL = 0x0001;
038:
039: /**
040: * This value should be used to read the constant pool entries and
041: * the method infos of a .class file.
042: */
043: int METHOD_INFOS = 0x0002 + CONSTANT_POOL;
044:
045: /**
046: * This value should be used to read the constant pool entries and
047: * the field infos of a .class file.
048: */
049: int FIELD_INFOS = 0x0004 + CONSTANT_POOL;
050:
051: /**
052: * This value should be used to read the constant pool entries and
053: * the super interface names of a .class file.
054: */
055: int SUPER_INTERFACES = 0x0008 + CONSTANT_POOL;
056:
057: /**
058: * This value should be used to read the constant pool entries and
059: * the attributes of a .class file.
060: */
061: int CLASSFILE_ATTRIBUTES = 0x0010 + CONSTANT_POOL;
062:
063: /**
064: * This value should be used to read the method bodies.
065: * It has to be used with METHOD_INFOS.
066: */
067: int METHOD_BODIES = 0x0020;
068:
069: /**
070: * This value should be used to read the whole contents of the .class file except the
071: * method bodies.
072: */
073: int ALL_BUT_METHOD_BODIES = ALL & ~METHOD_BODIES;
074:
075: /**
076: * Answer back the access flag of the .class file.
077: *
078: * @return the access flag of the .class file
079: */
080: int getAccessFlags();
081:
082: /**
083: * Answer back the array of field infos of the .class file,
084: * an empty array if none.
085: *
086: * @return the array of field infos of the .class file, an empty array if none
087: */
088: IFieldInfo[] getFieldInfos();
089:
090: /**
091: * Answer back the names of interfaces implemented by this .class file,
092: * an empty array if none. The names are returned as described in the
093: * JVM specifications.
094: *
095: * @return the names of interfaces implemented by this .class file, an empty array if none
096: */
097: char[][] getInterfaceNames();
098:
099: /**
100: * Answer back the indexes in the constant pool of interfaces implemented
101: * by this .class file, an empty array if none.
102: *
103: * @return the indexes in the constant pool of interfaces implemented
104: * by this .class file, an empty array if none
105: */
106: int[] getInterfaceIndexes();
107:
108: /**
109: * Answer back the inner classes attribute of this .class file, null if none.
110: *
111: * @return the inner classes attribute of this .class file, null if none
112: */
113: IInnerClassesAttribute getInnerClassesAttribute();
114:
115: /**
116: * Answer back the array of method infos of this .class file,
117: * an empty array if none.
118: *
119: * @return the array of method infos of this .class file,
120: * an empty array if none
121: */
122: IMethodInfo[] getMethodInfos();
123:
124: /**
125: * Answer back the qualified name of the .class file.
126: * The name is returned as described in the JVM specifications.
127: *
128: * @return the qualified name of the .class file
129: */
130: char[] getClassName();
131:
132: /**
133: * Answer back the index of the class name in the constant pool
134: * of the .class file.
135: *
136: * @return the index of the class name in the constant pool
137: */
138: int getClassIndex();
139:
140: /**
141: * Answer back the qualified name of the superclass of this .class file.
142: * The name is returned as described in the JVM specifications. Answer null if
143: * getSuperclassIndex() is zero.
144: *
145: * @return the qualified name of the superclass of this .class file, null if getSuperclassIndex() is zero
146: */
147: char[] getSuperclassName();
148:
149: /**
150: * Answer back the index of the superclass name in the constant pool
151: * of the .class file. Answer 0 if this .class file represents java.lang.Object.
152: *
153: * @return the index of the superclass name in the constant pool
154: * of the .class file, 0 if this .class file represents java.lang.Object.
155: */
156: int getSuperclassIndex();
157:
158: /**
159: * Answer true if this .class file represents an class, false otherwise.
160: *
161: * @return true if this .class file represents an class, false otherwise
162: */
163: boolean isClass();
164:
165: /**
166: * Answer true if this .class file represents an interface, false otherwise.
167: *
168: * @return true if this .class file represents an interface, false otherwise
169: */
170: boolean isInterface();
171:
172: /**
173: * Answer the source file attribute, if it exists, null otherwise.
174: *
175: * @return the source file attribute, if it exists, null otherwise
176: */
177: ISourceAttribute getSourceFileAttribute();
178:
179: /**
180: * Answer the constant pool of this .class file.
181: *
182: * @return the constant pool of this .class file
183: */
184: IConstantPool getConstantPool();
185:
186: /**
187: * Answer the minor version of this .class file.
188: *
189: * @return the minor version of this .class file
190: */
191: int getMinorVersion();
192:
193: /**
194: * Answer the major version of this .class file.
195: *
196: * @return the major version of this .class file
197: */
198: int getMajorVersion();
199:
200: /**
201: * Answer back the attribute number of the .class file.
202: *
203: * @return the attribute number of the .class file
204: */
205: int getAttributeCount();
206:
207: /**
208: * Answer back the collection of all attributes of the field info. It
209: * includes SyntheticAttribute, ConstantValueAttributes, etc. Answers an empty
210: * array if none.
211: *
212: * @return the collection of all attributes of the field info. It
213: * includes SyntheticAttribute, ConstantValueAttributes, etc. Answers an empty
214: * array if none
215: */
216: IClassFileAttribute[] getAttributes();
217:
218: /**
219: * Answer back the magic number.
220: *
221: * @return the magic number
222: */
223: int getMagic();
224:
225: /**
226: * Answer back the number of field infos.
227: *
228: * @return the number of field infos
229: */
230: int getFieldsCount();
231:
232: /**
233: * Answer back the number of method infos.
234: *
235: * @return the number of method infos
236: */
237: int getMethodsCount();
238: }
|