nus-yam/ex-repair huggingface dataset:
Program: 75282
Project: 75282
Buggy source:
/** 
 * This method, which is required by the ImageObserver interface, is called if something has changed in a background loading of the image.
 * @param image The image being observed.
 * @param infoflags The bitwise inclusive OR of the following flags:WIDTH, HEIGHT, PROPERTIES, SOMEBITS, FRAMEBITS, ALLBITS, ERROR, ABORT.
 * @param x The x coordinate of the image.
 * @param y The y coordinate of the image.
 * @param width The width of the image.
 * @param height The height of the image.
 * @return False if the infoflags indicate that the image iscompletely loaded; true otherwise.
 */
public boolean imageUpdate(Image image,int infoflags,int x,int y,int width,int height){
  if (((infoflags | ImageObserver.WIDTH) != 0) || ((infoflags | ImageObserver.HEIGHT) != 0)) {
    scaleImage(_scalePercentage);
    return false;
  }
  if (((infoflags | ImageObserver.ERROR) != 0) || ((infoflags | ImageObserver.ABORT) != 0)) {
    return false;
  }
  Runnable doRepaint=new Runnable(){
    public void run(){
      Iterator figures=_liveFigureIterator();
      while (figures.hasNext()) {
        Object figure=figures.next();
        ((ImageFigure)figure).repaint();
      }
    }
  }
;
  SwingUtilities.invokeLater(doRepaint);
  return true;
}

Fixed version (ground truth):
/** 
 * This method, which is required by the ImageObserver interface, is called if something has changed in a background loading of the image.
 * @param image The image being observed.
 * @param infoflags The bitwise inclusive OR of the following flags:WIDTH, HEIGHT, PROPERTIES, SOMEBITS, FRAMEBITS, ALLBITS, ERROR, ABORT.
 * @param x The x coordinate of the image.
 * @param y The y coordinate of the image.
 * @param width The width of the image.
 * @param height The height of the image.
 * @return False if the infoflags indicate that the image iscompletely loaded; true otherwise.
 */
public boolean imageUpdate(Image image,int infoflags,int x,int y,int width,int height){
  if ((infoflags & (ImageObserver.HEIGHT | ImageObserver.WIDTH)) != 0) {
    _height=height;
    _width=width;
    _image.getWidth(this);
    _image.getHeight(this);
    return true;
  }
  if ((infoflags & ImageObserver.ALLBITS) != 0) {
    scaleImage(_scalePercentage);
    requestChange(new MoMLChangeRequest(this,this,"String_Node_Str"));
    Runnable doRepaint=new Runnable(){
      public void run(){
        Iterator figures=_liveFigureIterator();
        while (figures.hasNext()) {
          Object figure=figures.next();
          ((ImageFigure)figure).repaint();
        }
      }
    }
;
    SwingUtilities.invokeLater(doRepaint);
    return false;
  }
  if ((infoflags & (ImageObserver.ERROR | ImageObserver.ABORT)) != 0) {
    return false;
  }
  _image.getWidth(this);
  _image.getHeight(this);
  return true;
}
Program: 75283
Project: 75283
Buggy source:
/** 
 * Specify a scaling for the image as a percentage.
 * @param percentage The scaling percentage.
 */
public void scaleImage(double percentage){
  _scalePercentage=percentage;
  Runnable doScale=new Runnable(){
    public void run(){
      if (_image == null) {
        return;
      }
      int width=_image.getWidth(ImageIcon.this);
      int height=_image.getHeight(ImageIcon.this);
      if (width > 0 && height > 0) {
        int newWidth=(int)Math.round(width * _scalePercentage / 100.0);
        int newHeight=(int)Math.round(height * _scalePercentage / 100.0);
        _scaledImage=_image.getScaledInstance(newWidth,newHeight,Image.SCALE_SMOOTH);
        Iterator figures=_liveFigureIterator();
        while (figures.hasNext()) {
          Object figure=figures.next();
          ((ImageFigure)figure).setCentered(false);
          ((ImageFigure)figure).setImage(_scaledImage);
        }
      }
    }
  }
;
  SwingUtilities.invokeLater(doScale);
}

Fixed version (ground truth):
/** 
 * Specify a scaling for the image as a percentage.
 * @param percentage The scaling percentage.
 */
public void scaleImage(double percentage){
  if (percentage == _scalePercentage) {
    return;
  }
  _scalePercentage=percentage;
  Runnable doScale=new Runnable(){
    public void run(){
      if (_image == null) {
        return;
      }
      int width=_image.getWidth(ImageIcon.this);
      int height=_image.getHeight(ImageIcon.this);
      if (width < 0 || height < 0) {
        width=_width;
        height=_height;
      }
      if (width > 0 && height > 0) {
        int newWidth=(int)Math.round(width * _scalePercentage / 100.0);
        int newHeight=(int)Math.round(height * _scalePercentage / 100.0);
        _scaledImage=_image.getScaledInstance(newWidth,newHeight,Image.SCALE_SMOOTH);
        _scaledImage.getWidth(ImageIcon.this);
        _scaledImage.getHeight(ImageIcon.this);
        Iterator figures=_liveFigureIterator();
        while (figures.hasNext()) {
          Object figure=figures.next();
          ((ImageFigure)figure).setCentered(false);
          ((ImageFigure)figure).setImage(_scaledImage);
        }
      }
    }
  }
;
  SwingUtilities.invokeLater(doScale);
}
Program: 75284
Project: 75284
Buggy source:
/** 
 * Specify an image to display.  This is deferred and executed in the Swing thread.
 * @param image The image to display.
 */
public void setImage(Image image){
  _image=image;
  _scaledImage=image;
  Runnable doSet=new Runnable(){
    public void run(){
      Iterator figures=_liveFigureIterator();
      while (figures.hasNext()) {
        Object figure=figures.next();
        ((ImageFigure)figure).setImage(_scaledImage);
        if (_scalePercentage != 100.0) {
          scaleImage(_scalePercentage);
        }
      }
    }
  }
;
  SwingUtilities.invokeLater(doSet);
}

Fixed version (ground truth):
/** 
 * Specify an image to display.  This is deferred and executed in the Swing thread.
 * @param image The image to display.
 */
public void setImage(Image image){
  _image=image;
  _scaledImage=image;
  _image.getWidth(this);
  _image.getHeight(this);
  Runnable doSet=new Runnable(){
    public void run(){
      Iterator figures=_liveFigureIterator();
      while (figures.hasNext()) {
        Object figure=figures.next();
        ((ImageFigure)figure).setImage(_scaledImage);
        if (_scalePercentage != 100.0) {
          scaleImage(_scalePercentage);
        }
      }
    }
  }
;
  SwingUtilities.invokeLater(doSet);
}
Program: 75285
Project: 75285
Buggy source:
/** 
 * Return a string representation of the UnitSystem.
 * @return A string representation of the UnitSystem
 */
public static String summarizeUnitCategories(){
synchronized (_indexTable) {
    return "String_Node_Str" + categories + _categoryList.toString();
  }
}

Fixed version (ground truth):
/** 
 * Return a string representation of the UnitSystem.
 * @return A string representation of the UnitSystem
 */
public static String summarizeUnitCategories(){
synchronized (_indexTable) {
    return "String_Node_Str" + _categories + "String_Node_Str"+ _categoryList.toString();
  }
}
Program: 75287
Project: 75287
Buggy source:
/** 
 * Clone the object into the specified workspace. The new object is <i>not</i> added to the directory of that workspace (you must do this yourself if you want it there). The result is an object with no container.
 * @param workspace The workspace for the cloned object.
 * @exception CloneNotSupportedException Not thrown in this base class
 * @return The new Attribute.
 */
public Object clone(Workspace workspace) throws CloneNotSupportedException {
  ImageAttribute newObject=(ImageAttribute)super.clone(workspace);
  try {
    newObject._icon=new ImageIcon(this,"String_Node_Str");
    newObject._icon.setPersistent(false);
  }
 catch (  KernelException e) {
    throw new InternalErrorException(e);
  }
  return newObject;
}

Fixed version (ground truth):
/** 
 * Clone the object into the specified workspace. The new object is <i>not</i> added to the directory of that workspace (you must do this yourself if you want it there). The result is an object with no container.
 * @param workspace The workspace for the cloned object.
 * @exception CloneNotSupportedException Not thrown in this base class
 * @return The new Attribute.
 */
public Object clone(Workspace workspace) throws CloneNotSupportedException {
  ImageAttribute newObject=(ImageAttribute)super.clone(workspace);
  newObject._icon=(ImageIcon)newObject.getAttribute("String_Node_Str");
  return newObject;
}
Program: 75288
Project: 75288
Buggy source:
/** 
 * Construct an attribute with the given name contained by the specified container. The container argument must not be null, or a NullPointerException will be thrown.  This attribute will use the workspace of the container for synchronization and version counts. If the name argument is null, then the name is set to the empty string. Increment the version of the workspace.
 * @param container The container.
 * @param name The name of this attribute.
 * @exception IllegalActionException If the attribute is not of anacceptable class for the container, or if the name contains a period.
 * @exception NameDuplicationException If the name coincides withan attribute already in the container.
 */
public ImageAttribute(NamedObj container,String name) throws IllegalActionException, NameDuplicationException {
  super(container,name);
  new SingletonAttribute(this,"String_Node_Str");
  _icon=new ImageIcon(this,"String_Node_Str");
  _icon.setPersistent(false);
  source=new FileParameter(this,"String_Node_Str");
  source.setExpression("String_Node_Str");
  scale=new Parameter(this,"String_Node_Str");
  scale.setTypeEquals(BaseType.DOUBLE);
  scale.setExpression("String_Node_Str");
  new ResizableAttributeControllerFactory(this,"String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Construct an attribute with the given name contained by the specified container. The container argument must not be null, or a NullPointerException will be thrown.  This attribute will use the workspace of the container for synchronization and version counts. If the name argument is null, then the name is set to the empty string. Increment the version of the workspace.
 * @param container The container.
 * @param name The name of this attribute.
 * @exception IllegalActionException If the attribute is not of anacceptable class for the container, or if the name contains a period.
 * @exception NameDuplicationException If the name coincides withan attribute already in the container.
 */
public ImageAttribute(NamedObj container,String name) throws IllegalActionException, NameDuplicationException {
  super(container,name);
  new SingletonAttribute(this,"String_Node_Str");
  _icon=new ImageIcon(this,"String_Node_Str");
  _icon.setPersistent(false);
  source=new FileParameter(this,"String_Node_Str");
  source.setExpression("String_Node_Str");
  scale=new Parameter(this,"String_Node_Str");
  scale.setTypeEquals(BaseType.DOUBLE);
  scale.setExpression("String_Node_Str");
}
Program: 75289
Project: 75289
Buggy source:
/** 
 * Override the base class to also set the associated port, if there is one.
 */
public void setName(String name) throws IllegalActionException, NameDuplicationException {
  super.setName(name);
  if (_associatedPort != null && !_associatedPort.getName().equals(name)) {
    MoMLChangeRequest request=new MoMLChangeRequest(this,_associatedPort.getContainer(),"String_Node_Str" + name + "String_Node_Str");
    _associatedPort.getContainer().requestChange(request);
  }
}

Fixed version (ground truth):
/** 
 * Override the base class to also set the associated port, if there is one.
 */
public void setName(String name) throws IllegalActionException, NameDuplicationException {
  super.setName(name);
  if (_associatedPort != null && !_associatedPort.getName().equals(name)) {
    MoMLChangeRequest request=new MoMLChangeRequest(this,_associatedPort,"String_Node_Str" + name + "String_Node_Str");
    _associatedPort.requestChange(request);
  }
}
Program: 75290
Project: 75290
Buggy source:
/** 
 * Override the base class to invalidate the schedule and resolved types of the director of the container, if there is one, in addition to what the base class does.
 * @param index The index at which to insert the link.
 * @param relation The relation to link to this port.
 * @exception IllegalActionException If the link would cross levels ofthe hierarchy, or the relation is incompatible, or the port has no container, or the port is not in the same workspace as the relation, or if this port is not a multiport and the index is greater than zero or if another link already exists.
 */
public void insertLink(int index,Relation relation) throws IllegalActionException {
  if (!isMultiport()) {
    if (index > 0) {
      throw new IllegalActionException(this,"String_Node_Str" + "String_Node_Str");
    }
 else     if (numLinks() > 0) {
      throw new IllegalActionException(this,"String_Node_Str" + "String_Node_Str");
    }
  }
  super.insertLink(index,relation);
  _invalidate();
}

Fixed version (ground truth):
/** 
 * Override the base class to invalidate the schedule and resolved types of the director of the container, if there is one, in addition to what the base class does.
 * @param index The index at which to insert the link.
 * @param relation The relation to link to this port.
 * @exception IllegalActionException If the link would cross levels ofthe hierarchy, or the relation is incompatible, or the port has no container, or the port is not in the same workspace as the relation, or if this port is not a multiport and the index is greater than zero or if another link already exists.
 */
public void insertLink(int index,Relation relation) throws IllegalActionException {
  if (!isMultiport()) {
    if (index > 0) {
      throw new IllegalActionException(this,"String_Node_Str" + "String_Node_Str");
    }
 else     if (_isInsideLinkable(relation)) {
      if (numInsideLinks() > 0) {
        throw new IllegalActionException(this,"String_Node_Str" + "String_Node_Str");
      }
    }
 else     if (numLinks() > 0) {
      throw new IllegalActionException(this,"String_Node_Str" + "String_Node_Str");
    }
  }
  super.insertLink(index,relation);
  _invalidate();
}
Program: 75291
Project: 75291
Buggy source:
private final AccessRecord _getAccessRecord(Thread current,boolean createNew){
  AccessRecord record=(AccessRecord)_readerRecords.get(current);
  if (record == null) {
    Iterator records=_readerRecords.values().iterator();
    while (records.hasNext()) {
      AccessRecord aRecord=(AccessRecord)records.next();
      if (aRecord.failedReadAttempts == 0 && aRecord.failedWriteAttempts == 0 && aRecord.readDepth == 0 && aRecord != _lastReaderRecord) {
        records.remove();
      }
    }
    if (createNew) {
      record=new AccessRecord();
      _readerRecords.put(current,record);
    }
  }
  if (record != null) {
    _lastReader=current;
    _lastReaderRecord=record;
  }
  return record;
}

Fixed version (ground truth):
private final AccessRecord _getAccessRecord(Thread current,boolean createNew){
  if (_readerRecords == null) {
    _readerRecords=new HashMap();
  }
  AccessRecord record=(AccessRecord)_readerRecords.get(current);
  if (record == null) {
    Iterator records=_readerRecords.values().iterator();
    while (records.hasNext()) {
      AccessRecord aRecord=(AccessRecord)records.next();
      if (aRecord.failedReadAttempts == 0 && aRecord.failedWriteAttempts == 0 && aRecord.readDepth == 0 && aRecord != _lastReaderRecord) {
        records.remove();
      }
    }
    if (createNew) {
      record=new AccessRecord();
      _readerRecords.put(current,record);
    }
  }
  if (record != null) {
    _lastReader=current;
    _lastReaderRecord=record;
  }
  return record;
}
Program: 75292
Project: 75292
Buggy source:
/** 
 * Read at most one token from each channel of each input port and plot it. This is done in postfire to ensure that data has settled. The width of the inputs should be the same, otherwise a exception will be thrown. The channels from the two input ports are matched to give the X and Y position of a single data point.  Each matched channel pair must have at least one token, or a token will be consumed from the input channel that has a token, but nothing will be plotted.
 * @exception IllegalActionException If there is no director,the width of the ports are not the same, or if the base class throws it.
 * @return True if it is OK to continue.
 */
public boolean postfire() throws IllegalActionException {
  boolean hasX=false, hasY=false;
  double xValue=0.0;
  double yValue=0.0;
  int widthX=inputX.getWidth();
  int widthY=inputY.getWidth();
  if (widthX != widthY) {
    throw new IllegalActionException(this,"String_Node_Str");
  }
  int offset=((IntToken)startingDataset.getToken()).intValue();
  for (int i=widthX - 1; i >= 0; i--) {
    if (inputX.hasToken(i)) {
      xValue=((DoubleToken)inputX.get(i)).doubleValue();
      hasX=true;
    }
    if (inputY.hasToken(i)) {
      yValue=((DoubleToken)inputY.get(i)).doubleValue();
      hasY=true;
    }
    if (hasX && hasY) {
      ((Plot)plot).addPoint(i + offset,xValue,yValue,true);
    }
  }
  return super.postfire();
}

Fixed version (ground truth):
/** 
 * Read at most one token from each channel of each input port and plot it. This is done in postfire to ensure that data has settled. The width of the inputs should be the same, otherwise a exception will be thrown. The channels from the two input ports are matched to give the X and Y position of a single data point.  Each matched channel pair must have at least one token, or a token will be consumed from the input channel that has a token, but nothing will be plotted.
 * @exception IllegalActionException If there is no director,the width of the ports are not the same, or if the base class throws it.
 * @return True if it is OK to continue.
 */
public boolean postfire() throws IllegalActionException {
  int widthX=inputX.getWidth();
  int widthY=inputY.getWidth();
  if (widthX != widthY) {
    throw new IllegalActionException(this,"String_Node_Str");
  }
  int offset=((IntToken)startingDataset.getToken()).intValue();
  for (int i=widthX - 1; i >= 0; i--) {
    boolean hasX=false, hasY=false;
    double xValue=0.0;
    double yValue=0.0;
    if (inputX.hasToken(i)) {
      xValue=((DoubleToken)inputX.get(i)).doubleValue();
      hasX=true;
    }
    if (inputY.hasToken(i)) {
      yValue=((DoubleToken)inputY.get(i)).doubleValue();
      hasY=true;
    }
    if (hasX && hasY) {
      ((Plot)plot).addPoint(i + offset,xValue,yValue,true);
    }
  }
  return super.postfire();
}
Program: 75293
Project: 75293
Buggy source:
/** 
 * Add a port to this actor. This overrides the base class to add a corresponding port to the container using a change request.
 * @param port The TypedIOPort to add to this actor.
 * @exception IllegalActionException If the port is not an instance ofMirrorPort, or the port has no name.
 * @exception NameDuplicationException If the port name collides with aname already in the actor.
 */
protected void _addPort(final Port port) throws IllegalActionException, NameDuplicationException {
  if (!(port instanceof MirrorPort)) {
    throw new IllegalActionException(this,"String_Node_Str");
  }
  super._addPort(port);
  final IterateOverArray container=(IterateOverArray)getContainer();
  if (container._inAddPort) {
    return;
  }
  ChangeRequest request=new ChangeRequest(this,"String_Node_Str"){
    protected void _execute() throws Exception {
      IteratePort newPort=(IteratePort)container.getPort(port.getName());
      if (newPort == null) {
        newPort=(IteratePort)container.newPort(port.getName());
      }
      if (port instanceof IOPort) {
        newPort.setInput(((IOPort)port).isInput());
        newPort.setOutput(((IOPort)port).isOutput());
        newPort.setMultiport(((IOPort)port).isMultiport());
      }
    }
  }
;
  container.requestChange(request);
}

Fixed version (ground truth):
/** 
 * Add a port to this actor. This overrides the base class to add a corresponding port to the container using a change request, if that port does not already exist.
 * @param port The TypedIOPort to add to this actor.
 * @exception IllegalActionException If the port is not an instance ofMirrorPort, or the port has no name.
 * @exception NameDuplicationException If the port name collides with aname already in the actor.
 */
protected void _addPort(final Port port) throws IllegalActionException, NameDuplicationException {
  if (!(port instanceof MirrorPort)) {
    throw new IllegalActionException(this,"String_Node_Str");
  }
  super._addPort(port);
  final IterateOverArray container=(IterateOverArray)getContainer();
  if (container._inAddPort) {
    return;
  }
  ChangeRequest request=new ChangeRequest(this,"String_Node_Str"){
    protected void _execute() throws Exception {
      IteratePort newPort=(IteratePort)container.getPort(port.getName());
      if (newPort == null) {
        newPort=(IteratePort)container.newPort(port.getName());
      }
      if (port instanceof IOPort) {
        newPort.setInput(((IOPort)port).isInput());
        newPort.setOutput(((IOPort)port).isOutput());
        newPort.setMultiport(((IOPort)port).isMultiport());
      }
    }
  }
;
  container.requestChange(request);
}
Program: 75295
Project: 75295
Buggy source:
/** 
 * Clone the object into the specified workspace. This overrides the base class to set a flag indicating that cloning is complete. While this flag is false and isDerived() returns true an instance of this class is being cloned from another instance. Methods of this object use this to test whether to construct the automatically constructed contents. These should not be constructed in a clone, since they will be copied from the original.
 * @param workspace The workspace for the new object.
 * @return A new NamedObj.
 * @exception CloneNotSupportedException If any of the attributescannot be cloned.
 * @see #exportMoML(Writer,int,String)
 */
public Object clone(Workspace workspace) throws CloneNotSupportedException {
  IterateOverArray result=(IterateOverArray)super.clone(workspace);
  result._cloning=false;
  return result;
}

Fixed version (ground truth):
/** 
 * Clone the object into the specified workspace. This overrides the base class to set up the associations in the mirror ports and to set a flag indicating that cloning is complete.
 * @param workspace The workspace for the new object.
 * @return A new NamedObj.
 * @exception CloneNotSupportedException If any of the attributescannot be cloned.
 * @see #exportMoML(Writer,int,String)
 */
public Object clone(Workspace workspace) throws CloneNotSupportedException {
  IterateOverArray result=(IterateOverArray)super.clone(workspace);
  result._iterationCount=(Variable)result.getAttribute("String_Node_Str");
  Iterator entities=result.entityList().iterator();
  while (entities.hasNext()) {
    Entity insideEntity=(Entity)entities.next();
    Iterator ports=result.portList().iterator();
    while (ports.hasNext()) {
      MirrorPort port=(MirrorPort)ports.next();
      Port insidePort=insideEntity.getPort(port.getName());
      if (insidePort instanceof MirrorPort) {
        port.setAssociatedPort((MirrorPort)insidePort);
      }
    }
  }
  result._cloning=false;
  return result;
}
Program: 75296
Project: 75296
Buggy source:
/** 
 * Apply the changes by renaming the object.
 */
public void apply(){
  if (_changed) {
    String newName=getStringValue("String_Node_Str");
    NamedObj parent=(NamedObj)_object.getContainer();
    String oldName=_object.getName();
    StringBuffer moml=new StringBuffer("String_Node_Str");
    String elementName=_object.getElementName();
    moml.append(elementName);
    moml.append("String_Node_Str");
    moml.append(oldName);
    moml.append("String_Node_Str");
    moml.append(newName);
    moml.append("String_Node_Str");
    boolean showName=getBooleanValue("String_Node_Str");
    if (_object instanceof Port) {
      if (showName) {
        moml.append("String_Node_Str" + "String_Node_Str");
      }
 else {
        if (_object.getAttribute("String_Node_Str") != null) {
          moml.append("String_Node_Str");
        }
      }
    }
 else {
      if (showName) {
        if (_object.getAttribute("String_Node_Str") != null) {
          moml.append("String_Node_Str");
        }
      }
 else {
        moml.append("String_Node_Str" + "String_Node_Str");
      }
    }
    moml.append("String_Node_Str");
    moml.append(elementName);
    moml.append("String_Node_Str");
    MoMLChangeRequest request=new MoMLChangeRequest(this,parent,moml.toString(),null);
    request.addChangeListener(this);
    request.setUndoable(true);
    parent.requestChange(request);
  }
}

Fixed version (ground truth):
/** 
 * Apply the changes by renaming the object.
 */
public void apply(){
  if (_changed) {
    String newName=getStringValue("String_Node_Str");
    NamedObj parent=(NamedObj)_object.getContainer();
    String oldName=_object.getName();
    StringBuffer moml=new StringBuffer("String_Node_Str");
    String elementName=_object.getElementName();
    moml.append(elementName);
    moml.append("String_Node_Str");
    moml.append(oldName);
    moml.append("String_Node_Str");
    moml.append(newName);
    moml.append("String_Node_Str");
    boolean showName=getBooleanValue("String_Node_Str");
    if (_object instanceof Port) {
      if (showName) {
        if (_object.getAttribute("String_Node_Str") == null) {
          moml.append("String_Node_Str" + "String_Node_Str");
        }
      }
 else {
        if (_object.getAttribute("String_Node_Str") != null) {
          moml.append("String_Node_Str");
        }
      }
    }
 else {
      if (showName) {
        if (_object.getAttribute("String_Node_Str") != null) {
          moml.append("String_Node_Str");
        }
      }
 else {
        if (_object.getAttribute("String_Node_Str") == null) {
          moml.append("String_Node_Str" + "String_Node_Str");
        }
      }
    }
    moml.append("String_Node_Str");
    moml.append(elementName);
    moml.append("String_Node_Str");
    MoMLChangeRequest request=new MoMLChangeRequest(this,parent,moml.toString(),null);
    request.addChangeListener(this);
    request.setUndoable(true);
    parent.requestChange(request);
  }
}
Program: 75298
Project: 75298
Buggy source:
/** 
 * Return true if setDeferringChangeRequests() has been called to specify that change requests should be deferred.
 * @return True if change requests are being deferred.
 * @see #setDeferringChangeRequests(boolean)
 */
public boolean isDeferringChangeRequests(){
  return _deferChangeRequests;
}

Fixed version (ground truth):
/** 
 * Return true if setDeferringChangeRequests() has been called to specify that change requests should be deferred. If there is a container, this delegates to the container.
 * @return True if change requests are being deferred.
 * @see #setDeferringChangeRequests(boolean)
 */
public boolean isDeferringChangeRequests(){
  NamedObj container=(NamedObj)getContainer();
  if (container != null) {
    return container.isDeferringChangeRequests();
  }
  return _deferChangeRequests;
}
Program: 75299
Project: 75299
Buggy source:
/** 
 * Return the associated port, or null if there is none.
 * @param port The associated port.
 * @see #setAssociatedPort(TypedIOPort)
 */
public MirrorPort getAssociatedPort(){
  return _associatedPort;
}

Fixed version (ground truth):
/** 
 * Return the associated port, or null if there is none.
 * @return The associated port, or null if there is none.
 * @see #setAssociatedPort(MirrorPort)
 */
public MirrorPort getAssociatedPort(){
  return _associatedPort;
}
Program: 75300
Project: 75300
Buggy source:
/** 
 * Initialize the _registeredWithChannel.
 */
public void initialize() throws IllegalActionException {
  super.initialize();
  _terrain.width.setToken(new IntToken(10));
  _number=10;
  _offset=new double[2];
  Locatable location=(Locatable)getAttribute(LOCATION_ATTRIBUTE_NAME,Locatable.class);
  if (location == null) {
    throw new IllegalActionException("String_Node_Str" + getName() + "String_Node_Str");
  }
  _offset=location.getLocation();
  CompositeEntity container=(CompositeEntity)getContainer();
  _channelName=channelName.stringValue();
  Entity channel=container.getEntity(_channelName);
  if (channel instanceof WirelessChannel) {
    _channel=(WirelessChannel)channel;
    ((WirelessChannel)channel).registerPropertyTransformer(this,null);
  }
 else {
    throw new IllegalActionException(this,"String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Initialize the _registeredWithChannel.
 */
public void initialize() throws IllegalActionException {
  super.initialize();
  _terrain.width.setToken(new IntToken(10));
  _number=10;
  _offset=new double[2];
  Locatable location=(Locatable)getAttribute(LOCATION_ATTRIBUTE_NAME,Locatable.class);
  if (location == null) {
    throw new IllegalActionException("String_Node_Str" + getName() + "String_Node_Str");
  }
  double[] center=_polygonCenter();
  _offset[0]=location.getLocation()[0] + center[0];
  _offset[1]=location.getLocation()[1] + center[1];
  CompositeEntity container=(CompositeEntity)getContainer();
  _channelName=channelName.stringValue();
  Entity channel=container.getEntity(_channelName);
  if (channel instanceof WirelessChannel) {
    _channel=(WirelessChannel)channel;
    ((WirelessChannel)channel).registerPropertyTransformer(this,null);
  }
 else {
    throw new IllegalActionException(this,"String_Node_Str");
  }
}
Program: 75304
Project: 75304
Buggy source:
/** 
 * Delete an attribute after verifying that it is contained (deeply) by the current environment.
 * @param attributeName The relative or absolute name of theattribute to delete.
 * @return The deleted object.
 * @exception Exception If there is no such attribute or if the attributeis defined in the class definition.
 */
private Attribute _deleteProperty(String attributeName) throws Exception {
  Attribute toDelete=_searchForAttribute(attributeName);
  if (toDelete == null) {
    throw new XmlException("String_Node_Str" + attributeName,_currentExternalEntity(),_parser.getLineNumber(),_parser.getColumnNumber());
  }
  if (toDelete.isDerived()) {
    throw new IllegalActionException(toDelete,"String_Node_Str");
  }
  StringBuffer undoMoML=new StringBuffer();
  try {
    Iterator heritage=toDelete.getDerivedList().iterator();
    String toUndo=_getUndoForDeleteAttribute(toDelete);
    toDelete.setContainer(null);
    undoMoML.append(toUndo);
    while (heritage.hasNext()) {
      Attribute inherited=(Attribute)heritage.next();
      toUndo=_getUndoForDeleteAttribute(inherited);
      inherited.setContainer(null);
      undoMoML.append(toUndo);
    }
  }
  finally {
    if (_undoEnabled && _undoContext.isUndoable()) {
      undoMoML.insert(0,"String_Node_Str");
      undoMoML.append("String_Node_Str");
      _undoContext.appendUndoMoML(undoMoML.toString());
    }
  }
  return toDelete;
}

Fixed version (ground truth):
/** 
 * Delete an attribute after verifying that it is contained (deeply) by the current environment. If no object is found, then do nothing and return null.  This is because deletion of a class may result in deletion of other objects that make this particular delete call redundant.
 * @param attributeName The relative or absolute name of theattribute to delete.
 * @return The deleted object, or null if none is found.
 * @exception Exception If there is no such attribute or if the attributeis defined in the class definition.
 */
private Attribute _deleteProperty(String attributeName) throws Exception {
  Attribute toDelete=_searchForAttribute(attributeName);
  if (toDelete == null) {
    return null;
  }
  if (toDelete.isDerived()) {
    throw new IllegalActionException(toDelete,"String_Node_Str");
  }
  StringBuffer undoMoML=new StringBuffer();
  try {
    Iterator heritage=toDelete.getDerivedList().iterator();
    String toUndo=_getUndoForDeleteAttribute(toDelete);
    toDelete.setContainer(null);
    undoMoML.append(toUndo);
    while (heritage.hasNext()) {
      Attribute inherited=(Attribute)heritage.next();
      toUndo=_getUndoForDeleteAttribute(inherited);
      inherited.setContainer(null);
      undoMoML.append(toUndo);
    }
  }
  finally {
    if (_undoEnabled && _undoContext.isUndoable()) {
      undoMoML.insert(0,"String_Node_Str");
      undoMoML.append("String_Node_Str");
      _undoContext.appendUndoMoML(undoMoML.toString());
    }
  }
  return toDelete;
}
Program: 75305
Project: 75305
Buggy source:
/** 
 * Delete the relation after verifying that it is contained (deeply) by the current environment.
 * @param relationName The relative or absolute name of therelation to delete.
 * @return The deleted object.
 * @exception Exception If there is no such relation or if the relationis defined in the class definition.
 */
private Relation _deleteRelation(String relationName) throws Exception {
  ComponentRelation toDelete=_searchForRelation(relationName);
  if (toDelete == null) {
    throw new XmlException("String_Node_Str" + relationName,_currentExternalEntity(),_parser.getLineNumber(),_parser.getColumnNumber());
  }
  if (toDelete.isDerived()) {
    throw new IllegalActionException(toDelete,"String_Node_Str");
  }
  StringBuffer undoMoML=new StringBuffer();
  try {
    Iterator heritage=toDelete.getDerivedList().iterator();
    List reverse=new LinkedList();
    while (heritage.hasNext()) {
      reverse.add(0,heritage.next());
    }
    heritage=reverse.iterator();
    while (heritage.hasNext()) {
      ComponentRelation inherited=(ComponentRelation)heritage.next();
      inherited.setContainer(null);
    }
    String toUndo=_getUndoForDeleteRelation(toDelete);
    toDelete.setContainer(null);
    undoMoML.insert(0,toUndo);
  }
  finally {
    if (_undoEnabled && _undoContext.isUndoable()) {
      undoMoML.insert(0,"String_Node_Str");
      undoMoML.append("String_Node_Str");
      _undoContext.appendUndoMoML(undoMoML.toString());
    }
  }
  return toDelete;
}

Fixed version (ground truth):
/** 
 * Delete the relation after verifying that it is contained (deeply) by the current environment. If no object is found, then do nothing and return null.  This is because deletion of a class may result in deletion of other objects that make this particular delete call redundant.
 * @param relationName The relative or absolute name of therelation to delete.
 * @return The deleted object, or null if none is found.
 * @exception Exception If there is no such relation or if the relationis defined in the class definition.
 */
private Relation _deleteRelation(String relationName) throws Exception {
  ComponentRelation toDelete=_searchForRelation(relationName);
  if (toDelete == null) {
    return null;
  }
  if (toDelete.isDerived()) {
    throw new IllegalActionException(toDelete,"String_Node_Str");
  }
  StringBuffer undoMoML=new StringBuffer();
  try {
    Iterator heritage=toDelete.getDerivedList().iterator();
    List reverse=new LinkedList();
    while (heritage.hasNext()) {
      reverse.add(0,heritage.next());
    }
    heritage=reverse.iterator();
    while (heritage.hasNext()) {
      ComponentRelation inherited=(ComponentRelation)heritage.next();
      inherited.setContainer(null);
    }
    String toUndo=_getUndoForDeleteRelation(toDelete);
    toDelete.setContainer(null);
    undoMoML.insert(0,toUndo);
  }
  finally {
    if (_undoEnabled && _undoContext.isUndoable()) {
      undoMoML.insert(0,"String_Node_Str");
      undoMoML.append("String_Node_Str");
      _undoContext.appendUndoMoML(undoMoML.toString());
    }
  }
  return toDelete;
}
Program: 75307
Project: 75307
Buggy source:
/** 
 * Return the node controller appropriate for the given object. If the object is an instance of Vertex, then return the local relation controller.  If it implements Locatable, then determine whether it is an Entity, Attribute, or Port, and return the appropriate default controller. If the argument is an instance of Port, then return the local port controller.
 * @param object A Vertex, Locatable, or Port.
 */
public NodeController getNodeController(Object object){
  NodeController result=super.getNodeController(object);
  if (result != null) {
    return result;
  }
  if (object instanceof Vertex) {
    return _relationController;
  }
 else   if (object instanceof Locatable) {
    Object semanticObject=getGraphModel().getSemanticObject(object);
    if (semanticObject instanceof Entity) {
      if (_classDefinitionController != null && ((Entity)semanticObject).isClassDefinition()) {
        return _classDefinitionController;
      }
 else {
        return _entityController;
      }
    }
 else     if (semanticObject instanceof Attribute) {
      return _attributeController;
    }
 else     if (semanticObject instanceof Port) {
      return _portController;
    }
 else {
      throw new RuntimeException("String_Node_Str" + semanticObject);
    }
  }
 else   if (object instanceof Port) {
    return _entityPortController;
  }
  throw new RuntimeException("String_Node_Str" + object);
}

Fixed version (ground truth):
/** 
 * Return the node controller appropriate for the given object. If the object is an instance of Vertex, then return the local relation controller.  If it implements Locatable, then determine whether it is an Entity, Attribute, or Port, and return the appropriate default controller. If the argument is an instance of Port, then return the local port controller.
 * @param object A Vertex, Locatable, or Port.
 */
public NodeController getNodeController(Object object){
  NodeController result=super.getNodeController(object);
  if (result != null) {
    return result;
  }
  if (object instanceof Vertex) {
    return _relationController;
  }
 else   if (object instanceof Locatable) {
    Object semanticObject=getGraphModel().getSemanticObject(object);
    if (semanticObject instanceof Entity) {
      if (_classDefinitionController != null && ((Entity)semanticObject).isClassDefinition()) {
        return _classDefinitionController;
      }
 else {
        return _entityController;
      }
    }
 else     if (semanticObject instanceof Attribute) {
      return _attributeController;
    }
 else     if (semanticObject instanceof Port) {
      return _portController;
    }
 else {
      return _locatableController;
    }
  }
 else   if (object instanceof Port) {
    return _entityPortController;
  }
  throw new RuntimeException("String_Node_Str" + object);
}
Program: 75308
Project: 75308
Buggy source:
/** 
 * Create a new basic controller with default terminal and edge interactors and default context menus.
 */
public ActorViewerGraphController(){
  _createControllers();
}

Fixed version (ground truth):
/** 
 * Create a new basic controller with default terminal and edge interactors and default context menus.
 */
public ActorViewerGraphController(){
  _createControllers();
  _locatableController=new LocatableNodeController(this);
}
Program: 75309
Project: 75309
Buggy source:
/** 
 * Update the graph model.  This is called whenever a change request is executed.  Subclasses will override this to update internal data structures that may be cached.
 * @return True if the graph model changes (always true in thisbase class).
 */
protected boolean _update(){
  return true;
}

Fixed version (ground truth):
/** 
 * Update the graph model.  This is called whenever a change request is executed.  This base class checks each of the contained nodes, and if any has a semantic object with no container, then that node is removed. Subclasses will override this to update internal data structures that may be cached.
 * @return True if the graph model changes (always true in thisbase class).
 */
protected boolean _update(){
  return true;
}
Program: 75310
Project: 75310
Buggy source:
/** 
 * Create an editor for configuring the specified object with the specified parent window.
 * @param object The object to configure.
 * @param parent The parent window, or null if there is none.
 */
public void createEditor(NamedObj object,Frame parent){
  try {
    Configuration configuration=((TableauFrame)parent).getConfiguration();
    TypedCompositeActor model=(TypedCompositeActor)GiottoCEmachineFrameworkGenerator.this.getContainer();
    CompositeActor toplevel=(CompositeActor)model.toplevel();
    Manager manager=toplevel.getManager();
    if (manager == null) {
      manager=new Manager(toplevel.workspace(),"String_Node_Str");
      toplevel.setManager(manager);
    }
    manager.preinitializeAndResolveTypes();
    writeFrameworkCode(model);
    TextEffigy codeEffigy=TextEffigy.newTextEffigy(configuration.getDirectory(),generateCode(model));
    codeEffigy.setModified(true);
    configuration.createPrimaryTableau(codeEffigy);
  }
 catch (  Exception ex) {
    throw new InternalErrorException(object,ex,"String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Create an editor for configuring the specified object with the specified parent window.
 * @param object The object to configure.
 * @param parent The parent window, or null if there is none.
 */
public void createEditor(NamedObj object,Frame parent){
  try {
    Configuration configuration=((TableauFrame)parent).getConfiguration();
    TypedCompositeActor model=(TypedCompositeActor)GiottoCEmachineFrameworkGenerator.this.getContainer();
    CompositeActor toplevel=(CompositeActor)model.toplevel();
    Manager manager=toplevel.getManager();
    if (manager == null) {
      manager=new Manager(toplevel.workspace(),"String_Node_Str");
      toplevel.setManager(manager);
    }
    manager.preinitializeAndResolveTypes();
    writeFrameworkCode(model);
    TextEffigy codeEffigy=TextEffigy.newTextEffigy(configuration.getDirectory(),generateCode(model));
    codeEffigy.setModified(true);
    configuration.createPrimaryTableau(codeEffigy);
    manager.stop();
    manager.wrapup();
  }
 catch (  Exception ex) {
    throw new InternalErrorException(object,ex,"String_Node_Str");
  }
}
Program: 75314
Project: 75314
Buggy source:
/** 
 * Get the timer with expiration time that matches the current time. Remove the timer from the timers set and return the <i>kind<i> parameter of the timer to the caller method. If there are multiple timers with expiration time matching the current time, return the first one from the iterator list.
 * @return return the i>kind<i> parameter of the timeout timer.
 * @exception IllegalActionException If thrown bygetDirector().getCurrentTime().
 */
protected int whoTimeout() throws IllegalActionException {
  Iterator timers=_timersSet.iterator();
  while (timers.hasNext()) {
    Timer timer=(Timer)timers.next();
    if (timer.expirationTime == getDirector().getCurrentTime()) {
      timers.remove();
      return timer.kind;
    }
  }
  return -1;
}

Fixed version (ground truth):
/** 
 * Get the timer with expiration time that matches the current time. Remove the timer from the timers set and return the <i>kind<i> parameter of the timer to the caller method. If there are multiple timers with expiration time matching the current time, return the first one from the iterator list.
 * @return return the i>kind<i> parameter of the timeout timer.
 * @exception IllegalActionException If thrown bygetDirector().getCurrentTime().
 */
protected int whoTimeout() throws IllegalActionException {
  Iterator timers=_timersSet.iterator();
  while (timers.hasNext()) {
    Timer timer=(Timer)timers.next();
    if (timer.expirationTime == getDirector().getCurrentTime()) {
      timers.remove();
      return timer.kind;
    }
  }
  return UNKNOWN;
}
Program: 75315
Project: 75315
Buggy source:
/** 
 * If the specified attribute is changed, check that a positive number is given. Otherwise, defer to the base class.
 * @param attribute The attribute that changed.
 * @exception IllegalActionException If the change is not acceptableto this container.
 */
public void attributeChanged(Attribute attribute) throws IllegalActionException {
  int temp=0;
  if (attribute == aPreambleLength) {
    temp=((IntToken)aPreambleLength.getToken()).intValue();
    if (temp < 0) {
      throw new IllegalActionException(this,"String_Node_Str" + "String_Node_Str" + temp);
    }
 else {
      _aPreambleLength=temp;
    }
  }
 else   if (attribute == aPlcpHeaderLength) {
    temp=((IntToken)aPlcpHeaderLength.getToken()).intValue();
    if (temp < 0) {
      throw new IllegalActionException(this,"String_Node_Str" + "String_Node_Str" + temp);
    }
 else {
      _aPlcpHeaderLength=temp;
    }
  }
 else   if (attribute == SNRThresholdInDB) {
    double SNRThresholdInDBValue=((DoubleToken)SNRThresholdInDB.getToken()).doubleValue();
    if (SNRThresholdInDBValue <= 0.0) {
      throw new IllegalActionException(this,"String_Node_Str" + "String_Node_Str" + SNRThresholdInDBValue);
    }
 else {
      _SNRThresholdInDB=Math.pow(10,SNRThresholdInDBValue / 10);
    }
  }
 else   if (attribute == sensitivity) {
    _sensitivity=((DoubleToken)sensitivity.getToken()).doubleValue();
    if (_sensitivity < 0.0) {
      throw new IllegalActionException(this,"String_Node_Str" + "String_Node_Str" + _sensitivity);
    }
  }
 else {
    super.attributeChanged(attribute);
  }
}

Fixed version (ground truth):
/** 
 * If the specified attribute is changed, check that a positive number is given. Otherwise, defer to the base class.
 * @param attribute The attribute that changed.
 * @exception IllegalActionException If the change is not acceptableto this container.
 */
public void attributeChanged(Attribute attribute) throws IllegalActionException {
  int temp=0;
  if (attribute == aPreambleLength) {
    temp=((IntToken)aPreambleLength.getToken()).intValue();
    if (temp < 0) {
      throw new IllegalActionException(this,"String_Node_Str" + "String_Node_Str" + temp);
    }
 else {
      _aPreambleLength=temp;
    }
  }
 else   if (attribute == aPlcpHeaderLength) {
    temp=((IntToken)aPlcpHeaderLength.getToken()).intValue();
    if (temp < 0) {
      throw new IllegalActionException(this,"String_Node_Str" + "String_Node_Str" + temp);
    }
 else {
      _aPlcpHeaderLength=temp;
    }
  }
 else   if (attribute == SNRThresholdInDB) {
    double SNRThresholdInDBValue=((DoubleToken)SNRThresholdInDB.getToken()).doubleValue();
    _SNRThresholdInDB=Math.pow(10,SNRThresholdInDBValue / 10);
  }
 else   if (attribute == sensitivity) {
    _sensitivity=((DoubleToken)sensitivity.getToken()).doubleValue();
    if (_sensitivity < 0.0) {
      throw new IllegalActionException(this,"String_Node_Str" + "String_Node_Str" + _sensitivity);
    }
  }
 else {
    super.attributeChanged(attribute);
  }
}
Program: 75317
Project: 75317
Buggy source:
/** 
 * Get the timer with expiration time that matches the current time. Remove the timer from the timers set and return the <i>kind<i> parameter of the timer to the caller method. If there are multiple timers with expiration time matching the current time, return the first one from the iterator list.
 * @return return the i>kind<i> parameter of the timeout timer.
 * @exception IllegalActionException If thrown bygetDirector().getCurrentTime().
 */
protected int whoTimeout2() throws IllegalActionException {
  Iterator timers=_timersSet.iterator();
  while (timers.hasNext()) {
    ExtendedTimer timer=(ExtendedTimer)timers.next();
    if (timer.expirationTime == getDirector().getCurrentTime()) {
      if (timer.kind == InterferenceDone) {
        _interference=_interference - timer.power;
        if (_interference < 0.0)         _interference=0.0;
      }
      if (((timer.kind == InterferenceDone) || (timer.kind == RxDone)) && timer.power > _sensitivity)       _numBusyTimers--;
      timers.remove();
      return timer.kind;
    }
  }
  return -1;
}

Fixed version (ground truth):
/** 
 * Get the timer with expiration time that matches the current time. Remove the timer from the timers set and return the <i>kind<i> parameter of the timer to the caller method. If there are multiple timers with expiration time matching the current time, return the first one from the iterator list.
 * @return return the i>kind<i> parameter of the timeout timer.
 * @exception IllegalActionException If thrown bygetDirector().getCurrentTime().
 */
protected int whoTimeout2() throws IllegalActionException {
  Iterator timers=_timersSet.iterator();
  while (timers.hasNext()) {
    ExtendedTimer timer=(ExtendedTimer)timers.next();
    if (timer.expirationTime == getDirector().getCurrentTime()) {
      if (timer.kind == InterferenceDone) {
        _interference=_interference - timer.power;
        if (_interference < 0.0) {
          _interference=0.0;
        }
      }
      if (((timer.kind == InterferenceDone) || (timer.kind == RxDone)) && timer.power > _sensitivity) {
        _numBusyTimers--;
      }
      timers.remove();
      return timer.kind;
    }
  }
  return -1;
}