groupWildcardHandler = new ChildWildcardHandler(property, wrapperInfo, groupWildcard.property());
}
else
groupWildcardHandler = new ChildWildcardHandler(property);
WildcardBinding wildcard = new WildcardBinding(schemaBinding);
if (groupWildcard.lax())
wildcard.setProcessContents((short) 3); // Lax
else
wildcard.setProcessContents((short) 1); // Strict
particleBinding = new ParticleBinding(wildcard);
particleBinding.setMinOccurs(0);
particleBinding.setMaxOccurs(1);
childModel.addParticle(particleBinding);
elementTypeBinding.getWildcard().setWildcardHandler(groupWildcardHandler);
}
}
}
}
else
{
XBValueAdapter valueAdapter = null;
XmlJavaTypeAdapter xmlTypeAdapter = property.getUnderlyingAnnotation(XmlJavaTypeAdapter.class);
if (xmlTypeAdapter != null)
{
valueAdapter = new XBValueAdapter(xmlTypeAdapter.value(), propertyType.getTypeInfoFactory());
localPropertyType = valueAdapter.getAdaptedTypeInfo();
}
ModelGroupBinding targetGroup = localModel;
boolean isCol = false;
boolean isMap = false;
AbstractPropertyHandler propertyHandler = null;
// a collection may be bound as a value of a complex type
// and this is checked with the XmlType annotation
if (propertyType.isCollection() && ((ClassInfo) propertyType).getUnderlyingAnnotation(XmlType.class) == null)
{
isCol = true;
propertyHandler = new CollectionPropertyHandler(property, propertyType);
// here we get the comp type based on the non-overriden property type...
// which feels like a weak point
TypeInfo typeArg = ((ClassInfo)property.getType()).getComponentType();
if (typeArg != null)
{
JBossXmlChild xmlChild = ((ClassInfo) propertyType).getUnderlyingAnnotation(JBossXmlChild.class);
if (xmlChild == null && localPropertyType.equals(propertyType))
{ // the localPropertyType was not overriden previously so use the collection parameter type
localPropertyType = typeArg;
}
}
}
// TODO this shouldn't be here (because localPropertyType should specify an item?)
// this is to support the Descriptions.class -> DescriptionsImpl.class
else if (localPropertyType.isCollection()
&& ((ClassInfo) localPropertyType).getUnderlyingAnnotation(XmlType.class) == null)
{
if (valueAdapter != null)
propertyHandler = new PropertyHandler(property, localPropertyType);
else
propertyHandler = new CollectionPropertyHandler(property, localPropertyType);
isCol = true;
localPropertyType = ((ClassInfo)localPropertyType).getComponentType();
}
else if (localPropertyType.isMap())
{
TypeBinding wrapperType = null;
if(elements.length > 1)
{
wrapperType = resolveTypeBinding(localPropertyType);
ElementBinding elementBinding = createElementBinding(localPropertyType, wrapperType, propertyQName, false);
elementBinding.setNillable(nillable);
elementBinding.setValueAdapter(valueAdapter);
// Bind it to the model
ParticleBinding particle = new ParticleBinding(elementBinding, 0, 1, isCol);
if (required == false)
particle.setMinOccurs(0);
targetGroup.addParticle(particle);
targetGroup = (ModelGroupBinding) wrapperType.getParticle().getTerm();
}
QName boundQName = bindMapProperty(property, (ClassInfo) localPropertyType, propertyQName, targetGroup);
if(boundQName != null)
{
if(wrapperType != null)
{
BeanAdapterFactory wrapperBeanFactory = ((BeanHandler)wrapperType.getHandler()).getBeanAdapterFactory();
Map<QName, AbstractPropertyHandler> properties = wrapperBeanFactory.getProperties();
if(!properties.containsKey(boundQName))
{
propertyHandler = new MapPropertyHandler(JBossXBBuilder.configuration, property, localPropertyType, true);
wrapperBeanFactory.addProperty(boundQName, propertyHandler);
}
propertyHandler = new PropertyHandler(property, localPropertyType);
}
else
{
propertyQName = boundQName;
propertyHandler = new MapPropertyHandler(JBossXBBuilder.configuration, property, localPropertyType, false);
}
isMap = true;
}
else
propertyHandler = new PropertyHandler(property, localPropertyType);
}
else
{
propertyHandler = new PropertyHandler(property, localPropertyType);
}
ParticleBinding particle;
if(Element.class.getName().equals(propertyType.getName()))
{
if(!wildcardProperty)
{
WildcardBinding wildcard = new WildcardBinding(schemaBinding);
wildcard.setProcessContents((short) 2);
wildcard.setUnresolvedElementHandler(DOMHandler.INSTANCE);
wildcard.setUnresolvedCharactersHandler(DOMHandler.INSTANCE);
SequenceBinding seq = new SequenceBinding(schemaBinding);
seq.addParticle(new ParticleBinding(wildcard, 0, 1, false));
TypeBinding elementTypeBinding = new TypeBinding();