public class GeneratedCodeClass extends Object implements CodeClass
When creating classes, instantiate one of these, add fields and methods. Associate CodeGenerator instances with methods. Then, use GeneratedClassLoader to make a new class.
| Constructor and Description |
|---|
GeneratedCodeClass(String name,
Class superClass,
Class[] interfaces,
int modifiers) |
GeneratedCodeClass(String name,
CodeClass superClass,
CodeClass[] interfaces,
int modifiers) |
| Modifier and Type | Method and Description |
|---|---|
void |
createCode(OutputStream os) |
CodeField |
createField(String name,
CodeClass clazz,
int mods) |
GeneratedCodeMethod |
createMethod(String name,
CodeClass type,
CodeClass[] args,
int mods)
Create a new method.
|
GeneratedCodeMethod |
createMethod(String name,
CodeClass type,
CodeClass[] args,
String[] argNames,
int mods)
Create a new method.
|
CodeMethod |
getConstructor(CodeClass[] args)
Get a constructor by argument list.
|
String |
getDescriptor() |
CodeField |
getFieldByName(String name)
Get a field by its name.
|
Set |
getFields()
Get all fields accessible through this class.
|
List |
getInterfaces() |
String |
getJName() |
CodeMethod |
getMethod(String name,
CodeClass[] args)
Get a method by name and argument list.
|
Set |
getMethods()
Get all methods declared by this class and its super classes, removing
all super class methods that are over ridden.
|
Set |
getMethodsByName(String name)
Get the name of all methods that could be invoked through this class with
a given name.
|
int |
getModifiers()
Get the modifiers associated with the class.
|
String |
getName() |
String |
getSourceFile()
Get the source file associated with this code class.
|
CodeClass |
getSuperClass() |
boolean |
isArray()
Discover if the class is an array type.
|
boolean |
isDeprecated()
Get the deprecation flag.
|
boolean |
isPrimitive()
Discover if the class represents a primitive type.
|
void |
setCodeGenerator(CodeMethod method,
CodeGenerator cg) |
void |
setDeprecated(boolean deprecated)
Set the deprecation flag.
|
void |
setSourceFile(String sourceFile)
Set the source file associated with this code class.
|
public GeneratedCodeClass(String name, Class superClass, Class[] interfaces, int modifiers) throws CodeException
CodeExceptionpublic GeneratedCodeClass(String name, CodeClass superClass, CodeClass[] interfaces, int modifiers) throws CodeException
CodeExceptionpublic void setSourceFile(String sourceFile)
The source file appears in debugging output and stack traces. Use this method to set the source file that this generated class will clame to be from. You can use non-file names e.g. uri:myGenerator:proxy/foo
To un-set the source file, use null.
sourceFile - the source file for this classpublic String getSourceFile()
Null indicates that no source file is set.
public void setDeprecated(boolean deprecated)
If deprecated is true, the class will be flagged as deprecated.
deprecated - the new value of the deprecationpublic boolean isDeprecated()
public List getInterfaces()
getInterfaces in interface CodeClasspublic Set getMethods()
CodeClassThis should return methods, regardless of their accessability.
getMethods in interface CodeClasspublic Set getMethodsByName(String name)
CodeClassgetMethodsByName in interface CodeClassname - the name of the methodpublic CodeMethod getConstructor(CodeClass[] args) throws NoSuchMethodException
CodeClassgetConstructor in interface CodeClassargs - the arguments it takesNoSuchMethodException - if there is no matching constructorpublic CodeMethod getMethod(String name, CodeClass[] args) throws NoSuchMethodException
CodeClassgetMethod in interface CodeClassname - the name of the methodargs - the arguments it takesNoSuchMethodException - if there is no maching methodpublic Set getFields()
CodeClasspublic CodeClass getSuperClass()
getSuperClass in interface CodeClasspublic CodeField getFieldByName(String name) throws NoSuchFieldException
CodeClassgetFieldByName in interface CodeClassname - the field nameNoSuchFieldException - if there is no field by that name accessible
through this classpublic int getModifiers()
CodeClassgetModifiers in interface CodeClasspublic String getDescriptor()
getDescriptor in interface CodeClasspublic GeneratedCodeMethod createMethod(String name, CodeClass type, CodeClass[] args, String[] argNames, int mods) throws CodeException
This defines the shape of a method that will be generated. Use
setCodeGenerator(org.biojava.utils.bytecode.CodeMethod, org.biojava.utils.bytecode.CodeGenerator) to associate code with the method.
The argNames will become the names of local variables for each argument.
name - the method nametype - the return typeargs - arguments takenargNames - names of the argumentsmods - access modifiersCodeException - if the method could not be createdpublic GeneratedCodeMethod createMethod(String name, CodeClass type, CodeClass[] args, int mods) throws CodeException
This defines the shape of a method that will be generated. Use
setCodeGenerator(org.biojava.utils.bytecode.CodeMethod, org.biojava.utils.bytecode.CodeGenerator) to associate code with the method.
name - the method nametype - the return typeargs - arguments takenmods - access modifiersCodeException - if the method could not be createdpublic CodeField createField(String name, CodeClass clazz, int mods) throws CodeException
CodeExceptionpublic void setCodeGenerator(CodeMethod method, CodeGenerator cg) throws CodeException
CodeExceptionpublic void createCode(OutputStream os) throws IOException, CodeException
IOExceptionCodeExceptionpublic boolean isPrimitive()
CodeClassisPrimitive in interface CodeClassCopyright © 2020 BioJava. All rights reserved.