org.objectweb.jorm.generator.lib
Class MappingGenerator

java.lang.Object
  |
  +--org.objectweb.jorm.generator.lib.CommonGenerator
        |
        +--org.objectweb.jorm.generator.lib.MappingGenerator
All Implemented Interfaces:
Loggable

public class MappingGenerator
extends CommonGenerator

This class is a generator of XPMapping objects. It is generic either the mapper type. This generator use the velocity tools. The used template is Mapping.vm . Associated to this template, this generator builds a velocity context which contains the following information:
KeyValue
"class"The reference to the Class meta object
"tools" The reference to the CommonHelper
"header" The file name of the common template which contains the header of the generate files.
"mappingTools" The reference to current instance of MappingGenerator.
"cparam" The reference to a CompilerParameter instance. This instance describes the user compilation parameter.
As a XXXMapping class is specific to a mapper, the Mapping.vm template uses externals macros which must be defined as an external template library in the velocity tools.


Field Summary
protected  java.util.HashMap mmops
          The mapper generation specializations (some MOP objects)
 
Fields inherited from class org.objectweb.jorm.generator.lib.CommonGenerator
GEN_TEMPLATE_DIR, logger, loggerFactory, MAPPER_TEMPLATE_DIR, velocityEngine
 
Constructor Summary
MappingGenerator(JormConfigurator jcc, JormCompilerParameter cp)
          This constrcutor permits to specify which BindingMOP must be used
 
Method Summary
 void generate(Class co, TargetHolder holder, JormCompilerParameter cp, JormConfigurator jcc, java.util.Map genctxts)
          This method generates a XXXPMapping file corresponding to the pod parameter in the directory parameter
 java.lang.String getGenclass(int level)
          This method is a generation helper.
 java.util.ArrayList getGenClassNames(GenClassRef gcr)
           
 int getIndexNumber(GenClass gc)
          This method calculates the number of indexes in a GenClass.
 java.util.HashMap getInheritedClasses(Class c)
          This method is a helper to reach the getInheritedClasses(Class, HashMap) method.
 TypedElement getLastElement(GenClassRef gcr)
           
 java.lang.String[][] getTemplateLibraries()
           
 java.lang.String ptype2CTString(PType pt)
          This generation helper method retrieves the string corresponding to the codding type (short value) associated to a PType.
 java.lang.String ptype2String(PType pt)
          This generation helper method retrieves the string corresponding to the instance of the PType.
 
Methods inherited from class org.objectweb.jorm.generator.lib.CommonGenerator
getLogger, getLoggerFactory, setLogger, setLoggerFactory, setVelocityEngine
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mmops

protected java.util.HashMap mmops
The mapper generation specializations (some MOP objects)

Constructor Detail

MappingGenerator

public MappingGenerator(JormConfigurator jcc,
                        JormCompilerParameter cp)
                 throws PException
This constrcutor permits to specify which BindingMOP must be used

Method Detail

getTemplateLibraries

public java.lang.String[][] getTemplateLibraries()
Overrides:
getTemplateLibraries in class CommonGenerator

generate

public void generate(Class co,
                     TargetHolder holder,
                     JormCompilerParameter cp,
                     JormConfigurator jcc,
                     java.util.Map genctxts)
              throws PException
This method generates a XXXPMapping file corresponding to the pod parameter in the directory parameter

Parameters:
co - the meta object interface
holder - The target holder which allows to create files
cp - This parameter permits to reach the compilation parameters
genctxts - The context variables used by the velocity template engine.
PException

getInheritedClasses

public java.util.HashMap getInheritedClasses(Class c)
This method is a helper to reach the getInheritedClasses(Class, HashMap) method. Indeed in the velocity template is not possible to instanciate an object.


ptype2CTString

public java.lang.String ptype2CTString(PType pt)
                                throws PExceptionTyping
This generation helper method retrieves the string corresponding to the codding type (short value) associated to a PType.

PExceptionTyping

ptype2String

public java.lang.String ptype2String(PType pt)
                              throws PExceptionTyping
This generation helper method retrieves the string corresponding to the instance of the PType.

PExceptionTyping

getGenclass

public java.lang.String getGenclass(int level)
This method is a generation helper. It returns a string like the following regular expression: (".getGenClassMapping()")* where the number of repetition of the string is equals to the level parameter.


getIndexNumber

public int getIndexNumber(GenClass gc)
This method calculates the number of indexes in a GenClass. This method should be moved into the meta object GenClass.


getLastElement

public TypedElement getLastElement(GenClassRef gcr)

getGenClassNames

public java.util.ArrayList getGenClassNames(GenClassRef gcr)