org.objectweb.jac.ide
Class CodeGeneration

java.lang.Object
  |
  +--org.objectweb.jac.ide.CodeGeneration

public class CodeGeneration
extends Object


Constructor Summary
CodeGeneration()
           
 
Method Summary
static Errors compile(Project project)
           
static Errors compile(Projects projects)
           
static Errors compileProjectCode(Project project)
          Run compilation command for a project.
static void createApplicationCode(Project prj, Application app, File baseDir)
          Generate code for an application (Run and aspect configurations)
static void createAspectCode(Project prj, Aspect a, File baseDir, String ppath)
          Generate java source code for an aspect.
static void createClassCode(Project prj, Class c, File baseDir, String ppath)
          Generate the java source code of a class.
static void createEnumCode(EnumeratedType enum, File dir)
          Generate java sources for an enumerated type.
static void createFieldCode(LineNumberWriter output, Map lineNumbers, Field field, boolean isInterface)
          Generate the code for a field, its getter and its setter
static void createJAR(Project project)
          Creates a JAR file containing all the .class files
static void createJavaCode(Project project, String baseDir)
          Generate java sources for a project
static void createManifest(Project project)
           
static void createMethodCode(LineNumberWriter output, Map lineNumbers, Method method, boolean isInterface)
          Generate the code for a method
static void createPackageCode(Project prj, Package pkg, File baseDir, String ppath)
          Generate code for the classes of a package and its subpackages.
static void createProjectCode(Project project, String baseDir)
          Generate code for all the classes and aspects of a project.
static void createRelationCode(LineNumberWriter output, Map lineNumbers, RelationLink rel, RelationRole role, boolean isInterface)
           
static void documentProjectCode(Project project, String baseDir)
          Generated javadoc documentation for a project
static Errors generateAndCompile(Project project)
           
static Errors generateAndCompile(Projects projects)
           
static Errors generateAndCompileProjectCode(Project project, String baseDir)
           
static void generateAndReload(AspectConfiguration ac)
           
static void generateCode(AspectConfiguration ac)
           
static void generateCode(Class cl)
           
static void generateCode(Package pkg)
           
static void generateCode(Project project)
           
static void generateCode(Projects projects)
           
static void generateJavaCode(Project project)
           
static String getAdderName(String fieldName)
          Returns the adder's name that corresponds to the given collection's name.
static Map getClassLineNumbers(Class c)
          Returns a Map giving the line number of methods in the generated java source file.
static String getClearerName(String fieldName)
          Returns the clearer's name that corresponds to the given collection's name.
static String getGetterName(String fieldName)
          Returns the getter's name that corresponds to the given field's name.
static String getRemoverName(String fieldName)
          Returns the remover's name that corresponds to the given collection's name.
static String getSetterName(String fieldName)
          Returns the setter's name that corresponds to the given field's name.
static void joinFullNames(Writer out, Collection items, String separator)
          Write the full names of the items of a collection, separated by a string.
static String keyWrapper(Typed keyField, String value)
           
static String translateParam(ConfigItem config)
          Return a string representing the call of method on ModelElement element with param param
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CodeGeneration

public CodeGeneration()
Method Detail

createProjectCode

public static void createProjectCode(Project project,
                                     String baseDir)
                              throws org.objectweb.jac.ide.CannotGenerateException,
                                     IOException
Generate code for all the classes and aspects of a project.

Parameters:
project - the project
baseDir - base directory where to put generated files
org.objectweb.jac.ide.CannotGenerateException
IOException

createJavaCode

public static void createJavaCode(Project project,
                                  String baseDir)
                           throws org.objectweb.jac.ide.CannotGenerateException,
                                  IOException,
                                  FileNotFoundException
Generate java sources for a project

Parameters:
project - a project
baseDir - directory where to generate files
org.objectweb.jac.ide.CannotGenerateException
IOException
FileNotFoundException

createEnumCode

public static void createEnumCode(EnumeratedType enum,
                                  File dir)
                           throws IOException
Generate java sources for an enumerated type.

Parameters:
enum - an enumerated type
dir - directory where to generate the file
IOException

createApplicationCode

public static void createApplicationCode(Project prj,
                                         Application app,
                                         File baseDir)
                                  throws org.objectweb.jac.ide.CannotGenerateException,
                                         IOException
Generate code for an application (Run and aspect configurations)

Parameters:
prj - the project
app - the application
baseDir - the base directory where to put the generated files
org.objectweb.jac.ide.CannotGenerateException
IOException

createPackageCode

public static void createPackageCode(Project prj,
                                     Package pkg,
                                     File baseDir,
                                     String ppath)
                              throws FileNotFoundException,
                                     IOException
Generate code for the classes of a package and its subpackages.

Parameters:
prj - the project
pkg - the package
baseDir - directory where to put the files of the package
ppath - java package path (myapp.mypackage for instance)
FileNotFoundException
IOException

getClassLineNumbers

public static Map getClassLineNumbers(Class c)
Returns a Map giving the line number of methods in the generated java source file.


createClassCode

public static void createClassCode(Project prj,
                                   Class c,
                                   File baseDir,
                                   String ppath)
Generate the java source code of a class.

Parameters:
prj - the project
c - the class
baseDir - directory where to put the generated file
ppath - java package path of the class

createFieldCode

public static void createFieldCode(LineNumberWriter output,
                                   Map lineNumbers,
                                   Field field,
                                   boolean isInterface)
                            throws IOException
Generate the code for a field, its getter and its setter

Parameters:
output - where to write generated code
lineNumbers - line numbers information will be stored in this map
field - the field to generate code for
isInterface - wether the field belongs to an interface
IOException

createRelationCode

public static void createRelationCode(LineNumberWriter output,
                                      Map lineNumbers,
                                      RelationLink rel,
                                      RelationRole role,
                                      boolean isInterface)
                               throws IOException
IOException

createMethodCode

public static void createMethodCode(LineNumberWriter output,
                                    Map lineNumbers,
                                    Method method,
                                    boolean isInterface)
                             throws IOException
Generate the code for a method

Parameters:
output - where to write generated code
lineNumbers -
method - the method to generate code for
isInterface - wether the method belongs to an interface
IOException

createAspectCode

public static void createAspectCode(Project prj,
                                    Aspect a,
                                    File baseDir,
                                    String ppath)
Generate java source code for an aspect.

Parameters:
prj - the project
a - the aspect
baseDir - directory where to put the file
ppath - java package path of the aspect component

getSetterName

public static String getSetterName(String fieldName)
Returns the setter's name that corresponds to the given field's name.


getGetterName

public static String getGetterName(String fieldName)
Returns the getter's name that corresponds to the given field's name.


getAdderName

public static String getAdderName(String fieldName)
Returns the adder's name that corresponds to the given collection's name.


getClearerName

public static String getClearerName(String fieldName)
Returns the clearer's name that corresponds to the given collection's name.


getRemoverName

public static String getRemoverName(String fieldName)
Returns the remover's name that corresponds to the given collection's name.


keyWrapper

public static String keyWrapper(Typed keyField,
                                String value)

generateAndCompileProjectCode

public static Errors generateAndCompileProjectCode(Project project,
                                                   String baseDir)
                                            throws org.objectweb.jac.ide.CannotGenerateException,
                                                   org.objectweb.jac.ide.CannotCompileException,
                                                   IOException,
                                                   InterruptedException
org.objectweb.jac.ide.CannotGenerateException
org.objectweb.jac.ide.CannotCompileException
IOException
InterruptedException

compileProjectCode

public static Errors compileProjectCode(Project project)
                                 throws org.objectweb.jac.ide.CannotCompileException,
                                        IOException,
                                        InterruptedException
Run compilation command for a project.

Parameters:
project - the project to compile
Returns:
A list of errors that occured during compilation.
org.objectweb.jac.ide.CannotCompileException
IOException
InterruptedException

documentProjectCode

public static void documentProjectCode(Project project,
                                       String baseDir)
Generated javadoc documentation for a project


translateParam

public static final String translateParam(ConfigItem config)
Return a string representing the call of method on ModelElement element with param param

Parameters:
config - the configItem of method
Returns:
a valid string that the ACCParser will understand

joinFullNames

public static void joinFullNames(Writer out,
                                 Collection items,
                                 String separator)
                          throws IOException
Write the full names of the items of a collection, separated by a string.

Parameters:
out - where to write
items - a collection of ModelElements
separator - use this string as a separator
IOException

generateCode

public static void generateCode(Projects projects)
                         throws Exception
Exception

compile

public static Errors compile(Projects projects)
                      throws Exception
Exception

generateAndCompile

public static Errors generateAndCompile(Projects projects)
                                 throws Exception
Exception

generateCode

public static void generateCode(Package pkg)
                         throws Exception
Exception

generateCode

public static void generateCode(Class cl)
                         throws Exception
Exception

generateCode

public static void generateCode(Project project)
                         throws Exception
Exception

generateJavaCode

public static void generateJavaCode(Project project)
                             throws Exception
Exception

compile

public static Errors compile(Project project)
                      throws org.objectweb.jac.ide.CannotCompileException,
                             IOException,
                             InterruptedException
org.objectweb.jac.ide.CannotCompileException
IOException
InterruptedException

generateAndCompile

public static Errors generateAndCompile(Project project)
                                 throws org.objectweb.jac.ide.CannotGenerateException,
                                        org.objectweb.jac.ide.CannotCompileException,
                                        IOException,
                                        InterruptedException,
                                        Exception
org.objectweb.jac.ide.CannotGenerateException
org.objectweb.jac.ide.CannotCompileException
IOException
InterruptedException
Exception

createJAR

public static void createJAR(Project project)
                      throws IOException
Creates a JAR file containing all the .class files

IOException

createManifest

public static void createManifest(Project project)
                           throws IOException
IOException

generateCode

public static void generateCode(AspectConfiguration ac)
                         throws Exception
Exception

generateAndReload

public static void generateAndReload(AspectConfiguration ac)
                              throws Throwable
Throwable