001: /* Copyright (C) 2004 - 2007 db4objects Inc. http://www.db4o.com
002:
003: This file is part of the db4o open source object database.
004:
005: db4o is free software; you can redistribute it and/or modify it under
006: the terms of version 2 of the GNU General Public License as published
007: by the Free Software Foundation and as clarified by db4objects' GPL
008: interpretation policy, available at
009: http://www.db4o.com/about/company/legalpolicies/gplinterpretation/
010: Alternatively you can write to db4objects, Inc., 1900 S Norfolk Street,
011: Suite 350, San Mateo, CA 94403, USA.
012:
013: db4o is distributed in the hope that it will be useful, but WITHOUT ANY
014: WARRANTY; without even the implied warranty of MERCHANTABILITY or
015: FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
016: for more details.
017:
018: You should have received a copy of the GNU General Public License along
019: with this program; if not, write to the Free Software Foundation, Inc.,
020: 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
021: package EDU.purdue.cs.bloat.reflect;
022:
023: import java.util.*;
024:
025: /**
026: * ClassInfo allows a class to be accessed and modified at a very low level.
027: * ClassInfo is implemented by <tt>file.ClassFile</tt>
028: *
029: * @see EDU.purdue.cs.bloat.file.ClassFile
030: *
031: * @author Nate Nystrom (<a
032: * href="mailto:nystrom@cs.purdue.edu">nystrom@cs.purdue.edu</a>)
033: */
034: public interface ClassInfo {
035: /**
036: * Get the class info loader for the class.
037: *
038: * @return The class info loader.
039: */
040: public ClassInfoLoader loader();
041:
042: /**
043: * Get the name of the class.
044: *
045: * @return The name of the class.
046: */
047: public String name();
048:
049: /**
050: * Get the index into the constant pool of class.
051: *
052: * @return The index of the class.
053: */
054: public int classIndex();
055:
056: /**
057: * Get the index into the constant pool of class's superclass.
058: *
059: * @return The index of the superclass.
060: */
061: public int super classIndex();
062:
063: /**
064: * Get the indices into the constant pool of class's interfaces.
065: *
066: * @return The indices of the interfaces.
067: */
068: public int[] interfaceIndices();
069:
070: /**
071: * Set the index into the constant pool of class.
072: *
073: * @param index
074: * The index of the class.
075: */
076: public void setClassIndex(int index);
077:
078: /**
079: * Set the index into the constant pool of class's superclass.
080: *
081: * @param index
082: * The index of the superclass.
083: */
084: public void setSuperclassIndex(int index);
085:
086: /**
087: * Set the indices into the constant pool of class's interfaces.
088: *
089: * @param indices
090: * The indices of the interfaces.
091: */
092: public void setInterfaceIndices(int[] indices);
093:
094: /**
095: * Set the modifiers of the class. The values correspond to the constants in
096: * the Modifiers class.
097: *
098: * @param modifiers
099: * A bit vector of modifier flags for the class.
100: * @see Modifiers
101: */
102: public void setModifiers(int modifiers);
103:
104: /**
105: * Get the modifiers of the class. The values correspond to the constants in
106: * the Modifiers class.
107: *
108: * @return A bit vector of modifier flags for the class.
109: * @see Modifiers
110: */
111: public int modifiers();
112:
113: /**
114: * Get an array of FieldInfo structures for each field in the class.
115: *
116: * @return An array of FieldInfo structures.
117: * @see FieldInfo
118: */
119: public FieldInfo[] fields();
120:
121: /**
122: * Returns an array of MethodInfo structures for each method in the class.
123: */
124: public MethodInfo[] methods();
125:
126: /**
127: * Sets the methods in this class.
128: */
129: public void setMethods(MethodInfo[] methods);
130:
131: /**
132: * Returns an array of the constants in the constant pool.
133: */
134: public Constant[] constants();
135:
136: /**
137: * Set all the constants in the constant pool.
138: *
139: * @param constants
140: * The array of Constants.
141: * @see Constant
142: */
143: public void setConstants(Constant[] constants);
144:
145: /**
146: * Commit any changes to the file or to the virtual machine.
147: */
148: public void commit();
149:
150: /**
151: * Commits only certain methods and fields.
152: *
153: * @param methods
154: * Methods (<tt>MethodInfo</tt>s) to commit. If <tt>null</tt>,
155: * all methods are committed.
156: * @param fields
157: * Fields (<tt>FieldInfo</tt>s) to commit. If <tt>null</tt>,
158: * all fields are committed.
159: */
160: public void commitOnly(Set methods, Set fields);
161:
162: /**
163: * Factory method that creates a new field in the class being modeled
164: */
165: public FieldInfo addNewField(int modifiers, int typeIndex,
166: int nameIndex);
167:
168: /**
169: * Factory method that creates a new field with a constant value in the
170: * class being modeled
171: *
172: * @param cvNameIndex
173: * The index in the class's constant pool for the UTF8 constant
174: * "ConstantValue"
175: * @param constantValueIndex
176: * The index in the class's constant pool for the constant value
177: */
178: public FieldInfo addNewField(int modifiers, int typeIndex,
179: int nameIndex, int cvNameIndex, int constantValueIndex);
180:
181: /**
182: * Deletes a field from this class
183: *
184: * @param nameIndex
185: * Index in the constant pool of the name of the field to be
186: * deleted
187: *
188: * @throws IllegalArgumentException The class modeled by this
189: * <code>ClassInfo</code> does not contain a field whose name is at
190: * the given index
191: */
192: public void deleteField(int nameIndex);
193:
194: /**
195: * Deletes a method from this class
196: *
197: * @param nameIndex
198: * Index in the constant pool of the name of the method to be
199: * deleted
200: * @param typeIndex
201: * Index in the constant pool of the type of the method to be
202: * deleted
203: *
204: * @throws IllegalArgumentException The class modeled by this
205: * <code>ClassInfo</code> does not contain a method whose name and
206: * type are not at the given indices
207: */
208: public void deleteMethod(int nameIndex, int typeIndex);
209:
210: /**
211: * Adds a new method to this class.
212: *
213: * @param modifiers
214: * The {@link EDU.purdue.cs.bloat.reflect.Modifiers modifiers}
215: * for the new method
216: * @param typeIndex
217: * The index of the type (conglomeration of the parameter types
218: * and the return type) for this method in the class's constant
219: * pool
220: * @param nameIndex
221: * The index of the name of the method in the class's constant
222: * pool
223: * @param exceptionIndex
224: * The index of the UTF8 string "Exceptions" in the class's
225: * constant pool
226: * @param exceptionTypeIndices
227: * The indices in the class's constant pool of the type of the
228: * exceptions thrown by this method
229: * @param codeIndex
230: * The index of the UTF8 string "Code" in the class's constant
231: * pool
232: */
233: public MethodInfo addNewMethod(int modifiers, int typeIndex,
234: int nameIndex, int exceptionIndex,
235: int[] exceptionTypeIndices, int codeIndex);
236:
237: public void print(java.io.PrintStream out);
238:
239: public void print(java.io.PrintWriter out);
240:
241: public String toString();
242: }
|