org.objectweb.jorm.generator.lib
Class MappingGenerator

java.lang.Object
  extended byTypeHelper
      extended byorg.objectweb.jorm.generator.lib.CommonHelper
          extended byorg.objectweb.jorm.generator.lib.CommonJVMHelper
              extended byorg.objectweb.jorm.generator.lib.CommonGenerator
                  extended byorg.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.

See Also:
Serialized Form

Field Summary
protected  java.util.HashMap mmops
          The mapper generation specializations (some MOP objects) key = mapper name value = a MOP
 
Fields inherited from class org.objectweb.jorm.generator.lib.CommonGenerator
GEN_TEMPLATE_DIR, logger, loggerFactory, MAPPER_TEMPLATE_DIR, template, velocityEngine
 
Fields inherited from class org.objectweb.jorm.generator.lib.CommonHelper
debug, PN_GET_TYPES
 
Constructor Summary
MappingGenerator(JormCompilerConfigurator jcc, JormCompilerParameter cp)
          This constrcutor permits to specify which BindingMOP must be used
 
Method Summary
 void generate(Class clazz, TargetHolder holder, JormCompilerParameter cp, JormCompilerConfigurator jcc)
          Generates java code mapping for a jorm class.
 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.
 PType getJavaLangPrimitive(PType pt)
           
 TypedElement getLastElement(GenClassRef gcr)
           
 java.lang.String getOwner(TypedElement te, Class owner, java.lang.String ownerName)
           
 PType getPrimitive(PType pt)
           
 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 org.objectweb.jorm.generator.lib.CommonJVMHelper
any2I, getConstructorFieldsPncParam, getJVMClassName, getJVMClassName, getJVMClassName, getJVMType, getJVMType, loadNull, write, writeJavaClass
 
Methods inherited from class org.objectweb.jorm.generator.lib.CommonHelper
buildPemList, canBeNullValue, comparePE, containsCharArrayField, containsCompositeName, containsFieldWhichCanBeNull, containsGenClassRef, containsReference, containsSerializedField, debug, getCNPackageName, getCoderName, getCompositeNameDefEntries, getCompositeReferences, getCTDeclaration, getFQNOfCompositeName, getInheritedClasses, getPaGetMethod, getPaSetMethod, getPemPos, getPNameDecodeFunction, getPNameEncodeFunction, getPNameGetterGetFunction, getPNGTypes, getPrimitiveElement, getPrimitiveElement, getProjectionField, getPType, getPTypeBigDecimal, getPTypeBigInteger, getPTypeBoolean, getPTypeByte, getPTypeByteArray, getPTypeChar, getPTypeCharArray, getPTypeDate, getPTypeDouble, getPTypeFloat, getPTypeInt, getPTypeLong, getPTypeOboolean, getPTypeObyte, getPTypeOchar, getPTypeOdouble, getPTypeOfloat, getPTypeOint, getPTypeOlong, getPTypeOshort, getPTypeReference, getPTypeSerialized, getPTypeShort, getPTypeSpaceFieldName, getPTypeString, getRefNameDef, getTupleDecoding, getTupleDecoding, getTupleGetter, isCharArrayType, isClass, isClassRef, isCompositeName, isFieldName, isGenClassRef, isHiddenField, isNull, isPrimitiveElement, isReference, isSerializedField, isSerializedType, isValidString, log, not, upperFL
 
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) key = mapper name value = a MOP

Constructor Detail

MappingGenerator

public MappingGenerator(JormCompilerConfigurator 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 clazz,
                     TargetHolder holder,
                     JormCompilerParameter cp,
                     JormCompilerConfigurator jcc)
              throws PException
Generates java code mapping for a jorm class. Code in put in a file named XMapping.java whre X is the name of the class Iterates java code generation for each mapping defined for this project

Parameters:
clazz - the meta object interface
holder - The target holder which allows to create files
cp - the compilation parameters
jcc - the compiler configurator (not used at the moment)
Throws:
PException

getOwner

public java.lang.String getOwner(TypedElement te,
                                 Class owner,
                                 java.lang.String ownerName)

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.

Throws:
PExceptionTyping

getJavaLangPrimitive

public PType getJavaLangPrimitive(PType pt)

getPrimitive

public PType getPrimitive(PType pt)

ptype2String

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

Throws:
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)