org.objectweb.speedo.generation.jorm
Class JormMIBuilder

java.lang.Object
  extended byorg.objectweb.speedo.generation.jorm.JormMIBuilder
All Implemented Interfaces:
MIBuilderHelper

public class JormMIBuilder
extends java.lang.Object
implements MIBuilderHelper

This class is a builder of jorm meta information. Its entries are the folowing:

Author:
S.Chassande-Barrioz

Field Summary
static java.lang.String DEFAULT_RDB_BUILDER
           
static java.lang.String GENCLASS_ELM_PREFIX
          is the prefix of the fields used for the element of a generic class
static java.lang.String GENCLASS_ID_PREFIX
          is the prefix of the fields used to identify a generic class
static java.lang.String LIST_INDEX
          is the name of the index field in the list (Genclass).
static java.lang.String MAP_INDEX
           
 
Constructor Summary
JormMIBuilder()
          Builds a JormMIBuilder without a jorm meta information manager and a logger.
JormMIBuilder(org.objectweb.jorm.metainfo.api.Manager manager, org.objectweb.util.monolog.api.Logger logger)
          Builds a JormMIBuilder with a jorm meta information manager and a logger
JormMIBuilder(org.objectweb.jorm.metainfo.api.Manager manager, NamingManagerFactory nmf, org.objectweb.util.monolog.api.Logger logger)
          Builds a JormMIBuilder with a jorm meta information manager and a logger
 
Method Summary
 java.util.Collection createMI(java.util.List scs)
          Creates the jorm meta information for a set of persistent classes.
 java.util.Collection createMI(java.util.List scs, java.lang.String projectName, java.lang.String mapperName)
          Creates the jorm meta information for a set of persistent classes.
 java.util.Collection createMI(java.util.List scs, java.lang.String projectName, java.lang.String mapperName, JormMIMappingBuilder mb)
          Creates the jorm meta information for a set of persistent classes.
 org.objectweb.jorm.metainfo.api.ScalarField createNameDefField(org.objectweb.jorm.metainfo.api.MetaObject mo, java.lang.String fn, org.objectweb.jorm.type.api.PType type)
          It creates a field of a name def.
 org.objectweb.jorm.metainfo.api.ScalarField createNameDefField(org.objectweb.jorm.metainfo.api.MetaObject mo, java.lang.String fn, org.objectweb.jorm.type.api.PType type, int size, int scale)
          It creates a field of a name def.
 java.lang.String getErrorMessage(SpeedoClass sc, org.objectweb.jorm.metainfo.api.MetaObject mo, org.objectweb.jorm.metainfo.api.Reference ref)
          retrieves the start of a pretty error message.
 org.objectweb.util.monolog.api.Logger getLogger()
           
 org.objectweb.jorm.metainfo.api.Manager getManager()
          retrieves the jorm meta information manager hosting the Class and CompositeName instances.
 java.lang.String getNameDefFieldPrefix(org.objectweb.jorm.metainfo.api.Reference ref, boolean isIdentifier, boolean isInGenClass)
          Calculates the prefix of a field use in a name def.
 org.objectweb.jorm.metainfo.api.PrimitiveElement getPrimitiveField(org.objectweb.jorm.metainfo.api.MetaObject mo, java.lang.String name)
           
 org.objectweb.jorm.type.api.PType getPrimitivePType(org.objectweb.asm.Type t)
          Retrieves the jorm type matching to primitive type.
 void setLogger(org.objectweb.util.monolog.api.Logger logger)
           
 void setManager(org.objectweb.jorm.metainfo.api.Manager manager)
          retrieves the jorm meta information manager hosting the Class and CompositeName instances.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GENCLASS_ID_PREFIX

public static final java.lang.String GENCLASS_ID_PREFIX
is the prefix of the fields used to identify a generic class

See Also:
Constant Field Values

GENCLASS_ELM_PREFIX

public static final java.lang.String GENCLASS_ELM_PREFIX
is the prefix of the fields used for the element of a generic class

See Also:
Constant Field Values

DEFAULT_RDB_BUILDER

public static final java.lang.String DEFAULT_RDB_BUILDER
See Also:
Constant Field Values

LIST_INDEX

public static final java.lang.String LIST_INDEX
is the name of the index field in the list (Genclass).

See Also:
Constant Field Values

MAP_INDEX

public static final java.lang.String MAP_INDEX
See Also:
Constant Field Values
Constructor Detail

JormMIBuilder

public JormMIBuilder()
Builds a JormMIBuilder without a jorm meta information manager and a logger.


JormMIBuilder

public JormMIBuilder(org.objectweb.jorm.metainfo.api.Manager manager,
                     org.objectweb.util.monolog.api.Logger logger)
Builds a JormMIBuilder with a jorm meta information manager and a logger

Parameters:
manager -

JormMIBuilder

public JormMIBuilder(org.objectweb.jorm.metainfo.api.Manager manager,
                     NamingManagerFactory nmf,
                     org.objectweb.util.monolog.api.Logger logger)
Builds a JormMIBuilder with a jorm meta information manager and a logger

Parameters:
manager -
Method Detail

getManager

public org.objectweb.jorm.metainfo.api.Manager getManager()
retrieves the jorm meta information manager hosting the Class and CompositeName instances.


setManager

public void setManager(org.objectweb.jorm.metainfo.api.Manager manager)
retrieves the jorm meta information manager hosting the Class and CompositeName instances.


getLogger

public org.objectweb.util.monolog.api.Logger getLogger()

setLogger

public void setLogger(org.objectweb.util.monolog.api.Logger logger)

createMI

public java.util.Collection createMI(java.util.List scs)
                              throws SpeedoException,
                                     org.objectweb.jorm.api.PException
Creates the jorm meta information for a set of persistent classes. Only the generic part will be created.

Parameters:
scs - is a list of SpeedoClass instances.
Returns:
a Collection of jorm meta object composed by Class instances and CompositeName instances.
Throws:
SpeedoException
org.objectweb.jorm.api.PException

createMI

public java.util.Collection createMI(java.util.List scs,
                                     java.lang.String projectName,
                                     java.lang.String mapperName)
                              throws SpeedoException,
                                     org.objectweb.jorm.api.PException
Creates the jorm meta information for a set of persistent classes.

Parameters:
scs - is a list of SpeedoClass instances.
projectName - is the project name for which the mapping must be defined. If the value is null no mapping will be generated.
mapperName - is the mapper name for which the mapping must be defined. If the value is null no mapping will be generated.
Returns:
a Collection of jorm meta object composed by Class instances and CompositeName instances.
Throws:
SpeedoException
org.objectweb.jorm.api.PException

createMI

public java.util.Collection createMI(java.util.List scs,
                                     java.lang.String projectName,
                                     java.lang.String mapperName,
                                     JormMIMappingBuilder mb)
                              throws SpeedoException,
                                     org.objectweb.jorm.api.PException
Creates the jorm meta information for a set of persistent classes.

Parameters:
scs - is a list of SpeedoClass instances.
projectName - is the project name for which the mapping must be defined
mapperName - is the mapper name for which the mapping must be defined
mb - is the build of the mapping part of the meta information
Returns:
a Collection of jorm meta object composed by Class instances and CompositeName instances.
Throws:
SpeedoException
org.objectweb.jorm.api.PException

getNameDefFieldPrefix

public java.lang.String getNameDefFieldPrefix(org.objectweb.jorm.metainfo.api.Reference ref,
                                              boolean isIdentifier,
                                              boolean isInGenClass)
Calculates the prefix of a field use in a name def.

Specified by:
getNameDefFieldPrefix in interface MIBuilderHelper
Parameters:
ref - is the meta object of the reference if the namedef is used for a reference.
isIdentifier - indicates if the namedef is used for an identifier (true) or if the namedef is used for a reference (false).
isInGenClass - indicates if the namedef is used in a Generic class (true) or if the namedef is used in a class (false).
Returns:
a string value (never null) representing the prefix of a name def field.

createNameDefField

public org.objectweb.jorm.metainfo.api.ScalarField createNameDefField(org.objectweb.jorm.metainfo.api.MetaObject mo,
                                                                      java.lang.String fn,
                                                                      org.objectweb.jorm.type.api.PType type,
                                                                      int size,
                                                                      int scale)
                                                               throws SpeedoException
It creates a field of a name def. This field will be hidden

Specified by:
createNameDefField in interface MIBuilderHelper
Parameters:
mo - is the jorm meta object hosting the field to create
fn - is the name of the field to create
type - is the type of the field to create
size - is the size of the field to create
Returns:
the jorm meta object representing the namedef field
Throws:
SpeedoException

createNameDefField

public org.objectweb.jorm.metainfo.api.ScalarField createNameDefField(org.objectweb.jorm.metainfo.api.MetaObject mo,
                                                                      java.lang.String fn,
                                                                      org.objectweb.jorm.type.api.PType type)
                                                               throws SpeedoException
It creates a field of a name def. This field will be hidden

Specified by:
createNameDefField in interface MIBuilderHelper
Parameters:
mo - is the jorm meta object hosting the field to create
fn - is the name of the field to create
type - is the type of the field to create
Returns:
the jorm meta object representing the namedef field
Throws:
SpeedoException

getPrimitivePType

public org.objectweb.jorm.type.api.PType getPrimitivePType(org.objectweb.asm.Type t)
Retrieves the jorm type matching to primitive type. It converts a Type defined in ASM into a PType defined in Jorm. If the type is not a jorm primitive type then a null value is returned.

Specified by:
getPrimitivePType in interface MIBuilderHelper

getErrorMessage

public java.lang.String getErrorMessage(SpeedoClass sc,
                                        org.objectweb.jorm.metainfo.api.MetaObject mo,
                                        org.objectweb.jorm.metainfo.api.Reference ref)
retrieves the start of a pretty error message.

Specified by:
getErrorMessage in interface MIBuilderHelper

getPrimitiveField

public org.objectweb.jorm.metainfo.api.PrimitiveElement getPrimitiveField(org.objectweb.jorm.metainfo.api.MetaObject mo,
                                                                          java.lang.String name)
Specified by:
getPrimitiveField in interface MIBuilderHelper