|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.castor.ddlgen.MappingHelper
public final class MappingHelper
This class handles all common tasks for manipulating Mapping document.
| Constructor Summary | |
|---|---|
MappingHelper()
|
|
| Method Summary | |
|---|---|
ClassMapping |
getClassMappingByName(String name)
Return the ClassMapping which associated with parameter name. |
String[] |
getClassMappingIdentity(ClassMapping cm)
The identity definitions at class and field are alternative syntax. |
String[] |
getClassMappingSqlIdentity(ClassMapping cm,
boolean ext)
The identity definitions at class and field are alternative syntax. |
Mapping |
getMapping()
Get mapping document. |
TypeMapper |
getTypeMapper()
Get type mapper. |
boolean |
isIdentity(ClassMapping cm,
FieldMapping fm)
Check if given FieldMapping is an identity at given ClassMapping. |
boolean |
isUseFieldIdentity(ClassMapping cm)
Check if identities of given ClassMapping are defined at its FieldMappings. |
String[] |
resolveTypeReferenceForIds(ClassMapping cm)
Collect sql type of all identities for a ClassMapping. |
String[] |
resolveTypeReferenceForIds(String className)
Collect sql type of all identities for class with given name. |
void |
setMapping(Mapping mapping)
set mapping document. |
void |
setTypeMapper(TypeMapper typeMapper)
Set type mapper. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public MappingHelper()
| Method Detail |
|---|
public Mapping getMapping()
public void setMapping(Mapping mapping)
mapping - Mapping document.public TypeMapper getTypeMapper()
public void setTypeMapper(TypeMapper typeMapper)
typeMapper - Type mapper.public ClassMapping getClassMappingByName(String name)
name - Name of class to get ClassMapping of.
null if no such
ClassMapping was found.
public String[] resolveTypeReferenceForIds(String className)
throws GeneratorException
<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.
GeneratorException - If failed to resolve sql type of identities.
public String[] resolveTypeReferenceForIds(ClassMapping cm)
throws GeneratorException
cm - ClassMapping to get type of identities of.
GeneratorException - If failed to resolve sql type of identities.public boolean isUseFieldIdentity(ClassMapping cm)
cm - ClassMapping to check for identity definitions at FieldMapping.
true if identities are defined at fieldMapping.
public boolean isIdentity(ClassMapping cm,
FieldMapping fm)
<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.
public String[] getClassMappingSqlIdentity(ClassMapping cm,
boolean ext)
cm - ClassMapping to get sql names of identities of.ext - Recursivly search for identities in extended ClassMappings.
public String[] getClassMappingIdentity(ClassMapping cm)
cm - ClassMapping to get identity names of.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||