Program: 130073
Project: 130073
Buggy source:
private void addParticleDetail(XSDSchema xsdSchema,XSDParticle xsdParticle,ATreeNode parentNode,String currentPath) throws OdaException {
  XSDTerm xsdTerm=xsdParticle.getTerm();
  if (xsdTerm instanceof XSDElementDeclaration) {
    XSDElementDeclaration xsdElementDeclarationParticle=(XSDElementDeclaration)xsdTerm;
    ATreeNode partNode=new ATreeNode();
    String elementName=xsdElementDeclarationParticle.getName();
    String prefix=null;
    String namespace=xsdElementDeclarationParticle.getTargetNamespace();
    if (namespace != null) {
      prefix=namespaceToPrefix.get(namespace);
      if (prefix == null) {
        prefix=((XSDElementDeclaration)xsdTerm).getQName().contains("String_Node_Str") ? ((XSDElementDeclaration)xsdTerm).getQName().split("String_Node_Str")[0] : "String_Node_Str";
        if (isEnableGeneratePrefix() && (prefix == null || prefix.isEmpty())) {
          prefix="String_Node_Str" + prefixNumberGenerated;
          prefixNumberGenerated++;
        }
        if (namespaceToPrefix.containsValue(prefix)) {
          prefix=prefix + prefixNumberGenerated;
          prefixNumberGenerated++;
        }
        if (prefix != null && !prefix.isEmpty()) {
          namespaceToPrefix.put(namespace,prefix);
        }
 else {
          ATreeNode namespaceNode=new ATreeNode();
          namespaceNode.setDataType("String_Node_Str");
          namespaceNode.setType(ATreeNode.NAMESPACE_TYPE);
          namespaceNode.setValue(namespace);
          partNode.addChild(namespaceNode);
        }
      }
    }
    if (prefix != null && !prefix.isEmpty()) {
      elementName=prefix + "String_Node_Str" + elementName;
    }
    partNode.setValue(elementName);
    partNode.setType(ATreeNode.ELEMENT_TYPE);
    partNode.setDataType(xsdElementDeclarationParticle.getName());
    parentNode.addChild(partNode);
    if (xsdElementDeclarationParticle.getTypeDefinition() instanceof XSDComplexTypeDefinition) {
      if (!currentPath.contains("String_Node_Str" + elementName + "String_Node_Str")) {
        String path=currentPath + elementName + "String_Node_Str";
        XSDTypeDefinition xsdTypeDefinition=xsdElementDeclarationParticle.getTypeDefinition();
        XSDComplexTypeDefinition generalType=xsdSchema.resolveComplexTypeDefinitionURI(xsdElementDeclarationParticle.getURI());
        if (generalType.getContainer() != null) {
          xsdTypeDefinition=generalType;
        }
        if (xsdTypeDefinition != null && xsdTypeDefinition.getName() != null) {
          partNode.setDataType(xsdTypeDefinition.getQName());
        }
        addComplexTypeDetails(xsdSchema,partNode,xsdTypeDefinition,prefix,namespace,path);
      }
    }
 else {
      String dataType=xsdElementDeclarationParticle.getTypeDefinition().getQName();
      if (xsdElementDeclarationParticle.getTypeDefinition().getBaseType() != null) {
        if (!"String_Node_Str".equals(xsdElementDeclarationParticle.getTypeDefinition().getBaseType().getQName())) {
          dataType=xsdElementDeclarationParticle.getTypeDefinition().getBaseType().getQName();
        }
      }
      partNode.setDataType(dataType);
    }
  }
 else   if (xsdTerm instanceof XSDModelGroup) {
    XSDModelGroup xsdModelGroup=(XSDModelGroup)xsdTerm;
    for (Iterator j=xsdModelGroup.getParticles().iterator(); j.hasNext(); ) {
      XSDParticle childParticle=(XSDParticle)j.next();
      addParticleDetail(xsdSchema,childParticle,parentNode,currentPath);
    }
  }
}

Fixed version (ground truth):
private void addParticleDetail(XSDSchema xsdSchema,XSDParticle xsdParticle,ATreeNode parentNode,String currentPath) throws OdaException {
  XSDTerm xsdTerm=xsdParticle.getTerm();
  if (xsdTerm instanceof XSDElementDeclaration) {
    XSDElementDeclaration xsdElementDeclarationParticle=(XSDElementDeclaration)xsdTerm;
    ATreeNode partNode=new ATreeNode();
    String elementName=xsdElementDeclarationParticle.getName();
    String prefix=null;
    String namespace=xsdElementDeclarationParticle.getTargetNamespace();
    XSDTypeDefinition typeDef=xsdElementDeclarationParticle.getTypeDefinition();
    if (namespace != null) {
      prefix=namespaceToPrefix.get(namespace);
      if (prefix == null) {
        prefix=((XSDElementDeclaration)xsdTerm).getQName().contains("String_Node_Str") ? ((XSDElementDeclaration)xsdTerm).getQName().split("String_Node_Str")[0] : "String_Node_Str";
        if (isEnableGeneratePrefix() && (prefix == null || prefix.isEmpty())) {
          prefix="String_Node_Str" + prefixNumberGenerated;
          prefixNumberGenerated++;
        }
        if (namespaceToPrefix.containsValue(prefix)) {
          prefix=prefix + prefixNumberGenerated;
          prefixNumberGenerated++;
        }
        if (prefix != null && !prefix.isEmpty()) {
          namespaceToPrefix.put(namespace,prefix);
        }
 else {
          ATreeNode namespaceNode=new ATreeNode();
          namespaceNode.setDataType("String_Node_Str");
          namespaceNode.setType(ATreeNode.NAMESPACE_TYPE);
          namespaceNode.setValue(namespace);
          partNode.addChild(namespaceNode);
        }
      }
    }
    if (namespace == null && typeDef.getTargetNamespace() != null && !typeDef.getTargetNamespace().equals(parentNode.getCurrentNamespace())) {
      namespace=typeDef.getTargetNamespace();
      if (!XSDConstants.isSchemaForSchemaNamespace(namespace)) {
        prefix=namespaceToPrefix.get(namespace);
        if (prefix == null) {
          if (xsdSchema.getQNamePrefixToNamespaceMap().containsValue(typeDef.getTargetNamespace())) {
            for (            String key : xsdSchema.getQNamePrefixToNamespaceMap().keySet()) {
              if (xsdSchema.getQNamePrefixToNamespaceMap().get(key).equals(typeDef.getTargetNamespace())) {
                prefix=key;
              }
            }
          }
 else {
            prefix="String_Node_Str" + prefixNumberGenerated;
            prefixNumberGenerated++;
          }
          namespaceToPrefix.put(namespace,prefix);
        }
      }
    }
    partNode.setCurrentNamespace(namespace);
    if (prefix != null && !prefix.isEmpty()) {
      elementName=prefix + "String_Node_Str" + elementName;
    }
    partNode.setValue(elementName);
    partNode.setType(ATreeNode.ELEMENT_TYPE);
    partNode.setDataType(xsdElementDeclarationParticle.getName());
    parentNode.addChild(partNode);
    boolean resolvedAsComplex=false;
    if (typeDef instanceof XSDComplexTypeDefinition) {
      if (!currentPath.contains("String_Node_Str" + elementName + "String_Node_Str")) {
        String path=currentPath + elementName + "String_Node_Str";
        XSDTypeDefinition xsdTypeDefinition=xsdElementDeclarationParticle.getTypeDefinition();
        XSDComplexTypeDefinition generalType=xsdSchema.resolveComplexTypeDefinitionURI(xsdElementDeclarationParticle.getURI());
        if (generalType.getContainer() != null) {
          xsdTypeDefinition=generalType;
        }
        if (xsdTypeDefinition != null && xsdTypeDefinition.getName() != null) {
          partNode.setDataType(xsdTypeDefinition.getQName());
        }
        addComplexTypeDetails(xsdSchema,partNode,xsdTypeDefinition,prefix,namespace,path);
      }
      resolvedAsComplex=true;
    }
 else     if (typeDef.getTargetNamespace() != null) {
      resolvedAsComplex=true;
      if (!currentPath.contains("String_Node_Str" + elementName + "String_Node_Str")) {
        String path=currentPath + elementName + "String_Node_Str";
        XSDComplexTypeDefinition generalType=xsdSchema.resolveComplexTypeDefinition(typeDef.getQName());
        XSDTypeDefinition xsdTypeDefinition=xsdElementDeclarationParticle.getTypeDefinition();
        if (generalType.getContainer() != null) {
          xsdTypeDefinition=generalType;
        }
        if (xsdTypeDefinition != null && xsdTypeDefinition.getName() != null) {
          partNode.setDataType(xsdTypeDefinition.getName());
        }
        if (xsdTypeDefinition instanceof XSDComplexTypeDefinition) {
          addComplexTypeDetails(xsdSchema,partNode,xsdTypeDefinition,prefix,namespace,path);
        }
 else {
          resolvedAsComplex=false;
        }
      }
    }
    if (!resolvedAsComplex) {
      String dataType=xsdElementDeclarationParticle.getTypeDefinition().getQName();
      if (xsdElementDeclarationParticle.getTypeDefinition().getBaseType() != null) {
        if (!"String_Node_Str".equals(xsdElementDeclarationParticle.getTypeDefinition().getBaseType().getQName())) {
          dataType=xsdElementDeclarationParticle.getTypeDefinition().getBaseType().getQName();
        }
      }
      partNode.setDataType(dataType);
    }
  }
 else   if (xsdTerm instanceof XSDModelGroup) {
    XSDModelGroup xsdModelGroup=(XSDModelGroup)xsdTerm;
    for (Iterator j=xsdModelGroup.getParticles().iterator(); j.hasNext(); ) {
      XSDParticle childParticle=(XSDParticle)j.next();
      addParticleDetail(xsdSchema,childParticle,parentNode,currentPath);
    }
  }
}