public class ClassFile extends Object
| Constructor and Description |
|---|
ClassFile(File path)
Creates a new ClassFile on the given class file.
|
ClassFile(InputStream clazz)
Creates a new ClassFile on the given class definition.
|
| Modifier and Type | Method and Description |
|---|---|
ClassAccessFlagSet |
getAccessFlags()
Returns the set of access flags for this class.
|
List<Attribute> |
getAttributes()
Returns the Attributes for a class.
|
TypeName |
getClassName()
Returns the name of the class.
|
ConstantPool |
getConstantPool()
Returns the class constant pool.
|
List<ClassField> |
getFields()
Returns the ClassFields for this class.
|
Collection<Integer> |
getInterfaceIndices()
Returns the constant pool indices of the implemented interfaces.
|
Collection<TypeName> |
getInterfaces()
Returns the names of the implemented interfaces.
|
int |
getMajorVersion()
Returns the major version.
|
List<ClassMethod> |
getMethods()
Returns the ClassMethods for this class.
|
int |
getMinorVersion()
Returns the minor version.
|
TypeName |
getSuperClassName()
Returns the name of the super class.
|
static void |
main(String[] args)
Prints out the detail of the specified class.
|
void |
setAccessFlags(ClassAccessFlagSet set)
Sets the set of access flags for this class.
|
void |
setClassName(TypeName name)
Sets the name of the class.
|
void |
setSuperClassName(TypeName name)
Sets the name of the super class.
|
void |
setVersion(int major,
int minor)
Changes the class file version.
|
String |
toString() |
void |
writeAccessFlags(DataOutputStream output)
Writes the access flags.
|
void |
writeAttributes(DataOutputStream output)
Writes the class attributes.
|
void |
writeClass(OutputStream stream)
Writes the class file.
|
void |
writeClass(String path)
Writes the class file.
|
void |
writeClassName(DataOutputStream output)
Writes the class name.
|
void |
writeFields(DataOutputStream output)
Writes the class fields.
|
void |
writeInterfaces(DataOutputStream output)
Writes the implemented interfaces.
|
void |
writeMethods(DataOutputStream output)
Writes the class methods.
|
void |
writeSuperClass(DataOutputStream output)
Writes the super class extended.
|
public ClassFile(InputStream clazz) throws ClassFormatError
clazz - the class streamClassFormatError - if an error occurs while parsing the class filepublic ClassFile(File path) throws IOException, ClassFormatError
path - the class file pathClassFormatError - if an error occurs while parsing the class fileIOException - if the file could not be openedpublic TypeName getClassName()
public void setClassName(TypeName name)
name - the name of the classpublic TypeName getSuperClassName()
public void setSuperClassName(TypeName name)
name - the name of the super classpublic Collection<TypeName> getInterfaces()
public Collection<Integer> getInterfaceIndices()
public List<ClassField> getFields()
public List<ClassMethod> getMethods()
public int getMajorVersion()
public int getMinorVersion()
public void setVersion(int major,
int minor)
major - the major versionminor - the minor versionpublic ClassAccessFlagSet getAccessFlags()
public void setAccessFlags(ClassAccessFlagSet set)
set - the set of access flags for this classpublic void writeClass(String path) throws IOException
path - the class pathIOException - if an error occurs while writingpublic void writeClass(OutputStream stream) throws IOException
stream - the output streamIOException - if an error occurs while writingpublic void writeAccessFlags(DataOutputStream output) throws IOException
output - the output streamIOException - if an error occurs while writing the classpublic void writeClassName(DataOutputStream output) throws IOException
output - the output streamIOException - if an error occurs while writing the classpublic void writeSuperClass(DataOutputStream output) throws IOException
output - the output streamIOException - if an error occurs while writing the classpublic void writeInterfaces(DataOutputStream output) throws IOException
output - the output streamIOException - if an error occurs while writing the classpublic void writeFields(DataOutputStream output) throws IOException
output - the output streamIOException - if an error occurs while writing the classpublic void writeMethods(DataOutputStream output) throws IOException
output - the output streamIOException - if an error occurs while writing the classpublic void writeAttributes(DataOutputStream output) throws IOException
output - the output streamIOException - if an error occurs while writing the classpublic List<Attribute> getAttributes()
public ConstantPool getConstantPool()
public static void main(String[] args) throws IOException
args - the command-line argumentsIOExceptionCopyright © 2012. All Rights Reserved.