try {
reader.require(XMLStreamConstants.START_ELEMENT, Edm.NAMESPACE_D_2007_08, name);
final String nullAttribute = reader.getAttributeValue(Edm.NAMESPACE_M_2007_08, FormatXml.M_NULL);
if (!(nullAttribute == null || TRUE.equals(nullAttribute) || FALSE.equals(nullAttribute))) {
throw new EntityProviderException(EntityProviderException.COMMON);
}
if (TRUE.equals(nullAttribute)) {
if ((readProperties == null || readProperties.isValidatingFacets()) && propertyInfo.isMandatory()) {
throw new EntityProviderException(EntityProviderException.INVALID_PROPERTY_VALUE.addContent(name));
}
reader.nextTag();
} else if (propertyInfo.isComplex()) {
final String typeAttribute = reader.getAttributeValue(Edm.NAMESPACE_M_2007_08, FormatXml.M_TYPE);
if (typeAttribute != null) {
final String expectedTypeAttributeValue =
propertyInfo.getType().getNamespace() + Edm.DELIMITER + propertyInfo.getType().getName();
if (!expectedTypeAttributeValue.equals(typeAttribute)) {
throw new EntityProviderException(EntityProviderException.INVALID_COMPLEX_TYPE.addContent(
expectedTypeAttributeValue).addContent(typeAttribute));
}
}
reader.nextTag();
Map<String, Object> name2Value = new HashMap<String, Object>();
while (reader.hasNext() && !reader.isEndElement()) {
final String childName = reader.getLocalName();
final EntityPropertyInfo childProperty =
((EntityComplexPropertyInfo) propertyInfo).getPropertyInfo(childName);
if (childProperty == null) {
throw new EntityProviderException(EntityProviderException.INVALID_PROPERTY.addContent(childName));
}
final Object value = readStartedElement(reader, childProperty, typeMappings.getEntityTypeMapping(name),
readProperties);
name2Value.put(childName, value);
reader.nextTag();
}
result = name2Value;
} else {
result = convert(propertyInfo, reader.getElementText(), typeMappings.getMappingClass(name), readProperties);
}
reader.require(XMLStreamConstants.END_ELEMENT, Edm.NAMESPACE_D_2007_08, name);
return result;
} catch (XMLStreamException e) {
throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
.getSimpleName()), e);
}
}