Program: 73397
Project: 73397
Buggy source:
/** 
 * Return a string describing how many actors, parameters, ports, and relations are in this CompositeEntity. Entities whose instantiation is deferred are not included.
 * @param className If non-null and non-empty, then alsoinclude the number of objects with the give name.
 * @return a string describing the number of components.
 * @exception IllegalActionException If the class named byactorClassName cannot be found.
 */
public String statistics(String className) throws IllegalActionException {
  try {
    _workspace.getReadAccess();
    Class clazz=null;
    try {
      if (className != null && className.length() > 0) {
        clazz=Class.forName(className);
      }
    }
 catch (    Exception ex) {
      throw new IllegalActionException(null,ex,"String_Node_Str" + className + "String_Node_Str");
    }
    List atomicEntities=lazyAllAtomicEntityList();
    int entityCount=atomicEntities.size();
    Map<String,Integer> actorMap=new HashMap<String,Integer>();
    Integer one=new Integer(1);
    int attributeCount=0, entityClassCount=0;
    Iterator entities=atomicEntities.iterator();
    while (entities.hasNext()) {
      ComponentEntity entity=(ComponentEntity)entities.next();
      List attributeList=entity.attributeList();
      attributeCount+=attributeList.size();
      Class entityClass=entity.getClass();
      String entityClassName=entityClass.getName();
      if (!actorMap.containsKey(entityClassName)) {
        actorMap.put(entityClassName,one);
      }
 else {
        actorMap.put(entityClassName,Integer.valueOf(actorMap.get(entityClassName) + 1));
      }
      if (clazz != null) {
        if (clazz.isAssignableFrom(entityClass)) {
          entityClassCount++;
        }
 else {
          Iterator attributes=attributeList.iterator();
          while (attributes.hasNext()) {
            Attribute attribute=(Attribute)attributes.next();
            if (clazz.isAssignableFrom(attribute.getClass())) {
              entityClassCount++;
            }
          }
        }
      }
    }
    ArrayList actorArrayList=new ArrayList(actorMap.entrySet());
    Collections.sort(actorArrayList,new CountComparator());
    StringBuffer actorNames=new StringBuffer();
    Iterator actors=actorArrayList.iterator();
    while (actors.hasNext()) {
      Map.Entry<String,Integer> actor=(Map.Entry)actors.next();
      actorNames.append(actor.getKey() + "String_Node_Str" + actor.getValue()+ "String_Node_Str");
    }
    int compositeEntityCount=0;
    int opaqueCompositeEntityCount=0;
    List relationList=lazyRelationList();
    int relationCount=relationList.size();
    if (clazz != null) {
      Iterator relations=relationList.iterator();
      while (relations.hasNext()) {
        Relation relation=(Relation)relations.next();
        if (clazz.isAssignableFrom(relation.getClass())) {
          entityClassCount++;
        }
      }
    }
    Map<Integer,Integer> compositeEntityDepthMap=new TreeMap<Integer,Integer>();
    entities=lazyAllCompositeTransparentAndOpaqueEntityList().iterator();
    while (entities.hasNext()) {
      Entity entity=(Entity)entities.next();
      if (entity instanceof CompositeEntity) {
        compositeEntityCount++;
        if (((CompositeEntity)entity).isOpaque()) {
          opaqueCompositeEntityCount++;
        }
        Integer depth=Integer.valueOf(entity.depthInHierarchy());
        if (!compositeEntityDepthMap.containsKey(depth)) {
          compositeEntityDepthMap.put(depth,one);
        }
 else {
          compositeEntityDepthMap.put(depth,Integer.valueOf(compositeEntityDepthMap.get(depth) + 1));
        }
        relationList=((CompositeEntity)entity).lazyRelationList();
        relationCount+=relationList.size();
        if (clazz != null) {
          if (clazz.isAssignableFrom(entity.getClass())) {
            entityClassCount++;
          }
 else {
            Iterator relations=relationList.iterator();
            while (relations.hasNext()) {
              Relation relation=(Relation)relations.next();
              if (clazz.isAssignableFrom(relation.getClass())) {
                entityClassCount++;
              }
            }
          }
        }
      }
    }
    StringBuffer compositeEntityDepths=new StringBuffer();
    for (    Map.Entry<Integer,Integer> depth : compositeEntityDepthMap.entrySet()) {
      compositeEntityDepths.append("String_Node_Str" + depth.getKey() + "String_Node_Str"+ depth.getValue()+ "String_Node_Str");
    }
    return "String_Node_Str" + getFullName() + "String_Node_Str"+ entityCount+ "String_Node_Str"+ compositeEntityCount+ "String_Node_Str"+ opaqueCompositeEntityCount+ "String_Node_Str"+ relationCount+ "String_Node_Str"+ attributeCount+ (clazz == null ? "String_Node_Str" : "String_Node_Str" + clazz.getName() + "String_Node_Str"+ entityClassCount)+ "String_Node_Str"+ actorNames+ "String_Node_Str"+ compositeEntityDepths;
  }
  finally {
    _workspace.doneReading();
  }
}

Fixed version (ground truth):
/** 
 * Return a string describing how many actors, parameters, ports, and relations are in this CompositeEntity. Entities whose instantiation is deferred are not included.
 * @param className If non-null and non-empty, then alsoinclude the number of objects with the give name.
 * @return a string describing the number of components.
 * @exception IllegalActionException If the class named byactorClassName cannot be found.
 */
public String statistics(String className) throws IllegalActionException {
  try {
    _workspace.getReadAccess();
    Class clazz=null;
    try {
      if (className != null && className.length() > 0) {
        clazz=Class.forName(className);
      }
    }
 catch (    Exception ex) {
      throw new IllegalActionException(null,ex,"String_Node_Str" + className + "String_Node_Str");
    }
    List atomicEntities=lazyAllAtomicEntityList();
    int entityCount=atomicEntities.size();
    Map<String,Integer> actorMap=new HashMap<String,Integer>();
    Integer one=Integer.valueOf(1);
    int attributeCount=0, entityClassCount=0;
    Iterator entities=atomicEntities.iterator();
    while (entities.hasNext()) {
      ComponentEntity entity=(ComponentEntity)entities.next();
      List attributeList=entity.attributeList();
      attributeCount+=attributeList.size();
      Class entityClass=entity.getClass();
      String entityClassName=entityClass.getName();
      if (!actorMap.containsKey(entityClassName)) {
        actorMap.put(entityClassName,one);
      }
 else {
        actorMap.put(entityClassName,Integer.valueOf(actorMap.get(entityClassName) + 1));
      }
      if (clazz != null) {
        if (clazz.isAssignableFrom(entityClass)) {
          entityClassCount++;
        }
 else {
          Iterator attributes=attributeList.iterator();
          while (attributes.hasNext()) {
            Attribute attribute=(Attribute)attributes.next();
            if (clazz.isAssignableFrom(attribute.getClass())) {
              entityClassCount++;
            }
          }
        }
      }
    }
    ArrayList actorArrayList=new ArrayList(actorMap.entrySet());
    Collections.sort(actorArrayList,new CountComparator());
    StringBuffer actorNames=new StringBuffer();
    Iterator actors=actorArrayList.iterator();
    while (actors.hasNext()) {
      Map.Entry<String,Integer> actor=(Map.Entry)actors.next();
      actorNames.append(actor.getKey() + "String_Node_Str" + actor.getValue()+ "String_Node_Str");
    }
    int compositeEntityCount=0;
    int opaqueCompositeEntityCount=0;
    List relationList=lazyRelationList();
    int relationCount=relationList.size();
    if (clazz != null) {
      Iterator relations=relationList.iterator();
      while (relations.hasNext()) {
        Relation relation=(Relation)relations.next();
        if (clazz.isAssignableFrom(relation.getClass())) {
          entityClassCount++;
        }
      }
    }
    Map<Integer,Integer> compositeEntityDepthMap=new TreeMap<Integer,Integer>();
    entities=lazyAllCompositeTransparentAndOpaqueEntityList().iterator();
    while (entities.hasNext()) {
      Entity entity=(Entity)entities.next();
      if (entity instanceof CompositeEntity) {
        compositeEntityCount++;
        if (((CompositeEntity)entity).isOpaque()) {
          opaqueCompositeEntityCount++;
        }
        Integer depth=Integer.valueOf(entity.depthInHierarchy());
        if (!compositeEntityDepthMap.containsKey(depth)) {
          compositeEntityDepthMap.put(depth,one);
        }
 else {
          compositeEntityDepthMap.put(depth,Integer.valueOf(compositeEntityDepthMap.get(depth) + 1));
        }
        relationList=((CompositeEntity)entity).lazyRelationList();
        relationCount+=relationList.size();
        if (clazz != null) {
          if (clazz.isAssignableFrom(entity.getClass())) {
            entityClassCount++;
          }
 else {
            Iterator relations=relationList.iterator();
            while (relations.hasNext()) {
              Relation relation=(Relation)relations.next();
              if (clazz.isAssignableFrom(relation.getClass())) {
                entityClassCount++;
              }
            }
          }
        }
      }
    }
    StringBuffer compositeEntityDepths=new StringBuffer();
    for (    Map.Entry<Integer,Integer> depth : compositeEntityDepthMap.entrySet()) {
      compositeEntityDepths.append("String_Node_Str" + depth.getKey() + "String_Node_Str"+ depth.getValue()+ "String_Node_Str");
    }
    return "String_Node_Str" + getFullName() + "String_Node_Str"+ entityCount+ "String_Node_Str"+ compositeEntityCount+ "String_Node_Str"+ opaqueCompositeEntityCount+ "String_Node_Str"+ relationCount+ "String_Node_Str"+ attributeCount+ (clazz == null ? "String_Node_Str" : "String_Node_Str" + clazz.getName() + "String_Node_Str"+ entityClassCount)+ "String_Node_Str"+ actorNames+ "String_Node_Str"+ compositeEntityDepths;
  }
  finally {
    _workspace.doneReading();
  }
}