entryType.setSchemaBinding(schemaBinding);
entryType.setHandler(entryHandler);
entryTypeInfo = JBossXBBuilder.configuration.getTypeInfo(DefaultMapEntry.class);
ElementBinding entryElementBinding = createElementBinding(entryTypeInfo, entryType, entryName, false);
ParticleBinding entryParticle = new ParticleBinding(entryElementBinding, 0, -1, true);
targetGroup.addParticle(entryParticle);
propertyQName = entryName;
if(keyAttribute != null)
{
TypeBinding attributeType = resolveTypeBinding(keyType);
AttributeHandler attributeHandler = new PropertyHandler(entryInfo.getProperty("key"), keyType);
QName attrQName = generateXmlName(keyType, attributeForm, keyAttribute.namespace(), keyAttribute.name());
AttributeBinding keyBinding = new AttributeBinding(schemaBinding, attrQName, attributeType, attributeHandler);
keyBinding.setRequired(true);
entryType.addAttribute(keyBinding);
}
if(valueAttribute != null)
{
TypeBinding attributeType = resolveTypeBinding(valueType);
AttributeHandler attributeHandler = new PropertyHandler(entryInfo.getProperty("value"), valueType);
QName attrQName = generateXmlName(valueType, attributeForm, valueAttribute.namespace(), valueAttribute.name());
AttributeBinding valueBinding = new AttributeBinding(schemaBinding, attrQName, attributeType, attributeHandler);
valueBinding.setRequired(true);
entryType.addAttribute(valueBinding);
}
else if(valueElement == null)
{
CharactersHandler charactersHandler = new ValueHandler(entryInfo.getProperty("value"), valueType);
entryType.setSimpleType(charactersHandler);
}
}
SequenceBinding keyValueSequence = null;
if(keyElement != null)
{
keyValueSequence = new SequenceBinding(schemaBinding);
if(entryType == null)
{
keyValueSequence.setSkip(Boolean.FALSE);
keyValueSequence.setQName(propertyQName);
schemaBinding.addGroup(keyValueSequence.getQName(), keyValueSequence);
ParticleBinding keyValueParticle = new ParticleBinding(keyValueSequence, 0, -1, true);
targetGroup.addParticle(keyValueParticle);
keyValueSequence.setHandler(entryHandler);
}
else
{
ParticleBinding keyValueParticle = new ParticleBinding(keyValueSequence, 1, 1, false);
entryType.setParticle(keyValueParticle);
}
// key element
TypeBinding keyTypeBinding = resolveTypeBinding(keyType);
String keyNs = keyElement.namespace();
if(JBossXmlConstants.DEFAULT.equals(keyNs))
keyNs = defaultNamespace;
ElementBinding keyElementBinding = createElementBinding(keyType, keyTypeBinding, new QName(keyNs, keyElement.name()), false);
ParticleBinding particle = new ParticleBinding(keyElementBinding, 1, 1, false);
keyValueSequence.addParticle(particle);
PropertyHandler keyHandler = new PropertyHandler(entryInfo.getProperty("key"), keyType);
entryAdapterFactory.addProperty(keyElementBinding.getQName(), keyHandler);
}
if(valueElement != null)
{
TypeBinding valueTypeBinding = resolveTypeBinding(valueType);
String valueNs = valueElement.namespace();
if(JBossXmlConstants.DEFAULT.equals(valueNs))
valueNs = defaultNamespace;
ElementBinding valueElementBinding = createElementBinding(valueType, valueTypeBinding, new QName(valueNs, valueElement.name()), false);
ParticleBinding particle = new ParticleBinding(valueElementBinding, 1, 1, false);
keyValueSequence.addParticle(particle);
PropertyHandler valueHandler = new PropertyHandler(entryInfo.getProperty("value"), valueType);
entryAdapterFactory.addProperty(valueElementBinding.getQName(), valueHandler);
}
// TODO: need to verify correct binding before proceeding
boundQName = propertyQName;
}
else if(entryElement != null && !JBossXmlMapEntry.DEFAULT.class.equals(entryElement.type()))
{
if(!JBossXmlConstants.DEFAULT.equals(entryElement.name()))
{
String ns = entryElement.namespace();
if(JBossXmlConstants.DEFAULT.equals(ns))
ns = propertyQName.getNamespaceURI();
propertyQName = new QName(ns, entryElement.name());
}
TypeInfo entryTypeInfo = JBossXBBuilder.configuration.getTypeInfo(entryElement.type());
ElementBinding entryElementBinding = createElementBinding(entryTypeInfo, propertyQName.getLocalPart(), false);
ParticleBinding entryParticle = new ParticleBinding(entryElementBinding, 0, -1, true);
targetGroup.addParticle(entryParticle);
boundQName = propertyQName;
}
return boundQName;
}