in lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/AtomDeserializer.java [326:381]
private void valuable(final Valuable valuable, final XMLEventReader reader, final StartElement start)
throws XMLStreamException, EdmPrimitiveTypeException {
final Attribute nullAttr = start.getAttributeByName(nullQName);
final Attribute typeAttr = start.getAttributeByName(typeQName);
final String typeAttrValue = typeAttr == null ? null : typeAttr.getValue();
final EdmTypeInfo typeInfo = StringUtils.isBlank(typeAttrValue) ? null :
new EdmTypeInfo.Builder().setTypeExpression(typeAttrValue).build();
if (typeInfo != null) {
valuable.setType(typeInfo.internal());
}
final PropertyType propType = typeInfo == null ? guessPropertyType(reader, typeInfo) :
typeInfo.isCollection() ? PropertyType.COLLECTION :
typeInfo.isPrimitiveType() ? PropertyType.PRIMITIVE : PropertyType.COMPLEX;
if (nullAttr == null) {
switch (propType) {
case COLLECTION:
fromCollection(valuable, reader, start, typeInfo);
break;
case COMPLEX:
final Object complexValue = fromComplexOrEnum(reader, start);
if (typeInfo != null && complexValue instanceof ComplexValue &&
start.getAttributeByName(QName.valueOf(Constants.ATOM_ATTR_TERM)) == null) {
((ComplexValue)complexValue).setTypeName(typeInfo.external());
}
valuable.setValue(complexValue instanceof ComplexValue ? ValueType.COMPLEX : ValueType.ENUM,
complexValue);
break;
case PRIMITIVE:
// No type specified? Defaults to Edm.String
if (typeInfo == null) {
valuable.setType(EdmPrimitiveTypeKind.String.getFullQualifiedName().toString());
}
final Object value = fromPrimitive(reader, start, typeInfo);
valuable.setValue(value instanceof Geospatial ? ValueType.GEOSPATIAL : ValueType.PRIMITIVE, value);
break;
case EMPTY:
default:
valuable.setValue(ValueType.PRIMITIVE, StringUtils.EMPTY);
}
} else {
valuable.setValue(propType == PropertyType.PRIMITIVE ? ValueType.PRIMITIVE :
propType == PropertyType.ENUM ? ValueType.ENUM :
propType == PropertyType.COMPLEX ? ValueType.COMPLEX :
propType == PropertyType.COLLECTION ? ValueType.COLLECTION_PRIMITIVE : ValueType.PRIMITIVE,
null);
}
}