Class GeneratedCodeClass
- All Implemented Interfaces:
- 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.
- Author:
- Matthew Pocock
- 
Constructor SummaryConstructorsConstructorDescriptionGeneratedCodeClass(String name, Class superClass, Class[] interfaces, int modifiers) GeneratedCodeClass(String name, CodeClass superClass, CodeClass[] interfaces, int modifiers) 
- 
Method SummaryModifier and TypeMethodDescriptionvoidcreateField(String name, CodeClass clazz, int mods) createMethod(String name, CodeClass type, CodeClass[] args, int mods) Create a new method.createMethod(String name, CodeClass type, CodeClass[] args, String[] argNames, int mods) Create a new method.getConstructor(CodeClass[] args) Get a constructor by argument list.getFieldByName(String name) Get a field by its name.Get all fields accessible through this class.getJName()Get a method by name and argument list.Get all methods declared by this class and its super classes, removing all super class methods that are over ridden.getMethodsByName(String name) Get the name of all methods that could be invoked through this class with a given name.intGet the modifiers associated with the class.getName()Get the source file associated with this code class.booleanisArray()Discover if the class is an array type.booleanGet the deprecation flag.booleanDiscover if the class represents a primitive type.voidsetCodeGenerator(CodeMethod method, CodeGenerator cg) voidsetDeprecated(boolean deprecated) Set the deprecation flag.voidsetSourceFile(String sourceFile) Set the source file associated with this code class.
- 
Constructor Details- 
GeneratedCodeClasspublic GeneratedCodeClass(String name, Class superClass, Class[] interfaces, int modifiers) throws CodeException - Throws:
- CodeException
 
- 
GeneratedCodeClasspublic GeneratedCodeClass(String name, CodeClass superClass, CodeClass[] interfaces, int modifiers) throws CodeException - Throws:
- CodeException
 
 
- 
- 
Method Details- 
setSourceFileSet the source file associated with this code class.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. - Parameters:
- sourceFile- the source file for this class
 
- 
getSourceFileGet the source file associated with this code class.Null indicates that no source file is set. - Returns:
- the source file for this code class
 
- 
setDeprecatedpublic void setDeprecated(boolean deprecated) Set the deprecation flag.If deprecated is true, the class will be flagged as deprecated. - Parameters:
- deprecated- the new value of the deprecation
 
- 
isDeprecatedpublic boolean isDeprecated()Get the deprecation flag.- Returns:
- wether or not this class is deprecated
 
- 
getInterfaces- Specified by:
- getInterfacesin interface- CodeClass
 
- 
getMethodsDescription copied from interface:CodeClassGet all methods declared by this class and its super classes, removing all super class methods that are over ridden.This should return methods, regardless of their accessability. - Specified by:
- getMethodsin interface- CodeClass
- Returns:
- a Set containing all methods
 
- 
getMethodsByNameDescription copied from interface:CodeClassGet the name of all methods that could be invoked through this class with a given name.- Specified by:
- getMethodsByNamein interface- CodeClass
- Parameters:
- name- the name of the method
- Returns:
- a Set of CodeMethod instances with that name
 
- 
getConstructorDescription copied from interface:CodeClassGet a constructor by argument list.- Specified by:
- getConstructorin interface- CodeClass
- Parameters:
- args- the arguments it takes
- Returns:
- a matching constructor
- Throws:
- NoSuchMethodException- if there is no matching constructor
 
- 
getMethodDescription copied from interface:CodeClassGet a method by name and argument list.- Specified by:
- getMethodin interface- CodeClass
- Parameters:
- name- the name of the method
- args- the arguments it takes
- Returns:
- a matching method
- Throws:
- NoSuchMethodException- if there is no maching method
 
- 
getFieldsDescription copied from interface:CodeClassGet all fields accessible through this class.
- 
getSuperClass- Specified by:
- getSuperClassin interface- CodeClass
 
- 
getFieldByNameDescription copied from interface:CodeClassGet a field by its name.- Specified by:
- getFieldByNamein interface- CodeClass
- Parameters:
- name- the field name
- Returns:
- a CodeField representing the field
- Throws:
- NoSuchFieldException- if there is no field by that name accessible through this class
 
- 
getName
- 
getJName
- 
getModifierspublic int getModifiers()Description copied from interface:CodeClassGet the modifiers associated with the class.- Specified by:
- getModifiersin interface- CodeClass
- Returns:
- the modifier integer
 
- 
getDescriptor- Specified by:
- getDescriptorin interface- CodeClass
 
- 
createMethodpublic GeneratedCodeMethod createMethod(String name, CodeClass type, CodeClass[] args, String[] argNames, int mods) throws CodeException Create a new method.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. - Parameters:
- name- the method name
- type- the return type
- args- arguments taken
- argNames- names of the arguments
- mods- access modifiers
- Returns:
- a new GeneratedCodeMethod
- Throws:
- CodeException- if the method could not be created
 
- 
createMethodpublic GeneratedCodeMethod createMethod(String name, CodeClass type, CodeClass[] args, int mods) throws CodeException Create a new method.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.- Parameters:
- name- the method name
- type- the return type
- args- arguments taken
- mods- access modifiers
- Returns:
- a new GeneratedCodeMethod
- Throws:
- CodeException- if the method could not be created
 
- 
createField- Throws:
- CodeException
 
- 
setCodeGenerator- Throws:
- CodeException
 
- 
createCode- Throws:
- IOException
- CodeException
 
- 
isPrimitivepublic boolean isPrimitive()Description copied from interface:CodeClassDiscover if the class represents a primitive type.- Specified by:
- isPrimitivein interface- CodeClass
- Returns:
- true if the class represents a primative type
 
- 
isArraypublic boolean isArray()Description copied from interface:CodeClassDiscover if the class is an array type.
 
-