Program: 76288
Project: 76288
Buggy source:
/** 
 * Start an element. This is called at the beginning of each XML element.  By the time it is called, all of the attributes for the element will already have been reported using the attribute() method.  Unrecognized elements are ignored.
 * @param elementName The element type name.
 * @exception XmlException If the element produces an errorin constructing the model.
 */
public void startElement(String elementName) throws XmlException {
  _currentElement=elementName;
  try {
    if (elementName.equals("String_Node_Str")) {
      String propertyName=(String)_attributes.get("String_Node_Str");
      _checkForNull(propertyName,"String_Node_Str");
      String value=(String)_attributes.get("String_Node_Str");
      _checkClass(_current,NamedObj.class,"String_Node_Str" + "String_Node_Str" + _current);
      Object property=(Attribute)((NamedObj)_current).getAttribute(propertyName);
      String className=(String)_attributes.get("String_Node_Str");
      Class newClass=null;
      if (className != null) {
        newClass=Class.forName(className);
      }
      if (property == null) {
        _checkForNull(newClass,"String_Node_Str");
        Object[] arguments=new Object[2];
        arguments[0]=_current;
        arguments[1]=propertyName;
        property=_createInstance(newClass,arguments);
        if (value != null) {
          if (!(property instanceof Variable)) {
            throw new XmlException("String_Node_Str" + "String_Node_Str",_currentExternalEntity(),_parser.getLineNumber(),_parser.getColumnNumber());
          }
          ((Variable)property).setExpression(value);
        }
      }
 else {
        if (newClass != null) {
          _checkClass(property,newClass,"String_Node_Str" + propertyName + "String_Node_Str"+ className);
        }
        if (value != null) {
          _checkClass(property,Variable.class,"String_Node_Str" + propertyName + "String_Node_Str"+ "String_Node_Str");
          ((Variable)property).setExpression(value);
        }
      }
      _containers.push(_current);
      _current=property;
    }
 else     if (elementName.equals("String_Node_Str")) {
      String className=(String)_attributes.get("String_Node_Str");
      _checkForNull(className,"String_Node_Str");
      String entityName=(String)_attributes.get("String_Node_Str");
      _checkForNull(entityName,"String_Node_Str");
      NamedObj newEntity;
      if (_current != null) {
        _checkClass(_current,CompositeEntity.class,"String_Node_Str" + "String_Node_Str" + _current);
        _containers.push(_current);
        newEntity=_createEntity(className,entityName);
      }
 else {
        newEntity=_createEntity(className,entityName);
        _toplevel=newEntity;
      }
      newEntity.setMoMLElementName("String_Node_Str");
      _current=newEntity;
    }
 else     if (elementName.equals("String_Node_Str")) {
      String source=(String)_attributes.get("String_Node_Str");
      _checkClass(_current,Configurable.class,"String_Node_Str" + "String_Node_Str" + _current);
      if (source != null) {
        URL xmlFile=new URL(_base,source);
        InputStream stream=xmlFile.openStream();
        ((Configurable)_current).configure(_base,stream);
      }
      _currentCharData=new StringBuffer();
    }
 else     if (elementName.equals("String_Node_Str")) {
      String className=(String)_attributes.get("String_Node_Str");
      _checkForNull(className,"String_Node_Str");
      String dirName=(String)_attributes.get("String_Node_Str");
      _checkForNull(dirName,"String_Node_Str");
      _checkClass(_current,CompositeActor.class,"String_Node_Str" + "String_Node_Str" + _current);
      Object[] arguments=new Object[2];
      arguments[0]=_current;
      arguments[1]=dirName;
      _containers.push(_current);
      Class newClass=Class.forName(className);
      _current=_createInstance(newClass,arguments);
    }
 else     if (elementName.equals("String_Node_Str")) {
      _currentCharData=new StringBuffer();
    }
 else     if (elementName.equals("String_Node_Str")) {
      String className=(String)_attributes.get("String_Node_Str");
      String entityName=(String)_attributes.get("String_Node_Str");
      _checkForNull(entityName,"String_Node_Str");
      _checkClass(_current,CompositeEntity.class,"String_Node_Str" + "String_Node_Str" + _current);
      NamedObj newEntity=_createEntity(className,entityName);
      if (_panel != null && newEntity instanceof Placeable) {
        ((Placeable)newEntity).place(_panel);
      }
      _containers.push(_current);
      _current=newEntity;
    }
 else     if (elementName.equals("String_Node_Str")) {
      String source=(String)_attributes.get("String_Node_Str");
      _checkForNull(source,"String_Node_Str");
      String baseSpec=(String)_attributes.get("String_Node_Str");
      URL base=_base;
      if (baseSpec != null) {
        base=new URL(_base,baseSpec);
      }
      MoMLParser newParser=new MoMLParser(_workspace);
      URL xmlFile=new URL(base,source);
      NamedObj reference=newParser.parse(base,xmlFile.openStream());
      if (_imports == null) {
        _imports=new LinkedList();
      }
      _imports.add(0,reference);
      if (_current instanceof NamedObj) {
        NamedObj container=(NamedObj)_current;
        Import attr=new Import(container,container.uniqueName("String_Node_Str"));
        attr.setSource(source);
        attr.setBase(_base);
      }
    }
 else     if (elementName.equals("String_Node_Str")) {
      String portName=(String)_attributes.get("String_Node_Str");
      _checkForNull(portName,"String_Node_Str");
      String relationName=(String)_attributes.get("String_Node_Str");
      _checkForNull(relationName,"String_Node_Str");
      _checkClass(_current,CompositeEntity.class,"String_Node_Str" + "String_Node_Str" + _current);
      CompositeEntity context=(CompositeEntity)_current;
      ComponentPort port=_getPort(portName,context);
      Relation tmpRelation=context.getRelation(relationName);
      _checkForNull(tmpRelation,"String_Node_Str" + relationName + "String_Node_Str"+ context.getFullName());
      ComponentRelation relation=(ComponentRelation)tmpRelation;
      port.link(relation);
    }
 else     if (elementName.equals("String_Node_Str")) {
      String xSpec=(String)_attributes.get("String_Node_Str");
      String ySpec=(String)_attributes.get("String_Node_Str");
      String zSpec=(String)_attributes.get("String_Node_Str");
      _checkForNull(xSpec,"String_Node_Str");
      _checkClass(_current,Locatable.class,"String_Node_Str" + "String_Node_Str" + _current);
      double x=Double.parseDouble(xSpec);
      if (ySpec != null) {
        double y=Double.parseDouble(ySpec);
        if (zSpec != null) {
          double z=Double.parseDouble(zSpec);
          double[] location={x,y,z};
          ((Locatable)_current).setLocation(location);
        }
 else {
          double[] location={x,y};
          ((Locatable)_current).setLocation(location);
        }
      }
 else {
        double[] location={x};
        ((Locatable)_current).setLocation(location);
      }
    }
 else     if (elementName.equals("String_Node_Str")) {
      String className=(String)_attributes.get("String_Node_Str");
      _checkForNull(className,"String_Node_Str");
      String modelName=(String)_attributes.get("String_Node_Str");
      _checkForNull(modelName,"String_Node_Str");
      Object[] arguments=new Object[1];
      arguments[0]=_workspace;
      Class newClass=Class.forName(className);
      _toplevel=(NamedObj)_createInstance(newClass,arguments);
      _toplevel.setName(modelName);
      _toplevel.setMoMLElementName("String_Node_Str");
      _current=_toplevel;
    }
 else     if (elementName.equals("String_Node_Str")) {
      String className=(String)_attributes.get("String_Node_Str");
      String portName=(String)_attributes.get("String_Node_Str");
      _checkForNull(portName,"String_Node_Str");
      _checkClass(_current,Entity.class,"String_Node_Str" + "String_Node_Str" + _current);
      Entity container=(Entity)_current;
      Class newClass=null;
      if (className != null) {
        newClass=Class.forName(className);
      }
      Port port=container.getPort(portName);
      if (port != null) {
        if (newClass != null) {
          _checkClass(port,newClass,"String_Node_Str" + portName + "String_Node_Str"+ className);
        }
      }
 else {
        _checkForNull(className,"String_Node_Str");
        Object[] arguments=new Object[2];
        arguments[0]=container;
        arguments[1]=portName;
        port=(Port)_createInstance(newClass,arguments);
      }
      _containers.push(_current);
      _current=port;
      if (port instanceof IOPort) {
        String direction=(String)_attributes.get("String_Node_Str");
        if (direction != null) {
          IOPort ioport=(IOPort)port;
          ioport.setOutput(direction.equals("String_Node_Str") || direction.equals("String_Node_Str"));
          ioport.setInput(direction.equals("String_Node_Str") || direction.equals("String_Node_Str"));
        }
      }
    }
 else     if (elementName.equals("String_Node_Str")) {
      String className=(String)_attributes.get("String_Node_Str");
      String relationName=(String)_attributes.get("String_Node_Str");
      _checkForNull(relationName,"String_Node_Str");
      _checkClass(_current,CompositeEntity.class,"String_Node_Str" + "String_Node_Str" + _current);
      CompositeEntity container=(CompositeEntity)_current;
      Class newClass=null;
      if (className != null) {
        newClass=Class.forName(className);
      }
      Relation relation=container.getRelation(relationName);
      if (relation == null) {
        _checkForNull(newClass,"String_Node_Str");
        Object[] arguments=new Object[2];
        arguments[0]=(CompositeEntity)_current;
        arguments[1]=relationName;
        _containers.push(_current);
        _current=_createInstance(newClass,arguments);
      }
 else {
        if (newClass != null) {
          _checkClass(relation,newClass,"String_Node_Str" + relationName + "String_Node_Str"+ className);
        }
        _containers.push(_current);
        _current=relation;
      }
    }
 else     if (elementName.equals("String_Node_Str")) {
      String className=(String)_attributes.get("String_Node_Str");
      _checkForNull(className,"String_Node_Str");
      _checkClass(_current,NamedObj.class,"String_Node_Str" + "String_Node_Str" + _current);
      Object[] arguments=new Object[2];
      arguments[0]=(NamedObj)_current;
      arguments[1]="String_Node_Str";
      _containers.push(_current);
      Class newClass=Class.forName(className);
      _current=_createInstance(newClass,arguments);
    }
 else     if (elementName.equals("String_Node_Str")) {
      String vertexName=(String)_attributes.get("String_Node_Str");
      _checkForNull(vertexName,"String_Node_Str");
      _checkClass(_current,Relation.class,"String_Node_Str" + "String_Node_Str" + _current);
      Vertex vertex=new Vertex((Relation)_current,vertexName);
      _containers.push(_current);
      _current=vertex;
    }
  }
 catch (  InvocationTargetException ex) {
    String msg="String_Node_Str" + elementName + "String_Node_Str"+ ex.getTargetException().toString();
    throw new XmlException(msg,_currentExternalEntity(),_parser.getLineNumber(),_parser.getColumnNumber());
  }
catch (  Exception ex) {
    if (ex instanceof XmlException) {
      throw (XmlException)ex;
    }
 else {
      String msg="String_Node_Str" + elementName + "String_Node_Str"+ ex.toString();
      System.err.println("String_Node_Str");
      ex.printStackTrace();
      throw new XmlException(msg,_currentExternalEntity(),_parser.getLineNumber(),_parser.getColumnNumber());
    }
  }
  _attributes.clear();
}

Fixed version (ground truth):
/** 
 * Start an element. This is called at the beginning of each XML element.  By the time it is called, all of the attributes for the element will already have been reported using the attribute() method.  Unrecognized elements are ignored.
 * @param elementName The element type name.
 * @exception XmlException If the element produces an errorin constructing the model.
 */
public void startElement(String elementName) throws XmlException {
  _currentElement=elementName;
  try {
    if (elementName.equals("String_Node_Str")) {
      String propertyName=(String)_attributes.get("String_Node_Str");
      _checkForNull(propertyName,"String_Node_Str");
      String value=(String)_attributes.get("String_Node_Str");
      _checkClass(_current,NamedObj.class,"String_Node_Str" + "String_Node_Str" + _current);
      Object property=(Attribute)((NamedObj)_current).getAttribute(propertyName);
      String className=(String)_attributes.get("String_Node_Str");
      Class newClass=null;
      if (className != null) {
        newClass=Class.forName(className);
      }
      if (property == null) {
        _checkForNull(newClass,"String_Node_Str");
        Object[] arguments=new Object[2];
        arguments[0]=_current;
        arguments[1]=propertyName;
        property=_createInstance(newClass,arguments);
        if (value != null) {
          if (!(property instanceof Variable)) {
            throw new XmlException("String_Node_Str" + "String_Node_Str",_currentExternalEntity(),_parser.getLineNumber(),_parser.getColumnNumber());
          }
          ((Variable)property).setExpression(value);
        }
      }
 else {
        if (newClass != null) {
          _checkClass(property,newClass,"String_Node_Str" + propertyName + "String_Node_Str"+ className);
        }
        if (value != null) {
          _checkClass(property,Variable.class,"String_Node_Str" + propertyName + "String_Node_Str"+ "String_Node_Str");
          ((Variable)property).setExpression(value);
        }
      }
      _containers.push(_current);
      _current=property;
    }
 else     if (elementName.equals("String_Node_Str")) {
      String className=(String)_attributes.get("String_Node_Str");
      _checkForNull(className,"String_Node_Str");
      String entityName=(String)_attributes.get("String_Node_Str");
      _checkForNull(entityName,"String_Node_Str");
      NamedObj newEntity;
      if (_current != null) {
        _checkClass(_current,CompositeEntity.class,"String_Node_Str" + "String_Node_Str" + _current);
        _containers.push(_current);
        newEntity=_createEntity(className,entityName);
      }
 else {
        newEntity=_createEntity(className,entityName);
        _toplevel=newEntity;
      }
      newEntity.setMoMLElementName("String_Node_Str");
      _current=newEntity;
    }
 else     if (elementName.equals("String_Node_Str")) {
      String source=(String)_attributes.get("String_Node_Str");
      _checkClass(_current,Configurable.class,"String_Node_Str" + "String_Node_Str" + _current);
      if (source != null) {
        URL xmlFile=new URL(_base,source);
        InputStream stream=xmlFile.openStream();
        ((Configurable)_current).configure(_base,stream);
      }
      _currentCharData=new StringBuffer();
    }
 else     if (elementName.equals("String_Node_Str")) {
      String className=(String)_attributes.get("String_Node_Str");
      _checkForNull(className,"String_Node_Str");
      String dirName=(String)_attributes.get("String_Node_Str");
      _checkForNull(dirName,"String_Node_Str");
      _checkClass(_current,CompositeActor.class,"String_Node_Str" + "String_Node_Str" + _current);
      Object[] arguments=new Object[2];
      arguments[0]=_current;
      arguments[1]=dirName;
      _containers.push(_current);
      Class newClass=Class.forName(className);
      _current=_createInstance(newClass,arguments);
    }
 else     if (elementName.equals("String_Node_Str")) {
      _currentCharData=new StringBuffer();
    }
 else     if (elementName.equals("String_Node_Str")) {
      String className=(String)_attributes.get("String_Node_Str");
      String entityName=(String)_attributes.get("String_Node_Str");
      _checkForNull(entityName,"String_Node_Str");
      _checkClass(_current,CompositeEntity.class,"String_Node_Str" + "String_Node_Str" + _current);
      NamedObj newEntity=_createEntity(className,entityName);
      if (_panel != null && newEntity instanceof Placeable) {
        ((Placeable)newEntity).place(_panel);
      }
      _containers.push(_current);
      _current=newEntity;
    }
 else     if (elementName.equals("String_Node_Str")) {
      String source=(String)_attributes.get("String_Node_Str");
      _checkForNull(source,"String_Node_Str");
      String baseSpec=(String)_attributes.get("String_Node_Str");
      URL base=_base;
      if (baseSpec != null) {
        base=new URL(_base,baseSpec);
      }
      MoMLParser newParser=new MoMLParser(_workspace);
      URL xmlFile=new URL(base,source);
      NamedObj reference=newParser.parse(xmlFile,xmlFile.openStream());
      if (_imports == null) {
        _imports=new LinkedList();
      }
      _imports.add(0,reference);
      if (_current instanceof NamedObj) {
        NamedObj container=(NamedObj)_current;
        Import attr=new Import(container,container.uniqueName("String_Node_Str"));
        attr.setSource(source);
        attr.setBase(_base);
      }
    }
 else     if (elementName.equals("String_Node_Str")) {
      String portName=(String)_attributes.get("String_Node_Str");
      _checkForNull(portName,"String_Node_Str");
      String relationName=(String)_attributes.get("String_Node_Str");
      _checkForNull(relationName,"String_Node_Str");
      _checkClass(_current,CompositeEntity.class,"String_Node_Str" + "String_Node_Str" + _current);
      CompositeEntity context=(CompositeEntity)_current;
      ComponentPort port=_getPort(portName,context);
      Relation tmpRelation=context.getRelation(relationName);
      _checkForNull(tmpRelation,"String_Node_Str" + relationName + "String_Node_Str"+ context.getFullName());
      ComponentRelation relation=(ComponentRelation)tmpRelation;
      port.link(relation);
    }
 else     if (elementName.equals("String_Node_Str")) {
      String xSpec=(String)_attributes.get("String_Node_Str");
      String ySpec=(String)_attributes.get("String_Node_Str");
      String zSpec=(String)_attributes.get("String_Node_Str");
      _checkForNull(xSpec,"String_Node_Str");
      _checkClass(_current,Locatable.class,"String_Node_Str" + "String_Node_Str" + _current);
      double x=Double.parseDouble(xSpec);
      if (ySpec != null) {
        double y=Double.parseDouble(ySpec);
        if (zSpec != null) {
          double z=Double.parseDouble(zSpec);
          double[] location={x,y,z};
          ((Locatable)_current).setLocation(location);
        }
 else {
          double[] location={x,y};
          ((Locatable)_current).setLocation(location);
        }
      }
 else {
        double[] location={x};
        ((Locatable)_current).setLocation(location);
      }
    }
 else     if (elementName.equals("String_Node_Str")) {
      String className=(String)_attributes.get("String_Node_Str");
      _checkForNull(className,"String_Node_Str");
      String modelName=(String)_attributes.get("String_Node_Str");
      _checkForNull(modelName,"String_Node_Str");
      Object[] arguments=new Object[1];
      arguments[0]=_workspace;
      Class newClass=Class.forName(className);
      _toplevel=(NamedObj)_createInstance(newClass,arguments);
      _toplevel.setName(modelName);
      _toplevel.setMoMLElementName("String_Node_Str");
      _current=_toplevel;
    }
 else     if (elementName.equals("String_Node_Str")) {
      String className=(String)_attributes.get("String_Node_Str");
      String portName=(String)_attributes.get("String_Node_Str");
      _checkForNull(portName,"String_Node_Str");
      _checkClass(_current,Entity.class,"String_Node_Str" + "String_Node_Str" + _current);
      Entity container=(Entity)_current;
      Class newClass=null;
      if (className != null) {
        newClass=Class.forName(className);
      }
      Port port=container.getPort(portName);
      if (port != null) {
        if (newClass != null) {
          _checkClass(port,newClass,"String_Node_Str" + portName + "String_Node_Str"+ className);
        }
      }
 else {
        _checkForNull(className,"String_Node_Str");
        Object[] arguments=new Object[2];
        arguments[0]=container;
        arguments[1]=portName;
        port=(Port)_createInstance(newClass,arguments);
      }
      _containers.push(_current);
      _current=port;
      if (port instanceof IOPort) {
        String direction=(String)_attributes.get("String_Node_Str");
        if (direction != null) {
          IOPort ioport=(IOPort)port;
          ioport.setOutput(direction.equals("String_Node_Str") || direction.equals("String_Node_Str"));
          ioport.setInput(direction.equals("String_Node_Str") || direction.equals("String_Node_Str"));
        }
      }
    }
 else     if (elementName.equals("String_Node_Str")) {
      String className=(String)_attributes.get("String_Node_Str");
      String relationName=(String)_attributes.get("String_Node_Str");
      _checkForNull(relationName,"String_Node_Str");
      _checkClass(_current,CompositeEntity.class,"String_Node_Str" + "String_Node_Str" + _current);
      CompositeEntity container=(CompositeEntity)_current;
      Class newClass=null;
      if (className != null) {
        newClass=Class.forName(className);
      }
      Relation relation=container.getRelation(relationName);
      if (relation == null) {
        _checkForNull(newClass,"String_Node_Str");
        Object[] arguments=new Object[2];
        arguments[0]=(CompositeEntity)_current;
        arguments[1]=relationName;
        _containers.push(_current);
        _current=_createInstance(newClass,arguments);
      }
 else {
        if (newClass != null) {
          _checkClass(relation,newClass,"String_Node_Str" + relationName + "String_Node_Str"+ className);
        }
        _containers.push(_current);
        _current=relation;
      }
    }
 else     if (elementName.equals("String_Node_Str")) {
      String className=(String)_attributes.get("String_Node_Str");
      _checkForNull(className,"String_Node_Str");
      _checkClass(_current,NamedObj.class,"String_Node_Str" + "String_Node_Str" + _current);
      Object[] arguments=new Object[2];
      arguments[0]=(NamedObj)_current;
      arguments[1]="String_Node_Str";
      _containers.push(_current);
      Class newClass=Class.forName(className);
      _current=_createInstance(newClass,arguments);
    }
 else     if (elementName.equals("String_Node_Str")) {
      String vertexName=(String)_attributes.get("String_Node_Str");
      _checkForNull(vertexName,"String_Node_Str");
      _checkClass(_current,Relation.class,"String_Node_Str" + "String_Node_Str" + _current);
      Vertex vertex=new Vertex((Relation)_current,vertexName);
      _containers.push(_current);
      _current=vertex;
    }
  }
 catch (  InvocationTargetException ex) {
    String msg="String_Node_Str" + elementName + "String_Node_Str"+ ex.getTargetException().toString();
    throw new XmlException(msg,_currentExternalEntity(),_parser.getLineNumber(),_parser.getColumnNumber());
  }
catch (  Exception ex) {
    if (ex instanceof XmlException) {
      throw (XmlException)ex;
    }
 else {
      String msg="String_Node_Str" + elementName + "String_Node_Str"+ ex.toString();
      System.err.println("String_Node_Str");
      ex.printStackTrace();
      throw new XmlException(msg,_currentExternalEntity(),_parser.getLineNumber(),_parser.getColumnNumber());
    }
  }
  _attributes.clear();
}