public class JiapiClass
extends java.lang.Object
JiapiMethods and
JiapiFields.
JiapiClass is an abstract class. Concrete classes are loaded using Loader.
Loader loader = new Loader();
JiapiClass clazz = loader.loadClass(className);
Loader| Constructor and Description |
|---|
JiapiClass(ClassFile classFile) |
| Modifier and Type | Method and Description |
|---|---|
JiapiField |
addField(int modifiers,
java.lang.String type,
java.lang.String name)
Adds a new Field to this JiapiClass.
|
JiapiField |
addField(java.lang.String name)
Adds a named Field to this JiapiClass.
|
void |
addInterface(JiapiClass interfaceType)
Adds an interface for a class.
|
void |
addInterface(java.lang.String interfaceType)
Adds an interface for a class.
|
JiapiMethod |
addMethod(int modifiers,
java.lang.String methodName,
Signature signature)
Adds a new method to this class.
|
JiapiMethod |
addMethod(JiapiMethod m)
Adds a new method to this class.
|
static JiapiClass |
createClass(java.lang.String name)
Create empty JiapiClass.
|
void |
dump(java.io.OutputStream out)
Dumps bytecodes of this JiapiClass to OutputStream given.
|
byte[] |
getByteCode()
Get the byte-code of this class.
|
ConstantPool |
getConstantPool()
Get the ConstantPool related to this JiapiClass.
|
JiapiAnnotation[] |
getDeclaredAnnotations()
Get all the declared annotations of this Class.
|
JiapiField |
getDeclaredField(java.lang.String name)
Get a declared field of a class.
|
JiapiField[] |
getDeclaredFields()
Get all the fields declared by this JiapiClass.
|
JiapiMethod |
getDeclaredMethod(java.lang.String name,
JiapiClass[] parameterTypes)
Get a specific method from a class.
|
JiapiMethod |
getDeclaredMethod(java.lang.String name,
java.lang.String[] parameterTypeNames)
Get a specific method from a class.
|
JiapiMethod[] |
getDeclaredMethods()
Get all the methods of this JiapiClass.
|
JiapiField |
getField(java.lang.String name)
Get a field from a class or from any of its superclasses.
|
JiapiField[] |
getFields()
Get all the Fields of this JiapiClass and its superclasses.
|
java.lang.String[] |
getInterfaceNames()
Gets all the interfaces, that this class directly implements.
|
JiapiClass[] |
getInterfaceTypes()
Gets all the interfaces, that this class directly implements.
|
Loader |
getLoader()
Gets the Loader, that loaded this JiapiClass.
|
JiapiMethod |
getMethod(java.lang.String name,
JiapiClass[] parameterTypes)
Get a specific method from a class or any of its superclasses.
|
JiapiMethod |
getMethod(java.lang.String name,
java.lang.String[] parameterTypeNames)
Get a specific method from a class or any of its superclasses.
|
JiapiMethod[] |
getMethods()
Get all the methods of this JiapiClass and its superclasses.
|
int |
getModifiers()
Get modifiers of this JiapiClass.
|
java.lang.String |
getName()
Get name of a class.
|
java.lang.String |
getPackageName()
Get the package where this class is defined.
|
JiapiClass |
getSuperclass()
Gets the super class of this JiapiClass.
|
boolean |
isInterface()
Tests, whether this JiapiClass is an interface or not.
|
static void |
main(java.lang.String[] args) |
static JiapiClass |
parseClass(byte[] bytes)
Parses byte[] for a class definition.
|
java.lang.String |
toString() |
public JiapiClass(ClassFile classFile)
public JiapiField addField(int modifiers, java.lang.String type, java.lang.String name) throws FieldExistsException
modifiers - Modifiers of the fieldtype - Type of the field to be added. Type is given in
simple form, like 'java.lang.Object' or 'int'name - Name of the field to be addedFieldExistsException - if a field with a same name already
existspublic JiapiField addField(java.lang.String name) throws FieldExistsException
public and of type java.lang.Objectname - Name of the field to be addedFieldExistsException - if a field with a same name already
existspublic void addInterface(JiapiClass interfaceType) throws java.lang.IllegalArgumentException
interfaceType - the type of an interfacejava.lang.IllegalArgumentException - is thrown, if interfaceType is
not an interface.public void addInterface(java.lang.String interfaceType)
interfaceType - the type of an interfacepublic JiapiMethod addMethod(int modifiers, java.lang.String methodName, Signature signature) throws MethodExistsException
modifiers - access modifiers of a classmethodName - name of a methodsignature - signature of a methodMethodExistsException - if a method with a same name and
parameter signature already existsModifierpublic JiapiMethod addMethod(JiapiMethod m) throws MethodExistsException
m - JiapiMethod to be used as method signatureMethodExistsException - if a method with a same name and
parameter signature already existspublic static JiapiClass createClass(java.lang.String name)
name - Name of the JiapiClass to createpublic void dump(java.io.OutputStream out)
throws java.io.IOException
out - OutputStream to usejava.io.IOExceptionpublic byte[] getByteCode()
public ConstantPool getConstantPool()
public JiapiAnnotation[] getDeclaredAnnotations()
public JiapiField getDeclaredField(java.lang.String name) throws java.lang.NoSuchFieldException
name - a name of a fieldjava.lang.NoSuchFieldException - if matching field is not foundpublic JiapiField[] getDeclaredFields()
public JiapiMethod getDeclaredMethod(java.lang.String name, JiapiClass[] parameterTypes) throws java.lang.NoSuchMethodException
parameterTypes - An array of JiapiClass, where each element
represents a parameter.java.lang.NoSuchMethodException - if matching method is not foundpublic JiapiMethod getDeclaredMethod(java.lang.String name, java.lang.String[] parameterTypeNames) throws java.lang.NoSuchMethodException
java.lang.Object,
int, int[], my.stuff.Thing[]Example:
JiapiClass clazz = ...;
String[] paramTypeNames = new String[] {"java.lang.Object[]", "int"};
JiapiMethod m = clazz.getMethod("foo", paramTypeNames);
Would return a method foo(Object[], int)name - Name of the methodparameterTypeNames - Type names of the parametersjava.lang.NoSuchMethodException - if matching method is not foundpublic JiapiMethod[] getDeclaredMethods()
public JiapiField getField(java.lang.String name) throws java.lang.NoSuchFieldException, java.lang.ClassNotFoundException
name - a name of a fieldjava.lang.NoSuchFieldException - if matching field is not foundjava.lang.ClassNotFoundException - is thrown if superclass could
not be loadedpublic JiapiField[] getFields() throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundException - is thrown if superclass could
not be loadedgetDeclaredFields() for further infopublic java.lang.String[] getInterfaceNames()
public JiapiClass[] getInterfaceTypes() throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundExceptionpublic Loader getLoader()
public JiapiMethod getMethod(java.lang.String name, JiapiClass[] parameterTypes) throws java.lang.NoSuchMethodException, java.lang.ClassNotFoundException
parameterTypes - An array of JiapiClass, where each element
represents a parameter.java.lang.NoSuchMethodException - if matching method is not foundjava.lang.ClassNotFoundException - is thrown if superclass could
not be loadedpublic JiapiMethod getMethod(java.lang.String name, java.lang.String[] parameterTypeNames) throws java.lang.NoSuchMethodException, java.lang.ClassNotFoundException
java.lang.Object,
int, int[], my.stuff.Thing[]Example:
JiapiClass clazz = ...;
String[] paramTypeNames = new String[] {"java.lang.Object[]", "int"};
JiapiMethod m = clazz.getMethod("foo", paramTypeNames);
Would return a method foo(Object[], int)name - Name of the methodparameterTypeNames - Type names of the parametersjava.lang.NoSuchMethodException - if matching method is not foundjava.lang.ClassNotFoundException - is thrown if superclass could
not be loadedpublic JiapiMethod[] getMethods() throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundException - is thrown if superclass could
not be loadedgetDeclaredMethods() for further infopublic int getModifiers()
Modifierpublic java.lang.String getName()
public java.lang.String getPackageName()
public JiapiClass getSuperclass() throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundException - is thrown, if superclass could not
be loadedpublic boolean isInterface()
public static void main(java.lang.String[] args)
throws java.lang.Exception
java.lang.Exceptionpublic static JiapiClass parseClass(byte[] bytes) throws java.io.IOException
java.io.IOExceptionpublic java.lang.String toString()
toString in class java.lang.ObjectCopyright © 2001. Documenation generated January 12 2013.