| java.lang.Object EDU.purdue.cs.bloat.file.ClassFile
Method Summary | |
public FieldInfo | addNewField(int modifiers, int typeIndex, int nameIndex) | public FieldInfo | addNewField(int modifiers, int typeIndex, int nameIndex, int cvNameIndex, int constantValueIndex) | public MethodInfo | addNewMethod(int modifiers, int typeIndex, int nameIndex, int exceptionIndex, int[] exceptionTypeIndices, int codeIndex) | public int | classIndex() Get the index into the constant pool of the name of the class. | public void | commit() Commit any changes back to a file in the output directory. | public void | commitOnly(Set methods, Set fields) | void | commitTo(OutputStream outStream) Commit changes made to this class. | public Constant[] | constants() Get an array of the constants in the constant pool. | public void | deleteField(int nameIndex) Removes the field whose name is at the given index in the constant pool. | public void | deleteMethod(int nameIndex, int typeIndex) | public FieldInfo[] | fields() Get an array of FieldInfo structures for each field in the class. | public File | file() Returns the File from which this ClassFile was created. | public int[] | interfaceIndices() Get the indices into the constant pool of the names of the class's
interfaces. | public ClassInfoLoader | loader() Get the class info loader for the class. | public MethodInfo[] | methods() Returns an array of MethodInfo structures for each method in the class. | public int | modifiers() Get the modifiers of the class. | public String | name() Get the name of the class, including the package name. | public File | outputFile() Creates a new File object to hold this class. | public void | print(PrintStream out) Prints a textual representation of this classfile to a PrintStream. | public void | print(PrintWriter out) | public void | setClassIndex(int index) Set the index into the constant pool of the name of the class. | public void | setConstants(Constant[] constants) Set all the constants in the constant pool. | public void | setInterfaceIndices(int[] indices) Set the indices into the constant pool of the names of the class's
interfaces. | public void | setMethods(MethodInfo[] methods) Sets the methods in this class. | public void | setModifiers(int modifiers) Set the modifiers of the class. | public void | setSuperclassIndex(int index) Set the index into the constant pool of the name of the class's
superclass. | public int | superclassIndex() Get the index into the constant pool of the name of the class's
superclass. | public String | toString() |
ClassFile | public ClassFile(File file, ClassInfoLoader loader, DataInputStream in)(Code) | | Constructor. This constructor parses the class file from the input
stream.
Parameters: file - The file in which the class resides. Parameters: loader - The class info loader which loaded the class. Parameters: in - The data stream containing the class. exception: ClassFormatError - When the class could not be parsed. |
ClassFile | public ClassFile(int modifiers, int classIndex, int superClassIndex, int[] interfaceIndexes, List constants, ClassInfoLoader loader)(Code) | | Creates a new ClassFile from scratch. It has no fields or
methods.
Parameters: modifiers - The modifiers describing the newly-created class Parameters: classIndex - The index of the type of the newly-created class in itsconstant pool Parameters: superClassIndex - The index of the type of the newly-created class's superclassin its constant pool Parameters: interfaceIndexes - The indexes of the types of the interfaces that thenewly-created class implements Parameters: constants - The constant pool for the newly created class (a list ofConstants). |
addNewField | public FieldInfo addNewField(int modifiers, int typeIndex, int nameIndex)(Code) | | Creates a new field in this classfile
|
addNewField | public FieldInfo addNewField(int modifiers, int typeIndex, int nameIndex, int cvNameIndex, int constantValueIndex)(Code) | | Creates a new field in this classfile
|
addNewMethod | public MethodInfo addNewMethod(int modifiers, int typeIndex, int nameIndex, int exceptionIndex, int[] exceptionTypeIndices, int codeIndex)(Code) | | Creates a new method in this class
|
classIndex | public int classIndex()(Code) | | Get the index into the constant pool of the name of the class.
The index of the name of the class. |
commit | public void commit()(Code) | | Commit any changes back to a file in the output directory. The output
directory is determined from the ClassFileLoader.
|
commitOnly | public void commitOnly(Set methods, Set fields)(Code) | | |
commitTo | void commitTo(OutputStream outStream)(Code) | | Commit changes made to this class. Write changes to an OutputStream.
|
constants | public Constant[] constants()(Code) | | Get an array of the constants in the constant pool.
An array of Constants. |
deleteField | public void deleteField(int nameIndex)(Code) | | Removes the field whose name is at the given index in the constant pool.
throws: IllegalArgumentException - The class does not contain a field whosename is at the given index |
deleteMethod | public void deleteMethod(int nameIndex, int typeIndex)(Code) | | Deletes a method from this class
Parameters: nameIndex - Index in the constant pool of the name of the method to bedeleted Parameters: typeIndex - Index in the constant pool of the type of the method to bedeleted throws: IllegalArgumentException - The class modeled by thisClassInfo does not contain a method whose name andtype are not at the given indices |
fields | public FieldInfo[] fields()(Code) | | Get an array of FieldInfo structures for each field in the class.
An array of FieldInfo structures. |
file | public File file()(Code) | | Returns the File from which this ClassFile was created. If
this ClassFile was created from scratch, null
is returned.
|
interfaceIndices | public int[] interfaceIndices()(Code) | | Get the indices into the constant pool of the names of the class's
interfaces.
The indices of the names of the interfaces. |
loader | public ClassInfoLoader loader()(Code) | | Get the class info loader for the class.
The class info loader for the class. |
methods | public MethodInfo[] methods()(Code) | | Returns an array of MethodInfo structures for each method in the class.
|
modifiers | public int modifiers()(Code) | | Get the modifiers of the class. The values correspond to the constants in
the Modifiers class.
A bit vector of modifier flags for the class. See Also: Modifiers |
name | public String name()(Code) | | Get the name of the class, including the package name.
The name of the class. |
outputFile | public File outputFile()(Code) | | Creates a new File object to hold this class. It is placed in the output
directory and has the name of the class represented by this ClassFile
followed by the .class extension.
|
print | public void print(PrintStream out)(Code) | | Prints a textual representation of this classfile to a PrintStream. The
text includes information such as the constants in the constant pool, the
name of the class's superclass, its modifier flags, its fields, and its
methods.
Parameters: out - The stream to which to print. |
setClassIndex | public void setClassIndex(int index)(Code) | | Set the index into the constant pool of the name of the class.
Parameters: index - The index of the name of the class. |
setConstants | public void setConstants(Constant[] constants)(Code) | | Set all the constants in the constant pool.
Parameters: constants - The array of Constants. |
setInterfaceIndices | public void setInterfaceIndices(int[] indices)(Code) | | Set the indices into the constant pool of the names of the class's
interfaces.
Parameters: indices - The indices of the names of the interfaces. |
setMethods | public void setMethods(MethodInfo[] methods)(Code) | | Sets the methods in this class.
|
setModifiers | public void setModifiers(int modifiers)(Code) | | Set the modifiers of the class. The values correspond to the constants in
the Modifiers class.
Parameters: modifiers - A bit vector of modifier flags for the class. See Also: Modifiers |
setSuperclassIndex | public void setSuperclassIndex(int index)(Code) | | Set the index into the constant pool of the name of the class's
superclass.
Parameters: index - The index of the name of the superclass. |
superclassIndex | public int superclassIndex()(Code) | | Get the index into the constant pool of the name of the class's
superclass.
The index of the name of the superclass. |
|
|