Program: 66731
Project: 66731
Buggy source:
private void processSimpleElement(String targetNamespace,String defaultNamespace,SDOType owningType,SDOType sdoPropertyType,TypeDefParticle typeDefParticle,Element element,boolean isQualified,boolean isGlobal,boolean isMany){
  if (element == null) {
    return;
  }
  String manyValue=(String)element.getAttributesMap().get(SDOConstants.SDOXML_MANY_QNAME);
  if (manyValue != null) {
    Boolean manyBoolean=new Boolean(manyValue);
    isMany=manyBoolean.booleanValue();
  }
  SDOProperty p=null;
  String typeName=null;
  String mappingUri=null;
  if (typeDefParticle != null) {
    mappingUri=owningType.getURI();
  }
  if (element.getRef() != null) {
    String ref=element.getRef();
    String localName=null;
    String uri=null;
    int index=ref.indexOf(':');
    if (index != -1) {
      String prefix=ref.substring(0,index);
      localName=ref.substring(index + 1,ref.length());
      uri=getURIForPrefix(prefix);
    }
 else {
      localName=ref;
      uri=defaultNamespace;
    }
    Property lookedUp=owningType.getProperty(localName);
    if (lookedUp != null) {
      if (inRestriction) {
        return;
      }
      updateCollisionProperty(owningType,(SDOProperty)lookedUp);
    }
 else {
      SDOProperty theProp=new SDOProperty(aHelperContext);
      theProp.setName(localName);
      theProp.setGlobal(false);
      theProp.setContainment(true);
      theProp.setXsd(true);
      theProp.setMany(isMany);
      theProp.setInstanceProperty(SDOConstants.XMLELEMENT_PROPERTY,Boolean.TRUE);
      if (element.getAnnotation() != null) {
        java.util.List doc=element.getAnnotation().getDocumentation();
        if (doc != null) {
          theProp.setInstanceProperty(SDOConstants.DOCUMENTATION_PROPERTY,doc);
        }
      }
      owningType.addDeclaredProperty(theProp);
      GlobalRef globalRef=new GlobalRef();
      globalRef.setProperty(theProp);
      globalRef.setIsElement(true);
      globalRef.setOwningType(owningType);
      globalRef.setUri(uri);
      globalRef.setLocalName(localName);
      addGlobalRef(globalRef);
    }
    return;
  }
 else {
    if (isGlobal) {
      SDOProperty lookedUpProp=getExistingGlobalProperty(targetNamespace,element.getName(),true);
      if (lookedUpProp != null && lookedUpProp.isFinalized()) {
        return;
      }
    }
    p=createNewProperty(targetNamespace,element.getName(),isQualified,isGlobal,true,element.isNillable(),element.getAnnotation());
    if (element.getAnnotation() != null) {
      p.setAppInfoElements(element.getAnnotation().getAppInfo());
    }
    if (element.getType() != null) {
      typeName=element.getType();
      p.setName(element.getName());
      QName qname=getQNameForString(defaultNamespace,typeName);
      if (isGlobal) {
        if (qname.getNamespaceURI().equals(targetNamespace)) {
          processGlobalItem(targetNamespace,defaultNamespace,qname.getLocalPart());
        }
      }
      if ((qname.equals(XMLConstants.QNAME_QNAME)) || (qname.equals(XMLConstants.BASE_64_BINARY_QNAME)) || (qname.equals(XMLConstants.HEX_BINARY_QNAME))|| (qname.equals(XMLConstants.DATE_QNAME))|| (qname.equals(XMLConstants.TIME_QNAME))|| (qname.equals(XMLConstants.DATE_TIME_QNAME))) {
        p.setXsdType(qname);
      }
      String mimeType=(String)element.getAttributesMap().get(SDOConstants.XML_MIME_TYPE_QNAME);
      if (mimeType != null) {
        p.setInstanceProperty(SDOConstants.MIME_TYPE_PROPERTY,mimeType);
      }
      String mimeTypePropName=(String)element.getAttributesMap().get(SDOConstants.XML_MIME_TYPE_PROPERTY_QNAME);
      if (mimeTypePropName != null) {
        p.setInstanceProperty(SDOConstants.MIME_TYPE_PROPERTY_PROPERTY,mimeTypePropName);
      }
      sdoPropertyType=getSDOTypeForName(targetNamespace,defaultNamespace,typeName);
      if (!sdoPropertyType.isFinalized() && qname.getNamespaceURI().equals(targetNamespace)) {
        if (sdoPropertyType.isDataType()) {
          SimpleType baseSimpleType=(SimpleType)rootSchema.getTopLevelSimpleTypes().get(qname.getLocalPart());
          processGlobalSimpleType(targetNamespace,defaultNamespace,baseSimpleType);
        }
      }
      if ((p.getXsdType() == null) && (sdoPropertyType.getXsdType() != null)) {
        p.setXsdType(sdoPropertyType.getXsdType());
      }
      if (sdoPropertyType.isDataType()) {
        p.setContainment(false);
      }
    }
 else     if (element.getComplexType() != null) {
      typeName=element.getName();
      p.setName(element.getComplexType().getNameOrOwnerName());
    }
 else     if (element.getSimpleType() != null) {
      typeName=element.getName();
      p.setName(element.getName());
      if (sdoPropertyType.isDataType()) {
        p.setContainment(false);
      }
    }
 else {
      p.setName(element.getName());
      sdoPropertyType=((SDOTypeHelper)aHelperContext.getTypeHelper()).getSDOTypeFromXSDType(SDOConstants.ANY_TYPE_QNAME);
    }
  }
  sdoPropertyType=processSimpleComponentAnnotations(owningType,element,p,targetNamespace,defaultNamespace,sdoPropertyType);
  p.setType(sdoPropertyType);
  setDefaultValue(p,element);
  p.setMany(isMany);
  if (p.getType().isChangeSummaryType()) {
    p.setReadOnly(true);
  }
  if (typeDefParticle != null) {
    updateOwnerAndBuildMapping(owningType,p,defaultNamespace,targetNamespace,element,typeName,mappingUri);
  }
  if (isGlobal) {
    addRootElementToDescriptor(p,targetNamespace,element.getName());
  }
  p.setFinalized(true);
}

Fixed version (ground truth):
private void processSimpleElement(String targetNamespace,String defaultNamespace,SDOType owningType,SDOType sdoPropertyType,TypeDefParticle typeDefParticle,Element element,boolean isQualified,boolean isGlobal,boolean isMany){
  if (element == null) {
    return;
  }
  String manyValue=(String)element.getAttributesMap().get(SDOConstants.SDOXML_MANY_QNAME);
  if (manyValue != null) {
    isMany=Boolean.valueOf(manyValue);
  }
  SDOProperty p=null;
  String typeName=null;
  String mappingUri=null;
  if (typeDefParticle != null) {
    mappingUri=owningType.getURI();
  }
  if (element.getRef() != null) {
    String ref=element.getRef();
    String localName=null;
    String uri=null;
    int index=ref.indexOf(':');
    if (index != -1) {
      String prefix=ref.substring(0,index);
      localName=ref.substring(index + 1,ref.length());
      uri=getURIForPrefix(prefix);
    }
 else {
      localName=ref;
      uri=defaultNamespace;
    }
    Property lookedUp=owningType.getProperty(localName);
    if (lookedUp != null) {
      if (inRestriction) {
        return;
      }
      updateCollisionProperty(owningType,(SDOProperty)lookedUp);
    }
 else {
      SDOProperty theProp=new SDOProperty(aHelperContext);
      theProp.setName(localName);
      theProp.setGlobal(false);
      theProp.setContainment(true);
      theProp.setXsd(true);
      theProp.setMany(isMany);
      theProp.setInstanceProperty(SDOConstants.XMLELEMENT_PROPERTY,Boolean.TRUE);
      if (element.getAnnotation() != null) {
        java.util.List doc=element.getAnnotation().getDocumentation();
        if (doc != null) {
          theProp.setInstanceProperty(SDOConstants.DOCUMENTATION_PROPERTY,doc);
        }
      }
      owningType.addDeclaredProperty(theProp);
      GlobalRef globalRef=new GlobalRef();
      globalRef.setProperty(theProp);
      globalRef.setIsElement(true);
      globalRef.setOwningType(owningType);
      globalRef.setUri(uri);
      globalRef.setLocalName(localName);
      addGlobalRef(globalRef);
    }
    return;
  }
 else {
    if (isGlobal) {
      SDOProperty lookedUpProp=getExistingGlobalProperty(targetNamespace,element.getName(),true);
      if (lookedUpProp != null && lookedUpProp.isFinalized()) {
        return;
      }
    }
    p=createNewProperty(targetNamespace,element.getName(),isQualified,isGlobal,true,element.isNillable(),element.getAnnotation());
    if (element.getAnnotation() != null) {
      p.setAppInfoElements(element.getAnnotation().getAppInfo());
    }
    if (element.getType() != null) {
      typeName=element.getType();
      p.setName(element.getName());
      QName qname=getQNameForString(defaultNamespace,typeName);
      if (isGlobal) {
        if (qname.getNamespaceURI().equals(targetNamespace)) {
          processGlobalItem(targetNamespace,defaultNamespace,qname.getLocalPart());
        }
      }
      if ((qname.equals(XMLConstants.QNAME_QNAME)) || (qname.equals(XMLConstants.BASE_64_BINARY_QNAME)) || (qname.equals(XMLConstants.HEX_BINARY_QNAME))|| (qname.equals(XMLConstants.DATE_QNAME))|| (qname.equals(XMLConstants.TIME_QNAME))|| (qname.equals(XMLConstants.DATE_TIME_QNAME))) {
        p.setXsdType(qname);
      }
      String mimeType=(String)element.getAttributesMap().get(SDOConstants.XML_MIME_TYPE_QNAME);
      if (mimeType != null) {
        p.setInstanceProperty(SDOConstants.MIME_TYPE_PROPERTY,mimeType);
      }
      String mimeTypePropName=(String)element.getAttributesMap().get(SDOConstants.XML_MIME_TYPE_PROPERTY_QNAME);
      if (mimeTypePropName != null) {
        p.setInstanceProperty(SDOConstants.MIME_TYPE_PROPERTY_PROPERTY,mimeTypePropName);
      }
      sdoPropertyType=getSDOTypeForName(targetNamespace,defaultNamespace,typeName);
      if (!sdoPropertyType.isFinalized() && qname.getNamespaceURI().equals(targetNamespace)) {
        if (sdoPropertyType.isDataType()) {
          SimpleType baseSimpleType=(SimpleType)rootSchema.getTopLevelSimpleTypes().get(qname.getLocalPart());
          processGlobalSimpleType(targetNamespace,defaultNamespace,baseSimpleType);
        }
      }
      if ((p.getXsdType() == null) && (sdoPropertyType.getXsdType() != null)) {
        p.setXsdType(sdoPropertyType.getXsdType());
      }
      if (sdoPropertyType.isDataType()) {
        p.setContainment(false);
      }
    }
 else     if (element.getComplexType() != null) {
      typeName=element.getName();
      p.setName(element.getComplexType().getNameOrOwnerName());
    }
 else     if (element.getSimpleType() != null) {
      typeName=element.getName();
      p.setName(element.getName());
      if (sdoPropertyType.isDataType()) {
        p.setContainment(false);
      }
    }
 else {
      p.setName(element.getName());
      sdoPropertyType=((SDOTypeHelper)aHelperContext.getTypeHelper()).getSDOTypeFromXSDType(SDOConstants.ANY_TYPE_QNAME);
    }
  }
  sdoPropertyType=processSimpleComponentAnnotations(owningType,element,p,targetNamespace,defaultNamespace,sdoPropertyType);
  p.setType(sdoPropertyType);
  setDefaultValue(p,element);
  p.setMany(isMany);
  if (p.getType().isChangeSummaryType()) {
    p.setReadOnly(true);
  }
  if (typeDefParticle != null) {
    updateOwnerAndBuildMapping(owningType,p,defaultNamespace,targetNamespace,element,typeName,mappingUri);
  }
  if (isGlobal) {
    addRootElementToDescriptor(p,targetNamespace,element.getName());
  }
  p.setFinalized(true);
}