use of org.eclipse.persistence.oxm.mappings.XMLVariableXPathCollectionMapping in project eclipselink by eclipse-ee4j.
the class MappingsGenerator method generateVariableXPathCollectionMapping.
private Mapping generateVariableXPathCollectionMapping(Property property, Descriptor descriptor, NamespaceInfo namespaceInfo, JavaClass actualType) {
XMLVariableXPathCollectionMapping mapping = new XMLVariableXPathCollectionMapping();
mapping.setAttributeName(property.getPropertyName());
if (property.isMap()) {
actualType = property.getValueType();
}
initializeXMLContainerMapping(mapping, property.getType().isArray());
initializeXMLMapping(mapping, property);
initializeVariableXPathMapping(mapping, property, actualType);
if (property.getXmlPath() != null) {
mapping.setField(new XMLField(property.getXmlPath()));
} else {
if (property.isSetXmlElementWrapper()) {
mapping.setField((XMLField) getXPathForField(property, namespaceInfo, false, true));
}
}
if (property.isSetXmlElementWrapper()) {
mapping.setWrapperNullPolicy(getWrapperNullPolicyFromProperty(property));
}
JavaClass collectionType = property.getType();
if (collectionType.isArray()) {
JAXBArrayAttributeAccessor accessor = new JAXBArrayAttributeAccessor(mapping.getAttributeAccessor(), mapping.getContainerPolicy(), helper.getClassLoader());
JavaClass componentType = collectionType.getComponentType();
if (componentType.isArray()) {
JavaClass baseComponentType = getBaseComponentType(componentType);
if (baseComponentType.isPrimitive()) {
Class<Object> primitiveClass = XMLConversionManager.getDefaultManager().convertClassNameToClass(baseComponentType.getRawName());
accessor.setComponentClass(primitiveClass);
} else {
accessor.setComponentClassName(baseComponentType.getQualifiedName());
}
} else {
accessor.setComponentClassName(componentType.getQualifiedName());
}
mapping.setAttributeAccessor(accessor);
}
if (property.isMap()) {
JavaClass mapType = property.getType();
if (mapType.isInterface()) {
mapping.useMapClass("java.util.HashMap");
} else {
mapping.useMapClass(property.getType().getName());
}
} else {
collectionType = containerClassImpl(collectionType);
mapping.useCollectionClass(helper.getClassForJavaClass(collectionType));
}
return mapping;
}
Aggregations