org.objectweb.jorm.api

Interface PClassMapping

public interface PClassMapping

The PClassMapping interface defines the behaviour of objects that contain all information required to map a JORM class. It is a PBinder but mainly delegates this behaviour to a nested PBinder that it must reference. It allows the creation or deletion of the persistent structures required to map this class within a particular hosting data store. It also holds references to naming contexts associated to reference fields, as well as to PClassMapping associated to generic class instances of relevant fields.

Author:
P. Dechamboux

Nested Class Summary

static interface
PClassMapping.ReferenceConfigurator

Field Summary

static byte
CLEANUP_DONOTHING
It tells that a cleanup is required for a JORM class with nothing to do on existing data or hosting structures.
static byte
CLEANUP_REMOVEALL
It tells that a cleanup is required for a JORM class with the removal of existing data as well as hosting structures.
static byte
CLEANUP_REMOVEDATA
It tells that a cleanup is required for a JORM class with the removal of only existing data.
static byte
CREATE_STRUCTURE_IF_NEEDED
It permits to specify to create the if it does not already exist.

Method Summary

void
configureRefFields(PClassMapping.ReferenceConfigurator rc)
It permits to assign the PNameCoder of all the reference fields of the persitent class.
PBinding
createPBinding()
It creates a new PBinding.
String
getClassName()
It retrieves the name of the class referenced by this PClassMapping.
PNameCoder
getClassPNameCoder()
It returns the PNameCoder to use for the class.
PClassMapping
getGenClassMapping()
It gives access to the PClassMapping associated to the element of a generic class whose type is a generic class.
PClassMapping
getGenClassMapping(String fn)
It gives access to the PClassMapping associated to a field whose type is a generic class.
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(String fn)
It returns the naming context that manages the reference associated to a field whose type is a JORM class.
Iterator
getPNameIterator(Object conn)
Deprecated. use getPNameIterator(Object, boolean, boolean)
PNameIterator
getPNameIterator(Object conn, boolean withSubType, boolean prefetching, Object txctx)
It returns an iterator over all pname of persitent objects availlable in this class.
PType
getPType()
Retrieves the PType of this mapped JORM class.
String
getProjectName()
It retrieves the project name.
void
init(PMappingCallback mapper, MetaObject metaclass)
It intialises the class mapping.
boolean
isConform(String mappername)
It specifies if the given kind of PMapper is supported by this PClassMapping.
void
setPBinder(PBinder pb)
It assigns the PBinder associated to this PClassMapping.

Field Details

CLEANUP_DONOTHING

public static final byte CLEANUP_DONOTHING
It tells that a cleanup is required for a JORM class with nothing to do on existing data or hosting structures.

Field Value:
4


CLEANUP_REMOVEALL

public static final byte CLEANUP_REMOVEALL
It tells that a cleanup is required for a JORM class with the removal of existing data as well as hosting structures.

Field Value:
1


CLEANUP_REMOVEDATA

public static final byte CLEANUP_REMOVEDATA
It tells that a cleanup is required for a JORM class with the removal of only existing data.

Field Value:
2


CREATE_STRUCTURE_IF_NEEDED

public static final byte CREATE_STRUCTURE_IF_NEEDED
It permits to specify to create the if it does not already exist. If the table exist then nothing is done.

Field Value:
3

Method Details

configureRefFields

public void configureRefFields(PClassMapping.ReferenceConfigurator rc)
            throws PException,
                   UnsupportedOperationException
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).

Parameters:
rc - is the callback object which knows the PNameCoder to use.


createPBinding

public PBinding createPBinding()
            throws PException
It creates a new PBinding.

Returns:
The new PBinding with lifecycle state set to LIFECYCLE_NOTBOUND.


getClassName

public String getClassName()
It retrieves the name of the class referenced by this PClassMapping. should be the same as the one get when calling "getPBinder().getPType().getJormName()" if the PType exists, that is a fully qualified name.

Returns:
The name of this class.


getClassPNameCoder

public PNameCoder getClassPNameCoder()
It returns the PNameCoder to use for the class. This PNamingContext manages also the sub classes.


getGenClassMapping

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

Returns:
The PClassMapping of the generic class instance.


getGenClassMapping

public PClassMapping getGenClassMapping(String fn)
            throws UnsupportedOperationException
It gives access to the PClassMapping associated to a field whose type is a generic class.

Parameters:
fn - The name of the generic class field.

Returns:
The PClassMapping of the generic class instance.


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.

Returns:
The Class/GenClass meta-object or null.

See Also:
org.objectweb.jorm.api.PMapper.map


getPBinder

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

Returns:
The PBinder associated to this PClassMapping.


getPMapper

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

Returns:
The associated PMapper.


getPNameCoder

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

Returns:
The naming context that manages references contained by a generic class instance.


getPNameCoder

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

Returns:
The naming context that manages the reference defined by a field.


getPNameIterator

public Iterator getPNameIterator(Object conn)
            throws PException

Deprecated. use getPNameIterator(Object, boolean, boolean)


getPNameIterator

public PNameIterator getPNameIterator(Object conn,
                                      boolean withSubType,
                                      boolean prefetching,
                                      Object txctx)
            throws PException
It returns an iterator over all pname of persitent objects availlable in this class. When you use the returned iterator you must leave the connection opened.

Parameters:
conn - is the connection which permits to access to the support
withSubType - indicates if the subclass instances must be included into the iterator
prefetching - indicates if prefething must be activated during the query on the persistent support.
txctx - The transaction context that can be used in case of prefetching.

Returns:
the iterator over PName objects


getPType

public PType getPType()
Retrieves the PType of this mapped JORM class.

Returns:
The PTYpe.


getProjectName

public String getProjectName()
It retrieves the project name.


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. It also defines all type information related to this class mapping.

Parameters:
mapper - The mapper to be assigned to this class mapping.
metaclass - The meta-object describing the associated class. It may be null.


isConform

public boolean isConform(String mappername)
It specifies if the given kind of PMapper is supported by this PClassMapping.

Parameters:
mappername - The name defining the PMapper kind.

Returns:
true if this kind of mapper is supported.


setPBinder

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

Parameters:
pb - The PBinder associated to this PClassMapping.