org.objectweb.medor.optim.jorm
Class JormRule

java.lang.Object
  extended byorg.objectweb.medor.optim.lib.BasicRule
      extended byorg.objectweb.medor.optim.jorm.JormRule
All Implemented Interfaces:
RewriteRule
Direct Known Subclasses:
Jorm2Rdb, JormFilteredInheritance, JormFlatten2Rdb, JormLeafRewriter

public abstract class JormRule
extends BasicRule

This class is a tool for the management of the JormExtent.

It is used for the replacement of JormExtent instances into specific QueryLeaf instances.

Author:
S.Chassande-Barrioz

Nested Class Summary
 
Nested classes inherited from class org.objectweb.medor.optim.lib.BasicRule
BasicRule.ModifiedExpression
 
Field Summary
 
Fields inherited from class org.objectweb.medor.optim.lib.BasicRule
debug, log
 
Constructor Summary
JormRule(java.lang.String suffix)
           
 
Method Summary
protected  ClassMapping getClassMapping(JormExtent extent)
          Retrieves the jorm meta object describing the mapping of the persistent object representing by its extent.
protected  GenClassMapping getGenClassMapping(JormExtent extent)
          Retrieves the jorm meta object describing the mapping of the persistent object representing by its extent.
protected  java.lang.String getJORMFieldName(java.lang.String fullName, JormExtent ext)
          Returns the field name without the extent name
protected  PrimitiveElementMapping getPEM(JormExtent extent, java.lang.String fieldName)
          Retrieves the RdbPrimitiveElementMapping of a field
protected  Operand getPNCOperand(JormExtent extent, PNameField pnf)
          Retrieves the Operand representing the PNameCoder needed to decode a pname.
protected  PrimitiveElement getPrimitiveElement(JormExtent extent, java.lang.String fieldname)
          Retrieves the primitive element corresponding to a field name of a jorm object (class or generic class).
 
Methods inherited from class org.objectweb.medor.optim.lib.BasicRule
replaceUsage, rewrite
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.objectweb.medor.optim.api.RewriteRule
rewrite
 

Constructor Detail

JormRule

public JormRule(java.lang.String suffix)
Method Detail

getPrimitiveElement

protected PrimitiveElement getPrimitiveElement(JormExtent extent,
                                               java.lang.String fieldname)
                                        throws MedorException
Retrieves the primitive element corresponding to a field name of a jorm object (class or generic class).

Parameters:
extent - represents the Jorm persistent class and references the Jorm meta object containing the expected jorm meta object.
fieldname - is the name of the
Throws:
MedorException - if the field does not exist.

getPEM

protected PrimitiveElementMapping getPEM(JormExtent extent,
                                         java.lang.String fieldName)
                                  throws MedorException
Retrieves the RdbPrimitiveElementMapping of a field

Parameters:
extent - the extent of a persistent class (ClassExtent or GenClassExtent)
fieldName - is the name of the field which the mapping is expected
Throws:
MedorException - if the extent is not managed or if the field does not have a mapping.

getJORMFieldName

protected java.lang.String getJORMFieldName(java.lang.String fullName,
                                            JormExtent ext)
Returns the field name without the extent name

Parameters:
fullName - the full field name containing the extent name
ext - the extent
Returns:
the abridged field name

getClassMapping

protected ClassMapping getClassMapping(JormExtent extent)
                                throws MedorException
Retrieves the jorm meta object describing the mapping of the persistent object representing by its extent. This method must be call with a ClassExtent instance. It retrieves a RdbClassMultiMapping instance. The JormExtent instance must contain the project name and the mapper instance.

Parameters:
extent - must be a ClassExtent instance.
Returns:
a RdbClassMultiMapping instance
Throws:
MedorException - if no class mapping has been found for the project name and the mapper specified by the JormExtent.

getGenClassMapping

protected GenClassMapping getGenClassMapping(JormExtent extent)
                                      throws MedorException
Retrieves the jorm meta object describing the mapping of the persistent object representing by its extent. This method must be call with a GenClassExtent instance. It retrieves a RdbGenClassMapping instance. The JormExtent instance must contain the project name and the mapper instance.

Parameters:
extent - must be a ClassExtent instance.
Returns:
a RdbGenClassMapping instance
Throws:
MedorException - if no class mapping has been found for the project name and the mapper specified by the JormExtent.

getPNCOperand

protected Operand getPNCOperand(JormExtent extent,
                                PNameField pnf)
Retrieves the Operand representing the PNameCoder needed to decode a pname. If the mapper is assigned to the extent and the persistent class is initialized then a constant operand is returned. Otherwise a ParameterOperand is returned.

Parameters:
extent - can contain the mapper
pnf - is the field representing the PName to be decoded
Returns:
a Operand instance.