|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--javar.JavaByteCodeFile
This class will represent the structure of a class file. It is constructed using a physical location of a class file.
| Field Summary | |
static int |
MAGIC_NUMBER
CAFEBABE the cafe where magic happens |
static short |
MAJOR_NUMBER
These is the default major number. |
static short |
MINOR_NUMBER
These is the default minor number. |
| Constructor Summary | |
JavaByteCodeFile(File theFile)
Constructor |
|
JavaByteCodeFile(InputStream stream)
This will take in input stream and create a java file representation from that. |
|
JavaByteCodeFile(String cName)
Constructor, uses java.lang.Object as its parent |
|
JavaByteCodeFile(String cName,
String pName)
Constructor |
|
| Method Summary | |
void |
addMethod(Method method)
This will add a method to the class |
int |
getAccessFlags()
This will return the access flags for this class |
long |
getClassName()
This will return index of the name of the class |
String |
getClassNameAsString()
This will return the fully qualified class name that contains both the name of the class and the package for the class. |
ConstantPool |
getConstantPool()
This will return the constant pool for this class. |
int |
getFieldCount()
This will return the number of fields that this class has |
int |
getInterfaceCount()
This will return the number of interfaces that this class deals with |
int |
getMagicNumber()
This will return the magic number for this class this should always return 0xCAFEBABE which is 3405691582 as an integer. |
int |
getMajorNumber()
This will return the major number for this class this should always return 3 which is the current major number for java class files. |
int |
getMethodCount()
This will return the number of methods that are in this class |
int |
getMinorNumber()
This will return the minor number for this class this should always return 45 which is the current major number for java class files. |
String |
getPackageName()
This will return the name of this classes package. |
long |
getParentClassName()
This will return the index of the name of the parent Class |
String |
getParentClassNameAsString()
This will return the fully qualified super class name that contains both the name of the class and the package for the class. |
String |
getShortClassName()
This will return the name of this class without the package. |
String |
getShortParentClassName()
This will return the name of this class without the package. |
boolean |
isInterface()
This will tell if this class is an interface or not. |
Iterator |
listFields()
This will list all of the interfaces for this class. |
Iterator |
listInterfaces()
This will list all of the interfaces for this class. |
Iterator |
listMethods()
This will get all the methods that are part of this class file |
void |
setAccessFlags(int val)
This will set the access flags for this class |
void |
setClassName(int val)
This will set index of the name of the class |
void |
setConstantPool(ConstantPool pool)
This will set the constant pool for this class |
void |
setMagicNumber(int number)
This will set the magic number for this class. |
void |
setMajorNumber(int number)
This will set the major number for this class. |
void |
setMinorNumber(int number)
This will set the minor number for this class. |
void |
setParentClassName(int val)
This will set the index of the name of the parent Class |
byte[] |
toBytes()
This will convert this byte code file into an array of class bytes. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final int MAGIC_NUMBER
public static final short MAJOR_NUMBER
public static final short MINOR_NUMBER
| Constructor Detail |
public JavaByteCodeFile(String cName)
cName - The name of the class to create
public JavaByteCodeFile(String cName,
String pName)
cName - The name of the class to createpName - The name of the super class
public JavaByteCodeFile(File theFile)
throws FileNotFoundException,
JavarParseException
theFile -
FileNotFoundException
JavarParseException
public JavaByteCodeFile(InputStream stream)
throws JavarParseException
stream - A stream that can be used to initialize all values
of this bytecodefile| Method Detail |
public void addMethod(Method method)
method - The method to addpublic Iterator listMethods()
public int getMagicNumber()
public int getMajorNumber()
public int getMinorNumber()
public ConstantPool getConstantPool()
public int getAccessFlags()
public long getClassName()
public String getClassNameAsString()
public String getShortClassName()
public String getPackageName()
public long getParentClassName()
public String getParentClassNameAsString()
public String getShortParentClassName()
public int getInterfaceCount()
public Iterator listInterfaces()
public int getFieldCount()
public Iterator listFields()
public int getMethodCount()
public boolean isInterface()
public void setMagicNumber(int number)
number - the magic number to set for this classpublic void setMajorNumber(int number)
number - the major number to set for this classpublic void setMinorNumber(int number)
number - the minor number to set for this classpublic void setConstantPool(ConstantPool pool)
public void setAccessFlags(int val)
public void setClassName(int val)
public void setParentClassName(int val)
public byte[] toBytes()
throws JavarIOException
JavarIOException - if there was an error writing the data
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||