* @param detail mapping details
*/
private void addMapping(String type, BindingMappingDetail detail) {
// create the basic mapping structure(s)
ClassCustom cust = m_global.addClassCustomization(type);
MappingElementBase mainmapping = null;
QName qname = null;
MappingElementBase mapcon = null;
IClass clas = cust.getClassInformation();
if (detail.isUseConcrete()) {
// create concrete mapping
mapcon = createMapping(type, cust);
qname = detail.getElementQName();
mapcon.setName(qname.getName());
detail.setConcreteMapping(mapcon);
// make "concrete" mapping abstract if no class creation possible
if (clas.isAbstract() || clas.isInterface()) {
mapcon.setAbstract(true);
}
// fill details directly to this mapping unless abstract also created
mainmapping = mapcon;
}
MappingElement mapabs = null;
if (detail.isUseAbstract()) {
// create abstract mapping
mapabs = createMapping(type, cust);
mapabs.setAbstract(true);
qname = detail.getTypeQName();
mapabs.setTypeQName(qname);
detail.setAbstractMapping(mapabs);
// use abstract mapping for details (concrete will reference this one)
mainmapping = mapabs;
}
if (mainmapping != null) {
// find the binding containing this mapping
String uri = qname.getUri();
BindingHolder hold = m_directory.getBinding(uri);
if (mainmapping.isAbstract()) {
hold.addTypeNameReference(uri, uri);
}
// check for superclass mapping to be extended (do this first for compatibility with schema type extension)
StructureElement struct = null;
String ptype = detail.getExtendsType();
Map exmembmap = Collections.EMPTY_MAP;
Map inmembmap = new HashMap();
if (ptype == null) {
// not extending a base mapping, check if need to include superclass
IClass parent = clas.getSuperClass();
if (cust.isUseSuper() && parent != null) {
ptype = parent.getName();
if (checkInclude(ptype)) {
struct = new StructureElement();
struct.setDeclaredType(ptype);
ClassCustom scust = m_global.getClassCustomization(ptype);
exmembmap = new HashMap();
fillStructure(scust, null, exmembmap, struct, hold);
}
}