Generator configuration

Javadoc

The javadoc of the original method and interface/class will considered. Each Java file which is created by the generator has a well formed javadoc.

The generator consider the following javadoc tags:

  • @generator.ignore: This tag in the method or class javadoc tells the generator to ignore the method or the whole class.

  • @generator.precondition: This tag defines an additional parameter in the method (multiple precondition parameters are allowed!)

    Example:

    package my.dao;
    ...
    
        /**
         * ... 
         * @generator.precondition Integer The number
         */
        public void update();
    

    The generator creates the following output:

    package my.dao;
    ...
    
        /**
         * ... 
         * @param integer The number
         */
        public void update( Integer integer )
            throws RemoteException
    

    If the example above is defined like this:

    @generator.precondition Integer(number) The number

    the generator creates the following output:

    package my.dao;
    ...
    
        /**
         * ... 
         * @param number The number
         */
        public void update( Integer number )
            throws RemoteException
    

    If the precondition parameter contains only the class name (like in the example) and the class is defined in an other package and is not a class from the java.lang package then an import mapping entry should be added to organise the import statements properly. If the parameter is full qualified, then no additional import mapping is required.

    Example:

    package my.dao;
    ...
    
        /**
         * ... 
         * @generator.precondition Collection(numbers)
         */
    ...     
    

    Import mapping entry for the configuration looks like:

        javaGenerator.import.java.util.Collection = true
    


  • @generator.ignoreParameter: This tag ignores a parameter of the method.

    Example:

    package my.dao;
    ...
    
        /**
         * ... 
         * @generator.ignoreParameter myName
         */     
    


  • @generator.return: This tag overwrite the return value of the method.

    Example:

    package my.dao;
    ...
    
        /**
         * ... 
         * @generator.return String the value
         */
    


  • @generator.exception: This tag defines an additional exception of the method.

    Example:

    package my.dao;
    ...
    
        /**
         * ... 
         * @generator.exception IOException ...
         */
    


  • @generator.subpackage: This tag force for the defined method to create a subpackage. The name of the subpackage is followed after the @generator.subpackage definition (see also package mapping).

    Example:

    package my.dao;
    ...
    
        /**
         * ... 
         * @generator.subpackage testdata
         */
    

    The generator creates in the test package a subpackage testdata.


The generator also supports DAO specific tags which are only considered by the DAO generator. To use this feature insert after the @generator the tag dao followed by a generator tag (see above).

Example:

package my.dao;
...

    /**
     * ... 
     * @generator.dao.return String the value
     * @generator.dao.exception FileNotFoundException
     * @generator.dao.subpackage testdata
     */


Configuration file

The generator use the jptools Java file parser and the class JavaFileFormatter to format the generated code. The documentation of the generator configuration you can find in the table below. The formatter and the generator configuration are placed in one file.

All formatter and generator configuration of the different generators like EJBGenerator, DAOFileGenerator, ProcessorGenerator and the ValueObjectGenerator can placed in one file. Generator specific configuration can be defined with their special key (EJBGenerator=ejb, DAOFileGenerator=dao, ProcessorGenerator=sql, ValueObjectGenerator=vo). Have a look in the example configuration!

The follwing file defines the default configuration: Formatter and Generator configuration example.

The following table shows the generator configuration documentation:

Key

Default value

Description

javaGenerator.superClassHeaderName

Abstract

Defines the header name of the abstract super classes

javaGenerator.superClassTrailerName

EJB

Defines the trailer name of the abstract super classes

javaGenerator.classNameHeader

Defines the header name of the classes

javaGenerator.classNameTrailer

DAO

Defines the trailer name of the classes

javaGenerator.addSuperClass

true

Flag to enable creating abstract super classes in each package.

javaGenerator.beanSuperClass

jptools.pattern.dao.AbstractDAO

Defines the superclass of the DAO bean classes.

javaGenerator.testSuperClass

junit.framework.TestCase

Defines the super class of the test case classes

javaGenerator.homeInterfaceTrailer

Home

Defines the trailer name of an EJB home interface

javaGenerator.remoteInterfaceTrailer

Defines the trailer name of an EJB remote interface

javaGenerator.beanImplTrailer

Bean

Defines the name trailer of an EJB implemenation class

javaGenerator.addTestClass

true

Flag to enable creating testclasses for each bean.

javaGenerator.addSuperTestClass

true

Flag to enable creating super testclasses for each test package.

javaGenerator.addLogger

true

Flag to enable creating logger instance in the generated classes. example:

private static final Logger log = Logger.getLogger( DeleteDAOBean.class );

javaGenerator.addVersionAttribute

true

Flag to enable creating version attribute instance in the generated classes. example:

public static final String VERSION = "$Revision: 1.5 $";

javaGenerator.testPackageName

tests

Defines the name of the subpackage for testclasses.

javaGenerator.addPreConditionParameterFirst

true

Insert precondition parameter before the existing parameters.

javaGenerator.ignoreMethodLevel

protected

Defines the method level to ignore methods. The following levels are valid:

  • public

  • protected

  • private

As exmple the level protected ignores the protected and private methods.

javaGenerator.package.xxx

xxx.dao

The package mapping allows to map to another package.

Example:
javaGenerator.package.jptools.util.generator = jptools.util.generator.dao

javaGenerator.import.xxx

true

The import mapping helps to organise the import statements properly.

Example: javaGenerator.import.jptools.util.JavaInformation = true

javaGenerator.exception.xxx

The exception mapping allows to change an existing javadoc description of a defined exception or to eliminate an exception of the throws declaration.

Example: defines a new javadoc text of the exception ReadOnlyModeException
javaGenerator.exception.jptools.exception.ReadOnlyModeException = This exception represents a read only mode failure.

Example: removes the ReadOnlyModeException exception of the throws declaration if it is defined
javaGenerator.exception.jptools.exception.ReadOnlyModeException =

javaGenerator.keyword.xxx

XXx

The keyword mapping guarantees to have well written keywords.

Example:
javaGenerator.keyword.Dao = DAO
javaGenerator.keyword.shift = sHifT