* @param delimiterType
* @return the created {@link org.milyn.javabean.pojogen.JClass}
* @throws IllegalNameException when name found in a xmltag-attribute is a java keyword.
*/
private BindingConfig createChildAndConnectWithParent(BindingConfig parentBinding, MappingNode mappingNode, int maxOccurs, DelimiterType delimiterType) throws IllegalNameException {
JClass child = getCommonType(mappingNode);
boolean addClassToModel = false;
if(child == null) {
String packageName = parentBinding.getBeanClass().getPackageName();
String className = EDIUtils.encodeClassName(mappingNode.getJavaName());
if(mappingNode instanceof Field) {
packageName += ".field";
} else if(mappingNode instanceof Component) {
packageName += ".component";
} else if(mappingNode instanceof SubComponent) {
packageName += ".subcomponent";
}
child = new JClass(packageName, className, getCurrentClassId()).setSerializable();
addClassToModel = true;
LOG.debug("Created class " + child.getClassName() + ".");
}
JType jtype;
if (maxOccurs > 1 || maxOccurs == -1) {
jtype = new JType(List.class, child.getSkeletonClass());
} else {
jtype = new JType(child.getSkeletonClass());
}
String propertyName = EDIUtils.encodeAttributeName(jtype, mappingNode.getJavaName());
JNamedType childProperty = new JNamedType(jtype, propertyName);
BindingConfig childBeanConfig = new BindingConfig(getCurrentClassId(), getCurrentNodePath(), child, parentBinding, childProperty);
childBeanConfig.setMappingNode(mappingNode);
JClass parentBeanClass = parentBinding.getBeanClass();
if(!parentBeanClass.isFinalized() && !parentBeanClass.hasProperty(propertyName) && model.isClassCreator(parentBeanClass)) {
parentBeanClass.addBeanProperty(childProperty);
if(delimiterType != null) {
getWriteMethod(parentBinding).writeObject(childProperty, delimiterType, parentBinding, mappingNode);
}
}
if(addClassToModel) {