Program: 148924
Project: 148924
Buggy source:
/** 
 * Find elementDeclarations that use any types derived from a named type. <p> This shows one way to query the schema for elementDeclarations and then how to find specific kinds of typeDefinitions. </p>
 * @param objList collection set to search for elemDecls
 * @param namespace for the type used
 * @param localName for the type used
 * @return Boolean  indicate any XSDElementDeclarations is found or not
 */
public static boolean findElementsUsingType(ArrayList<Object> objList,String namespace,String localName){
  if (null == localName) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  for (Iterator<Object> iter=objList.iterator(); iter.hasNext(); ) {
    Object obj=iter.next();
    if (obj instanceof XSDElementDeclaration || obj instanceof XSDTypeDefinition) {
      XSDTypeDefinition typedef=null;
      if (obj instanceof XSDElementDeclaration) {
        XSDElementDeclaration elem=(XSDElementDeclaration)obj;
        if (elem.getAnonymousTypeDefinition() != null) {
          typedef=elem.getAnonymousTypeDefinition();
        }
 else         if (elem.getTypeDefinition() != null) {
          typedef=elem.getTypeDefinition();
        }
 else {
          continue;
        }
      }
 else {
        typedef=(XSDTypeDefinition)obj;
      }
      if (typedef instanceof XSDComplexTypeDefinition) {
        XSDComplexTypeDefinition type=(XSDComplexTypeDefinition)typedef;
        if (type.getContent() instanceof XSDParticle) {
          XSDParticle particle=(XSDParticle)type.getContent();
          if (particle.getTerm() instanceof XSDModelGroup) {
            XSDModelGroup group=(XSDModelGroup)particle.getTerm();
            EList<XSDParticle> elist=group.getContents();
            for (            XSDParticle pt : elist) {
              if (pt.getContent() instanceof XSDElementDeclaration) {
                XSDTypeDefinition typeDef=((XSDElementDeclaration)pt.getContent()).getTypeDefinition();
                if (typeDef != null && typeDef.getName() != null) {
                  if ((localName.equals(typeDef.getName()))) {
                    return true;
                  }
                }
              }
            }
          }
        }
      }
 else       if (typedef instanceof XSDSimpleTypeDefinition) {
        XSDSimpleTypeDefinition type=(XSDSimpleTypeDefinition)typedef;
        XSDSimpleTypeDefinition baseType=type.getBaseTypeDefinition();
        if (baseType != null && baseType.getName().equals(localName))         return true;
      }
    }
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Find elementDeclarations that use any types derived from a named type. <p> This shows one way to query the schema for elementDeclarations and then how to find specific kinds of typeDefinitions. </p>
 * @param objList collection set to search for elemDecls
 * @param localName for the type used
 * @return Boolean  indicate any XSDElementDeclarations is found or not
 */
public static boolean findElementsUsingType(ArrayList<Object> objList,XSDTypeDefinition localTypedef){
  for (Iterator<Object> iter=objList.iterator(); iter.hasNext(); ) {
    Object obj=iter.next();
    if (obj == localTypedef)     continue;
    if (obj instanceof XSDElementDeclaration || obj instanceof XSDTypeDefinition) {
      XSDTypeDefinition typedef=null;
      if (obj instanceof XSDElementDeclaration) {
        XSDElementDeclaration elem=(XSDElementDeclaration)obj;
        if (elem.getAnonymousTypeDefinition() != null) {
          typedef=elem.getAnonymousTypeDefinition();
        }
 else         if (elem.getTypeDefinition() != null) {
          typedef=elem.getTypeDefinition();
        }
 else {
          continue;
        }
      }
 else {
        typedef=(XSDTypeDefinition)obj;
      }
      if (typedef instanceof XSDComplexTypeDefinition) {
        XSDComplexTypeDefinition type=(XSDComplexTypeDefinition)typedef;
        if (type.getName().equals(localTypedef.getName()) && (localTypedef instanceof XSDComplexTypeDefinition)) {
          return true;
        }
        if (type.getContent() instanceof XSDParticle) {
          XSDParticle particle=(XSDParticle)type.getContent();
          if (particle.getTerm() instanceof XSDModelGroup) {
            XSDModelGroup group=(XSDModelGroup)particle.getTerm();
            EList<XSDParticle> elist=group.getContents();
            for (            XSDParticle pt : elist) {
              if (pt.getContent() instanceof XSDElementDeclaration) {
                XSDTypeDefinition typeDef=((XSDElementDeclaration)pt.getContent()).getTypeDefinition();
                if (typeDef != null && typeDef.getName() != null) {
                  if ((localTypedef.getName().equals(typeDef.getName()))) {
                    return true;
                  }
                }
              }
            }
          }
        }
      }
 else       if (typedef instanceof XSDSimpleTypeDefinition) {
        XSDSimpleTypeDefinition type=(XSDSimpleTypeDefinition)typedef;
        XSDSimpleTypeDefinition baseType=type.getBaseTypeDefinition();
        if (baseType != null && baseType.getName().equals(localTypedef.getName()))         return true;
      }
    }
  }
  return false;
}