org.objectweb.jorm.comp.generator.lib
Class MappingGenerator

java.lang.Object
  |
  +--org.objectweb.jorm.comp.generator.lib.ObjectGenerator
        |
        +--org.objectweb.jorm.comp.generator.lib.MappingGenerator
All Implemented Interfaces:
Generator, Loggable

public class MappingGenerator
extends ObjectGenerator

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.


Fields inherited from class org.objectweb.jorm.comp.generator.lib.ObjectGenerator
logger, loggerFactory, TEMPLATE_DIR
 
Constructor Summary
MappingGenerator(MOP _bmop)
          This constrcutor permits to specify which MappingMOP must be used
 
Method Summary
 void generate(MetaObject pod, org.objectweb.util.io.api.TargetHolder holder, CompilerParameter cp)
          This method generates a XXXPMapping file corresponding to the pod parameter in the directory parameter
 java.lang.String getFQName(Class c)
          It retrieves the fully qualified class name of a Class meta object.
 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 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.
 void setMappingMOP(MOP _bmop)
          This sette method permits to specify which MappingMOP must be used
 
Methods inherited from class org.objectweb.jorm.comp.generator.lib.ObjectGenerator
getLogger, getLoggerFactory, initVelocity, setLogger, setLoggerFactory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MappingGenerator

public MappingGenerator(MOP _bmop)
                 throws java.lang.Exception
This constrcutor permits to specify which MappingMOP must be used
Method Detail

setMappingMOP

public void setMappingMOP(MOP _bmop)
This sette method permits to specify which MappingMOP must be used

generate

public void generate(MetaObject pod,
                     org.objectweb.util.io.api.TargetHolder holder,
                     CompilerParameter cp)
              throws java.lang.Exception
This method generates a XXXPMapping file corresponding to the pod parameter in the directory parameter
Overrides:
generate in class ObjectGenerator
Parameters:
pod - the meta object interface
holder - The target holder which allows to create files
cp - This parameter permits to reach the compilation parameters

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.

ptype2String

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

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.

getFQName

public java.lang.String getFQName(Class c)
It retrieves the fully qualified class name of a Class meta object.

getLastElement

public TypedElement getLastElement(GenClassRef gcr)

getGenClassNames

public java.util.ArrayList getGenClassNames(GenClassRef gcr)