in xbean-spring/src/main/java/org/apache/xbean/spring/context/impl/QNameHelper.java [86:128]
public static void coerceNamespaceAwarePropertyValues(AbstractBeanDefinition bd, Element element, PropertyDescriptor[] descriptors, int i) {
PropertyDescriptor descriptor = descriptors[i];
// When the property is an indexed property, the getPropertyType can return null.
if (descriptor.getPropertyType() == null) {
return;
}
if (descriptor.getPropertyType().isAssignableFrom(QName.class)) {
String name = descriptor.getName();
MutablePropertyValues propertyValues = bd.getPropertyValues();
PropertyValue propertyValue = propertyValues.getPropertyValue(name);
if (propertyValue != null) {
Object value = propertyValue.getValue();
if (value instanceof String) {
propertyValues.removePropertyValue(propertyValue);
addPropertyValue(propertyValues, name, createQName(element, (String) value));
} else if (value instanceof TypedStringValue) {
propertyValues.removePropertyValue(propertyValue);
addPropertyValue(propertyValues, name, createQName(element, ((TypedStringValue) value).getValue()));
}
}
} else if (descriptor.getPropertyType().isAssignableFrom(QName[].class)) {
String name = descriptor.getName();
MutablePropertyValues propertyValues = bd.getPropertyValues();
PropertyValue propertyValue = propertyValues.getPropertyValue(name);
if (propertyValue != null) {
Object value = propertyValue.getValue();
if (value instanceof List) {
List values = (List) value;
List newValues = new ManagedList();
for (Iterator iter = values.iterator(); iter.hasNext();) {
Object v = iter.next();
if (v instanceof String) {
newValues.add(createQName(element, (String) v));
} else {
newValues.add(v);
}
}
propertyValues.removePropertyValue(propertyValue);
propertyValues.addPropertyValue(name, newValues);
}
}
}
}