org.objectweb.jorm.genclass.lib
Class GenClassMapping

java.lang.Object
  extended byorg.objectweb.jorm.genclass.lib.GenClassMapping
All Implemented Interfaces:
GenClassProp, Loggable, PClassMapping, PClassMappingCtrl
Direct Known Subclasses:
FosGenClassMapping, RdbGenClassMapping

public abstract class GenClassMapping
extends java.lang.Object
implements PClassMapping, PClassMappingCtrl, GenClassProp, Loggable

This abstract class provides all the generic code for the PClassMapping associated with JORM generic classes. It implements all methods except the following ones: createPBinding, and isConform.

Author:
P. Dechamboux

Nested Class Summary
 
Nested classes inherited from class org.objectweb.jorm.api.PClassMapping
PClassMapping.ReferenceConfigurator
 
Field Summary
protected  PBinder binder
          The actual PBinder.
protected  PNameCoder classPNC
           
protected  PClassMapping elemClassMapping
          The PClassMapping of the generic class instance representing the element stored within this generic class object.
protected  FieldDesc[] elemFields
          This array contains the ScalarField meta object elements which represent the element fields of the generic class instance.
protected  PNameCoder elemNameCoder
          The naming context associated to the reference elements of this generic class instance.
protected  GenClass genClassMetaInfo
          It references the meta-information associated with this generic class.
protected  PType genClassPType
          This field is the PType of the involved generic class.
protected  FieldDesc[] identifierFields
          This array contains the ScalarField meta object elements which represent the identifier fields of the generic class instance.
protected  FieldDesc[] indexFields
          This array contains the ScalarField meta object elements which represent the index fields of the generic class instance.
protected  java.lang.String jormClassName
          Fully quailied name of the persitent class
protected  Logger logger
          The logger to log all information related to the mapping of this class.
protected  LoggerFactory loggerFactory
          The loggerFactory.
protected  PMappingCallback mapper
          This field references the mapper.
protected  java.lang.String projectName
           
 
Fields inherited from interface org.objectweb.jorm.api.PClassMapping
CLEANUP_DONOTHING, CLEANUP_REMOVEALL, CLEANUP_REMOVEDATA, CREATE_STRUCTURE_IF_NEEDED
 
Constructor Summary
GenClassMapping()
           
 
Method Summary
 void configureRefFields(PClassMapping.ReferenceConfigurator rc)
          It permits to assign the PNameCoder of all the reference fields of the persitent class.
 java.lang.String getClassName()
          It retrieves the name of the class mapped by this PClassMapping.
 PNameCoder getClassPNameCoder()
          It returns the PNameCoder to use for the class.
 FieldDesc[] getElemFields()
           
 PClassMapping getGenClassMapping()
          It gives access to the PClassMapping associated to the element of a generic class whose type is a generic class.
 PClassMapping getGenClassMapping(java.lang.String fn)
          It gives access to the PClassMapping associated to a field whose type is a generic class.
 FieldDesc[] getIdentifierFields()
           
 FieldDesc[] getIndexFields()
           
 Logger getLogger()
          Returns a logger to an component that wants to log things.
 LoggerFactory getLoggerFactory()
          Returns a logger factory that allows the creation of new loggers.
 MetaObject getMetaInfo()
          It returns the Class/GenClass object representing the meta-information associated to the JORM class/generic class whose mapping is defined by this PClassMapping.
 PBinder getPBinder()
          It yields the PBinder associated to this PClassMapping.
 PMapper getPMapper()
          It gives access to the mapper that has mapped the associated JORM class as defined by this PClassMapping.
 PNameCoder getPNameCoder()
          It returns the naming context that manages the references contained by the generic class instance whose mapping is defined by this PClassMapping.
 PNameCoder getPNameCoder(java.lang.String fn)
          It returns the naming context that manages the reference associated to a field whose type is a JORM class.
 java.util.Iterator getPNameIterator(java.lang.Object conn)
           
 java.lang.String getProjectName()
          It retrieves the project name.
 PType getPType()
          Retrieves the PType associated to the JORM class which is the type of the name managed by this naming context.
 void init(PMappingCallback mapper, MetaObject metaclass)
          It intialises the class mapping.
 void read(PBinding pb, java.lang.Object conn, PAccessor pa, java.lang.Object txctx)
          It reads the data store instance designated by the PName of a binding and transfers each attribute value to the accessor object.
 void read(PBinding pb, java.lang.Object conn, PAccessor pa, java.lang.Object txctx, boolean forUpdate)
           
 void setClassPNameCoder(PNameCoder pnc)
          It assigns the PNameCoder to use for the class.
 void setElemDesc(FieldDesc[] fds)
          Defines the fields property specifying the fields composing the element value structure of a generic class instance elements.
 void setGenClassMapping(PClassMapping pcm)
          It assigns the GenClassMapping used to manage the reference hold by a field whose type is a JORM gen class.
 void setGenClassMapping(java.lang.String fn, PClassMapping pcm)
          It assigns the GenClassMapping used to manage the reference hold by a field whose type is a JORM class.
 void setIdentifierDesc(FieldDesc[] fds)
          Defines the fields property specifying the fields composing the identifier structure of a generic class instance.
 void setIndexDesc(FieldDesc[] fds)
          Defines the fields property specifying the fields composing the index structure of a generic class instance elements.
 void setLogger(Logger logger)
          It assigns a logger to an component that wants to log things.
 void setLoggerFactory(LoggerFactory lf)
          It assigns a logger factory that allows the creation of new loggers.
 void setPBinder(PBinder pb)
          It assigns the PBinder associated to this PClassMapping.
 void setPNameCoder(PNameCoder pnc)
          It assigns the PNameCoder used to manage the references hold by a generic class instance whose mapping is described by this PClassMapping.
 void setPNameCoder(java.lang.String fn, PNameCoder pnc)
          It assigns the PNameCoder used to manage the reference hold by a field whose type is a JORM class.
 void setProjectName(java.lang.String projectName)
          Assignes the project name to a PClassMapping.
 void setPType(PType pt)
          It assigns the PType associated to the JORM class which is the type of the reference managed by this naming context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.objectweb.jorm.api.PClassMapping
addAssociation, classDefined, createPBinding, exist, getAssociationTable, getDecodedPName, getIndexesTable, getPNameIterator, getSubPCMs, init, isConform, match, read, resolve, write
 

Field Detail

mapper

protected PMappingCallback mapper
This field references the mapper. The mapper is used to know the mapper name and the mapping name.


genClassMetaInfo

protected GenClass genClassMetaInfo
It references the meta-information associated with this generic class.


genClassPType

protected PType genClassPType
This field is the PType of the involved generic class.


jormClassName

protected java.lang.String jormClassName
Fully quailied name of the persitent class


indexFields

protected FieldDesc[] indexFields
This array contains the ScalarField meta object elements which represent the index fields of the generic class instance.


identifierFields

protected FieldDesc[] identifierFields
This array contains the ScalarField meta object elements which represent the identifier fields of the generic class instance.


elemFields

protected FieldDesc[] elemFields
This array contains the ScalarField meta object elements which represent the element fields of the generic class instance. If it is a reference, there must be at least two fields: one describing the reference field, and one describing its structural projection. This structural projection may be a composite name in which case it should describes all the fields of this composite name.


binder

protected PBinder binder
The actual PBinder.


classPNC

protected PNameCoder classPNC

elemClassMapping

protected PClassMapping elemClassMapping
The PClassMapping of the generic class instance representing the element stored within this generic class object. This is valid only if the elements of this generic class object are also generic class objects.


elemNameCoder

protected PNameCoder elemNameCoder
The naming context associated to the reference elements of this generic class instance.


projectName

protected java.lang.String projectName

logger

protected Logger logger
The logger to log all information related to the mapping of this class.


loggerFactory

protected LoggerFactory loggerFactory
The loggerFactory.

Constructor Detail

GenClassMapping

public GenClassMapping()
Method Detail

getElemFields

public FieldDesc[] getElemFields()

getIdentifierFields

public FieldDesc[] getIdentifierFields()

getIndexFields

public FieldDesc[] getIndexFields()

getProjectName

public java.lang.String getProjectName()
Description copied from interface: PClassMapping
It retrieves the project name.

Specified by:
getProjectName in interface PClassMapping

setProjectName

public void setProjectName(java.lang.String projectName)
Description copied from interface: PClassMappingCtrl
Assignes the project name to a PClassMapping.

Specified by:
setProjectName in interface PClassMappingCtrl
Parameters:
projectName - to be assigned

getClassName

public java.lang.String getClassName()
It retrieves the name of the class mapped by this PClassMapping. It should be the same as the one get when calling "getPType().getJormName()" if the PType exists.

Specified by:
getClassName in interface PClassMapping
Returns:
The name of this class.

getGenClassMapping

public PClassMapping getGenClassMapping()
It gives access to the PClassMapping associated to the element of a generic class whose type is a generic class.

Specified by:
getGenClassMapping in interface PClassMapping
Returns:
The PClassMapping of the generic class instance.

getGenClassMapping

public PClassMapping getGenClassMapping(java.lang.String fn)
It gives access to the PClassMapping associated to a field whose type is a generic class. It has no meaning within this context.

Specified by:
getGenClassMapping in interface PClassMapping
Parameters:
fn - The name of the generic class field.
Returns:
The PClassMapping of the generic class instance: always null here.

getMetaInfo

public MetaObject getMetaInfo()
It returns the Class/GenClass object representing the meta-information associated to the JORM class/generic class whose mapping is defined by this PClassMapping. It may be null if not requested at mapping time.

Specified by:
getMetaInfo in interface PClassMapping
Returns:
The Class/GenClass meta-object or null.
See Also:
PMapper.map(org.objectweb.jorm.api.PClassMapping)

getPBinder

public PBinder getPBinder()
It yields the PBinder associated to this PClassMapping. As a PBinder itself, this PClassMapping delegates this behaviour to this PBinder.

Specified by:
getPBinder in interface PClassMapping
Returns:
The PBinder associated to this PClassMapping.

getClassPNameCoder

public PNameCoder getClassPNameCoder()
Description copied from interface: PClassMapping
It returns the PNameCoder to use for the class. This PNamingContext manages also the sub classes.

Specified by:
getClassPNameCoder in interface PClassMapping

getPMapper

public PMapper getPMapper()
It gives access to the mapper that has mapped the associated JORM class as defined by this PClassMapping.

Specified by:
getPMapper in interface PClassMapping
Returns:
The associated PMapper.

getPNameCoder

public PNameCoder getPNameCoder()
                         throws java.lang.UnsupportedOperationException
It returns the naming context that manages the references contained by the generic class instance whose mapping is defined by this PClassMapping.

Specified by:
getPNameCoder in interface PClassMapping
Returns:
The naming context that manages references contained by a generic class instance.
Throws:
java.lang.UnsupportedOperationException - It is raised when this PClassMapping does not map a generic class instance, or when the elements of this generic class instance are not references.

getPNameCoder

public PNameCoder getPNameCoder(java.lang.String fn)
                         throws java.lang.UnsupportedOperationException
It returns the naming context that manages the reference associated to a field whose type is a JORM class.

Specified by:
getPNameCoder in interface PClassMapping
Returns:
The naming context that manages the reference defined by a field.
Throws:
java.lang.UnsupportedOperationException - It is raised when no naming context is associated to the corresponding field.

init

public void init(PMappingCallback mapper,
                 MetaObject metaclass)
          throws PException
It intialises the class mapping. It especially assigns a mapper as well as a meta-object describing either a class or a generic class.

Specified by:
init in interface PClassMapping
Parameters:
mapper - The mapper to be assigned to this class mapping.
metaclass - The meta-object describing the associated class. It may be null.
Throws:
PException

getPNameIterator

public java.util.Iterator getPNameIterator(java.lang.Object conn)
                                    throws PException
Specified by:
getPNameIterator in interface PClassMapping
Throws:
PException

setPBinder

public void setPBinder(PBinder pb)
                throws PExceptionTyping
It assigns the PBinder associated to this PClassMapping. As a PBinder itself, this PClassMapping delegates this behaviour to this PBinder.

Specified by:
setPBinder in interface PClassMapping
Parameters:
pb - The PBinder associated to this PClassMapping.
Throws:
PExceptionTyping - It is raised when the structure of the the name that identifies the DSI for the PClassMapping is not supported by this PBinder that should be connected to this PClassMapping.

setClassPNameCoder

public void setClassPNameCoder(PNameCoder pnc)
                        throws PException
Description copied from interface: PClassMappingCtrl
It assigns the PNameCoder to use for the class. This PNamingContext manages also the sub classes.

Specified by:
setClassPNameCoder in interface PClassMappingCtrl
Throws:
PException

configureRefFields

public void configureRefFields(PClassMapping.ReferenceConfigurator rc)
                        throws PException,
                               java.lang.UnsupportedOperationException
Description copied from interface: PClassMapping
It permits to assign the PNameCoder of all the reference fields of the persitent class. The implementation of this method must call both method 'getPNameCoder' and 'isCodingOnly' of the specified PNCGetter. for each field which is a reference (to a class or a GenClass).

Specified by:
configureRefFields in interface PClassMapping
Parameters:
rc - is the callback object which knows the PNameCoder to use.
Throws:
PException
java.lang.UnsupportedOperationException

setPNameCoder

public void setPNameCoder(PNameCoder pnc)
                   throws PException,
                          java.lang.UnsupportedOperationException
It assigns the PNameCoder used to manage the references hold by a generic class instance whose mapping is described by this PClassMapping. It should verify that the name structure for this reference is supported by the corresponding naming context.

Specified by:
setPNameCoder in interface PClassMappingCtrl
Parameters:
pnc - The PNameCoder to be associated to this generic class PClassMapping for managing its reference elements.
Throws:
PExceptionTyping - It is raised when the structure of the the names that reference the DSI stored within the generic class instance is not supported by this naming context.
java.lang.UnsupportedOperationException - It is raised when this PClassMapping does not map a generic class instance, or when the elements of this generic class instance are not references.
PException

setPNameCoder

public void setPNameCoder(java.lang.String fn,
                          PNameCoder pnc)
                   throws PException,
                          java.lang.UnsupportedOperationException
It assigns the PNameCoder used to manage the reference hold by a field whose type is a JORM class. It should verify that the name structure for this reference is supported by the corresponding naming context.

Specified by:
setPNameCoder in interface PClassMappingCtrl
Parameters:
fn - The name of the involved field.
pnc - The PNameCoder to be associated to this field for managing the reference it may hold.
Throws:
PExceptionTyping - It is raised when the structure of the the names that reference the DSI stored within the generic class instance is not supported by this naming context.
java.lang.UnsupportedOperationException - It is raised when no naming context is associated to the corresponding field.
PException

setGenClassMapping

public void setGenClassMapping(PClassMapping pcm)
                        throws java.lang.UnsupportedOperationException
It assigns the GenClassMapping used to manage the reference hold by a field whose type is a JORM gen class.

Specified by:
setGenClassMapping in interface PClassMappingCtrl
Throws:
java.lang.UnsupportedOperationException

setGenClassMapping

public void setGenClassMapping(java.lang.String fn,
                               PClassMapping pcm)
                        throws java.lang.UnsupportedOperationException
It assigns the GenClassMapping used to manage the reference hold by a field whose type is a JORM class.

Specified by:
setGenClassMapping in interface PClassMappingCtrl
Throws:
java.lang.UnsupportedOperationException

getPType

public PType getPType()
Retrieves the PType associated to the JORM class which is the type of the name managed by this naming context.

Specified by:
getPType in interface PClassMapping
Returns:
The related PType.

setPType

public void setPType(PType pt)
It assigns the PType associated to the JORM class which is the type of the reference managed by this naming context.

Specified by:
setPType in interface GenClassProp
Parameters:
pt - The PType of the JORM class reference managed by this naming context.

read

public void read(PBinding pb,
                 java.lang.Object conn,
                 PAccessor pa,
                 java.lang.Object txctx)
          throws PException
Description copied from interface: PClassMapping
It reads the data store instance designated by the PName of a binding and transfers each attribute value to the accessor object. This read method should be used when prefetching is requested.

Specified by:
read in interface PClassMapping
Parameters:
conn - The connection that can be used to refer to the DS.
pa - The PAccessor used to access memory variables.
txctx - The transaction context that can be used in case of prefetching.
Throws:
PException

read

public void read(PBinding pb,
                 java.lang.Object conn,
                 PAccessor pa,
                 java.lang.Object txctx,
                 boolean forUpdate)
          throws PException
Specified by:
read in interface PClassMapping
Throws:
PException

setIdentifierDesc

public void setIdentifierDesc(FieldDesc[] fds)
Defines the fields property specifying the fields composing the identifier structure of a generic class instance.

Specified by:
setIdentifierDesc in interface GenClassProp
Parameters:
fds - The array of descriptions of the associated fields.

setIndexDesc

public void setIndexDesc(FieldDesc[] fds)
Defines the fields property specifying the fields composing the index structure of a generic class instance elements.

Specified by:
setIndexDesc in interface GenClassProp
Parameters:
fds - The array of descriptions of the associated fields.

setElemDesc

public void setElemDesc(FieldDesc[] fds)
Defines the fields property specifying the fields composing the element value structure of a generic class instance elements.

Specified by:
setElemDesc in interface GenClassProp
Parameters:
fds - The array of descriptions of the associated fields.

setLoggerFactory

public void setLoggerFactory(LoggerFactory lf)
It assigns a logger factory that allows the creation of new loggers.

Specified by:
setLoggerFactory in interface Loggable
Parameters:
lf - The LoggerFactory object to obtain new loggers.

setLogger

public void setLogger(Logger logger)
It assigns a logger to an component that wants to log things.

Specified by:
setLogger in interface Loggable
Parameters:
logger - The logger object.

getLogger

public Logger getLogger()
Description copied from interface: Loggable
Returns a logger to an component that wants to log things.

Specified by:
getLogger in interface Loggable

getLoggerFactory

public LoggerFactory getLoggerFactory()
Description copied from interface: Loggable
Returns a logger factory that allows the creation of new loggers.

Specified by:
getLoggerFactory in interface Loggable