org.castor.ddlgen
Class MappingHelper
java.lang.Object
org.castor.ddlgen.MappingHelper
public final class MappingHelper
extends java.lang.Object
This class handles all common tasks for manipulating Mapping document.
$Revision: 5951 $ $Date: 2006-04-25 16:09:10 -0600 (Tue, 25 Apr 2006) $
getClassMappingByName
public ClassMapping getClassMappingByName(String name)
Return the ClassMapping which associated with parameter name.
name
- Name of class to get ClassMapping of.
- ClassMapping of the named class or
null
if no such
ClassMapping was found.
getClassMappingIdentity
public String[] getClassMappingIdentity(ClassMapping cm)
The identity definitions at class and field are alternative syntax. If
both are specified the one at field should take precedence over the class
one. In other words if both are specified the one at class will be
ignored.
cm
- ClassMapping to get identity names of.
- Array of identity names of given ClassMapping.
getClassMappingSqlIdentity
public String[] getClassMappingSqlIdentity(ClassMapping cm,
boolean ext)
The identity definitions at class and field are alternative syntax. If
both are specified the one at field should take precedence over the class
one. In other words if both are specified the one at class will be
ignored.
cm
- ClassMapping to get sql names of identities of.ext
- Recursivly search for identities in extended ClassMappings.
- Array of sql names of identities of given ClassMapping.
getMapping
public Mapping getMapping()
Get mapping document.
getTypeMapper
public TypeMapper getTypeMapper()
Get type mapper.
isIdentity
public boolean isIdentity(ClassMapping cm,
FieldMapping fm)
Check if given FieldMapping is an identity at given ClassMapping.
<class name="myapp.ProductGroup" identity="id">
<field name="id" type="integer" >
<sql name="id1 id2" type="integer"/>
</field>
</class>
cm
- ClassMapping.fm
- FieldMapping.
true
if FieldMapping is an identity at ClassMapping.
isUseFieldIdentity
public boolean isUseFieldIdentity(ClassMapping cm)
Check if identities of given ClassMapping are defined at its FieldMappings.
cm
- ClassMapping to check for identity definitions at FieldMapping.
true
if identities are defined at fieldMapping.
resolveTypeReferenceForIds
public String[] resolveTypeReferenceForIds(String className)
throws GeneratorException
Collect sql type of all identities for class with given name. It also takes care
on multiple column identities and extended classes.
<mapping>
<class name="myapp.OtherProductGroup" >
<map-to table="other_prod_group" xml="group" />
<field name="id" type="integer" identity="true">
<sql name="id" type="integer"/>
</field>
</class>
<class name="myapp.ProductGroup" identity="id">
<map-to table="prod_group" xml="group" />
<field name="id" type="myapp.OtherProductGroup" >
<sql name="prod_id" />
</field>
</class>
<class name="myapp.Product" identity="id">
<field name="group" type="myapp.ProductGroup">
<sql name="group_id" />
</field>
</class>
</mapping>
className
- Name of class to get type of identities of.
- Array of sql types of all identities.
resolveTypeReferenceForIds
public String[] resolveTypeReferenceForIds(ClassMapping cm)
throws GeneratorException
Collect sql type of all identities for a ClassMapping. It also takes care on
multiple column identities and extended classes.
cm
- ClassMapping to get type of identities of.
- Array of sql types of all identities.
setMapping
public void setMapping(Mapping mapping)
set mapping document.
mapping
- Mapping document.
setTypeMapper
public void setTypeMapper(TypeMapper typeMapper)
Set type mapper.
typeMapper
- Type mapper.
Intalio Inc. (C) 1999-2008. All rights reserved http://www.intalio.com