{
if (null != xtm && null != pkg && null != imports && null != parent && null != field
&& null != parentClassName && null != mapClassName && null != mapType
&& null != mapChild && null != out)
{
TemplateRenderer template = Templates.GetTemplate(xtm);
TemplateDataDictionary top = new gap.hapax.AbstractData();
DefineDescription(xtm,top);
DefinePrimitives(top);
DefineImports(top,imports);
DefineClass(pkg,parent,imports,top,TemplateNames.PrefixParent);
Class childClass = FieldClass(PackageName(pkg),mapChild.childValueClassName,imports);
switch (mapType){
case MapPrimitive:{
Primitive child = Primitive.For(mapChild.childValueClassName,childClass);
if (null != child){
DefineClass(PackageFor(child,childClass),child,ImportsFor(child,parent,imports),top,TemplateNames.PrefixChild);
top.setVariable(TemplateNames.MapClassName,mapClassName);
top.setVariable(TemplateNames.MapKeyType,mapChild.childKeyFieldType);
top.setVariable(TemplateNames.MapPValueType,child.local);
try {
template.render(top,out);
}
catch (TemplateException exc){
throw new TemplateException("In template '"+xtm.source+"'.",exc);
}
}
else
throw new TemplateException("Primitive type not found for name '"+mapChild.childValueClassName+"'.");
}
break;
case MapShort: //(fall-through)
case MapLong:{
ClassDescriptor child = Classes.For(mapChild.childValueClassName);
if (null != child){
DefineClass(PackageFor(child,pkg),child,ImportsFor(child,imports),top,TemplateNames.PrefixChild);
top.setVariable(TemplateNames.MapClassName,mapClassName);
top.setVariable(TemplateNames.MapKeyType,mapChild.childKeyFieldType);
top.setVariable(TemplateNames.MapKeyFieldName,mapChild.childKeyFieldName);
top.setVariable(TemplateNames.MapKeyFieldNameCamel,Camel(mapChild.childKeyFieldName));
try {
template.render(top,out);
}
catch (TemplateException exc){
throw new TemplateException("In template '"+xtm.source+"'.",exc);
}
}
else if (null != childClass){
DefineClass(pkg,childClass,imports,top,TemplateNames.PrefixChild);
top.setVariable(TemplateNames.MapClassName,mapClassName);
top.setVariable(TemplateNames.MapKeyType,mapChild.childKeyFieldType);
top.setVariable(TemplateNames.MapKeyFieldName,mapChild.childKeyFieldName);
top.setVariable(TemplateNames.MapKeyFieldNameCamel,Camel(mapChild.childKeyFieldName));
try {
template.render(top,out);
}
catch (TemplateException exc){
throw new TemplateException("In template '"+xtm.source+"'.",exc);
}
}