nus-yam/ex-repair huggingface dataset:
Program: 73805
Project: 73805
Buggy source:
/** 
 * Execute the necessary commands to save/update a model in the database according to the model specification given in the task parameter
 * @param task The task to be completed.  In this case, SaveModelTask.  This will tell the DB layer to save/update a model already existing in the database.
 * @throws DBExecutionException Thrown if there is a problem executing the task.
 */
public void executeSaveModelTask(SaveModelTask task) throws DBExecutionException {
  try {
    if (_xmlContainer == null) {
      throw new DBExecutionException("String_Node_Str" + "String_Node_Str");
    }
    if (_xmlTransaction == null) {
      throw new DBExecutionException("String_Node_Str" + "String_Node_Str");
    }
    if (task == null) {
      throw new DBExecutionException("String_Node_Str" + "String_Node_Str");
    }
    XMLDBModel model=task.getXMLDBModel();
    if (model == null) {
      throw new DBExecutionException("String_Node_Str" + "String_Node_Str");
    }
    XmlDocument currentDbModel=_xmlContainer.getDocument(model.getModelName());
    if (currentDbModel == null) {
      throw new DBExecutionException("String_Node_Str" + "String_Node_Str");
    }
 else {
      currentDbModel.setContent(model.getModel());
      _xmlContainer.updateDocument(_xmlTransaction,currentDbModel);
    }
  }
 catch (  XmlException e) {
    throw new DBExecutionException("String_Node_Str" + e.getMessage(),e);
  }
}

Fixed version (ground truth):
/** 
 * Execute the necessary commands to save/update a model in the database according to the model specification given in the task parameter
 * @param task The task to be completed.  In this case, SaveModelTask.  This will tell the DB layer to save/update a model already existing in the database.
 * @throws DBExecutionException Thrown if there is a problem executing the task.
 */
public void executeSaveModelTask(SaveModelTask task) throws DBExecutionException {
  try {
    if (_xmlContainer == null) {
      throw new DBExecutionException("String_Node_Str" + "String_Node_Str");
    }
    if (_xmlTransaction == null) {
      throw new DBExecutionException("String_Node_Str" + "String_Node_Str");
    }
    if (task == null) {
      throw new DBExecutionException("String_Node_Str" + "String_Node_Str");
    }
    XMLDBModel model=task.getXMLDBModel();
    if (model == null) {
      throw new DBExecutionException("String_Node_Str" + "String_Node_Str");
    }
    XmlDocument currentDbModel=null;
    try {
      currentDbModel=_xmlContainer.getDocument(model.getModelName());
    }
 catch (    XmlException e) {
    }
    if (currentDbModel == null) {
      throw new DBExecutionException("String_Node_Str" + "String_Node_Str");
    }
 else {
      currentDbModel.setContent(model.getModel());
      _xmlContainer.updateDocument(_xmlTransaction,currentDbModel);
    }
  }
 catch (  XmlException e) {
    throw new DBExecutionException("String_Node_Str" + e.getMessage(),e);
  }
}
Program: 73806
Project: 73806
Buggy source:
/** 
 * retrieve the references inside a model from the reference file in the database.
 * @param p_strModelName - the model name for which the references are required.
 * @return String representation of all the references in the given model in xml format.
 * @throws DBExecutionException thrown if there is an execution exception.
 */
private String _getModelReferences(String p_strModelName) throws DBExecutionException {
  String strReference="String_Node_Str";
  try {
    if (_xmlContainer == null) {
      throw new DBExecutionException("String_Node_Str" + "String_Node_Str");
    }
    if (_xmlManager == null) {
      throw new DBExecutionException("String_Node_Str" + "String_Node_Str");
    }
    XmlQueryContext xmlContext=_xmlManager.createQueryContext();
    if (xmlContext == null) {
      throw new DBExecutionException("String_Node_Str" + "String_Node_Str");
    }
    String strQuery="String_Node_Str" + _xmlContainer.getName() + "String_Node_Str"+ p_strModelName+ "String_Node_Str";
    XmlQueryExpression queryExpression=_xmlManager.prepare(strQuery,xmlContext);
    if (queryExpression == null) {
      throw new DBExecutionException("String_Node_Str" + "String_Node_Str");
    }
    XmlResults results=queryExpression.execute(xmlContext);
    if (results != null && results.size() > 0) {
      XmlValue result=results.next();
      strReference=result.asString();
    }
    return strReference;
  }
 catch (  XmlException e) {
    throw new DBExecutionException("String_Node_Str" + e.getMessage(),e);
  }
}

Fixed version (ground truth):
/** 
 * retrieve the references inside a model from the reference file in the database.
 * @param p_strModelName - the model name for which the references are required.
 * @return String representation of all the references in the given model in xml format.
 * @throws DBExecutionException thrown if there is an execution exception.
 */
private String _getModelReferences(String p_strModelName) throws DBExecutionException {
  String strReference="String_Node_Str";
  try {
    if (_xmlContainer == null) {
      throw new DBExecutionException("String_Node_Str" + "String_Node_Str");
    }
    if (_xmlManager == null) {
      throw new DBExecutionException("String_Node_Str" + "String_Node_Str");
    }
    XmlQueryContext xmlContext=_xmlManager.createQueryContext();
    if (xmlContext == null) {
      throw new DBExecutionException("String_Node_Str" + "String_Node_Str");
    }
    String strQuery="String_Node_Str" + _xmlContainer.getName() + "String_Node_Str"+ "String_Node_Str"+ p_strModelName+ "String_Node_Str";
    XmlQueryExpression queryExpression=_xmlManager.prepare(strQuery,xmlContext);
    if (queryExpression == null) {
      throw new DBExecutionException("String_Node_Str" + "String_Node_Str");
    }
    XmlResults results=queryExpression.execute(xmlContext);
    if (results != null && results.size() > 0) {
      XmlValue result=results.next();
      strReference=result.asString();
    }
    return strReference;
  }
 catch (  XmlException e) {
    throw new DBExecutionException("String_Node_Str" + e.getMessage(),e);
  }
}
Program: 73807
Project: 73807
Buggy source:
/** 
 * Parse the xml string that is passed to it and returns the upper node of that xml.
 * @param p_strXML the xml string that needs to be parsed
 * @return Node - the upper node for the xml string after parsing it.
 * @throws DBExecutionException used as wrapper to the parser exceptions
 */
private Node _parseXML(String p_strXML) throws DBExecutionException {
  if (p_strXML == null || p_strXML.length() == 0) {
    throw new DBExecutionException("String_Node_Str" + "String_Node_Str");
  }
  DocumentBuilder docBuilder;
  Node firstNode=null;
  DocumentBuilderFactory docBuilderFactory=DocumentBuilderFactory.newInstance();
  if (docBuilderFactory == null) {
    throw new DBExecutionException("String_Node_Str" + "String_Node_Str");
  }
  docBuilderFactory.setIgnoringElementContentWhitespace(true);
  try {
    docBuilder=docBuilderFactory.newDocumentBuilder();
    if (docBuilder == null) {
      throw new DBExecutionException("String_Node_Str" + "String_Node_Str");
    }
    InputSource is=new InputSource();
    is.setCharacterStream(new StringReader(p_strXML));
    firstNode=docBuilder.parse(is);
  }
 catch (  ParserConfigurationException e) {
    throw new DBExecutionException("String_Node_Str" + e.getMessage(),e);
  }
catch (  SAXException e) {
    throw new DBExecutionException("String_Node_Str" + e.getMessage(),e);
  }
catch (  IOException e) {
    throw new DBExecutionException("String_Node_Str" + e.getMessage(),e);
  }
  return firstNode;
}

Fixed version (ground truth):
/** 
 * Parse the xml string that is passed to it and returns the upper node of that xml.
 * @param p_strXML the xml string that needs to be parsed
 * @return Node - the upper node for the xml string after parsing it.
 * @throws DBExecutionException used as wrapper to the parser exceptions
 */
private Node _parseXML(String p_strXML) throws DBExecutionException {
  if (p_strXML == null || p_strXML.length() == 0) {
    throw new DBExecutionException("String_Node_Str" + "String_Node_Str");
  }
  DocumentBuilder docBuilder;
  Node firstNode=null;
  DocumentBuilderFactory docBuilderFactory=DocumentBuilderFactory.newInstance();
  if (docBuilderFactory == null) {
    throw new DBExecutionException("String_Node_Str" + "String_Node_Str");
  }
  docBuilderFactory.setIgnoringElementContentWhitespace(true);
  try {
    docBuilder=docBuilderFactory.newDocumentBuilder();
    if (docBuilder == null) {
      throw new DBExecutionException("String_Node_Str" + "String_Node_Str");
    }
    InputSource is=new InputSource();
    is.setCharacterStream(new StringReader(p_strXML));
    firstNode=docBuilder.parse(is);
    firstNode=firstNode.getChildNodes().item(0);
  }
 catch (  ParserConfigurationException e) {
    throw new DBExecutionException("String_Node_Str" + e.getMessage(),e);
  }
catch (  SAXException e) {
    throw new DBExecutionException("String_Node_Str" + e.getMessage(),e);
  }
catch (  IOException e) {
    throw new DBExecutionException("String_Node_Str" + e.getMessage(),e);
  }
  return firstNode;
}
Program: 73808
Project: 73808
Buggy source:
/** 
 * Execute the necessary commands to create a new model in the database according to the model specification given in the task parameter
 * @param task The task to be completed.  In this case, CreateModelTask.  This will tell the DB layer to create a new model in the database.
 * @throws DBExecutionException Thrown if there is a problem executing the task.
 */
public void executeCreateModelTask(CreateModelTask task) throws DBExecutionException {
  try {
    if (_xmlContainer == null) {
      throw new DBExecutionException("String_Node_Str" + "String_Node_Str");
    }
    if (_xmlTransaction == null) {
      throw new DBExecutionException("String_Node_Str" + "String_Node_Str");
    }
    if (task == null) {
      throw new DBExecutionException("String_Node_Str" + "String_Node_Str");
    }
    XMLDBModel model=task.getXMLDBModel();
    if (model == null) {
      throw new DBExecutionException("String_Node_Str" + "String_Node_Str");
    }
    XmlDocument doc=_xmlContainer.getDocument(model.getModelName());
    if (doc != null) {
      throw new DBExecutionException("String_Node_Str" + "String_Node_Str");
    }
 else {
      _xmlContainer.putDocument(_xmlTransaction,model.getModelName(),model.getModel());
    }
  }
 catch (  XmlException e) {
    throw new DBExecutionException("String_Node_Str" + e.getMessage(),e);
  }
}

Fixed version (ground truth):
/** 
 * Execute the necessary commands to create a new model in the database according to the model specification given in the task parameter
 * @param task The task to be completed.  In this case, CreateModelTask.  This will tell the DB layer to create a new model in the database.
 * @throws DBExecutionException Thrown if there is a problem executing the task.
 */
public void executeCreateModelTask(CreateModelTask task) throws DBExecutionException {
  try {
    if (_xmlContainer == null) {
      throw new DBExecutionException("String_Node_Str" + "String_Node_Str");
    }
    if (_xmlTransaction == null) {
      throw new DBExecutionException("String_Node_Str" + "String_Node_Str");
    }
    if (task == null) {
      throw new DBExecutionException("String_Node_Str" + "String_Node_Str");
    }
    XMLDBModel model=task.getXMLDBModel();
    if (model == null) {
      throw new DBExecutionException("String_Node_Str" + "String_Node_Str");
    }
    XmlDocument doc=null;
    try {
      doc=_xmlContainer.getDocument(model.getModelName());
    }
 catch (    XmlException e) {
    }
    if (doc != null) {
      throw new DBExecutionException("String_Node_Str" + "String_Node_Str");
    }
 else {
      _xmlContainer.putDocument(_xmlTransaction,model.getModelName(),model.getModel());
    }
  }
 catch (  XmlException e) {
    throw new DBExecutionException("String_Node_Str" + e.getMessage(),e);
  }
}
Program: 73809
Project: 73809
Buggy source:
/** 
 * If the destination port is the only input port of the actor, or if the port does not have a minDelay parameter, or if there doesn't exist a destination port (in case of pure event) then the event is always safe to process. Otherwise: If the current physical time has passed the timestamp of the event minus minDelay of the port, then the event is safe to process. Otherwise the event is not safe to process, and we calculate the physical time when the event is safe to process and setup a timed interrupt.
 * @param event The event checked for safe to process
 * @return True if the event is safe to process, otherwise return false.
 * @exception IllegalActionException
 * @see #_setTimedInterrupt(Time)
 */
protected boolean _safeToProcess(PtidesEvent event) throws IllegalActionException {
  IOPort port=event.ioPort();
  if (port == null) {
    if (!event.isPureEvent()) {
      throw new IllegalActionException(port,"String_Node_Str" + "String_Node_Str");
    }
    return true;
  }
  if (port.isOutput()) {
    return true;
  }
  double minDelay=_getMinDelay(port,((PtidesEvent)event).channel(),event.isPureEvent());
  Time waitUntilPhysicalTime=event.timeStamp().subtract(minDelay);
  if (getPhysicalTime().subtract(waitUntilPhysicalTime).compareTo(_zero) >= 0) {
    return true;
  }
 else {
    _setTimedInterrupt(waitUntilPhysicalTime);
    return false;
  }
}

Fixed version (ground truth):
/** 
 * If the destination port is the only input port of the actor, or if the port does not have a minDelay parameter, or if there doesn't exist a destination port (in case of pure event) then the event is always safe to process. Otherwise: If the current physical time has passed the timestamp of the event minus minDelay of the port, then the event is safe to process. Otherwise the event is not safe to process, and we calculate the physical time when the event is safe to process and setup a timed interrupt.
 * @param event The event checked for safe to process
 * @return True if the event is safe to process, otherwise return false.
 * @exception IllegalActionException
 * @see #_setTimedInterrupt(Time)
 */
protected boolean _safeToProcess(PtidesEvent event) throws IllegalActionException {
  IOPort port=event.ioPort();
  if (port == null) {
    if (!event.isPureEvent()) {
      throw new IllegalActionException(port,"String_Node_Str" + "String_Node_Str");
    }
    return true;
  }
  if (port.isOutput()) {
    return true;
  }
  double minDelay=_getMinDelay(port,((PtidesEvent)event).channel(),event.isPureEvent());
  Time waitUntilPhysicalTime=event.timeStamp().subtract(minDelay);
  if (getPhysicalTag().timestamp.subtract(waitUntilPhysicalTime).compareTo(_zero) >= 0 && (getPhysicalTag().microstep - event.microstep() >= 0)) {
    return true;
  }
 else {
    _setTimedInterrupt(waitUntilPhysicalTime);
    return false;
  }
}
Program: 73810
Project: 73810
Buggy source:
/** 
 * Compares this RealTimeEvent with another. Compares the delivery times of these two events.
 * @param other The object comparing to.
 */
public int compareTo(Object other){
  return deliveryTime.compareTo(((RealTimeEvent)other).deliveryTime);
}

Fixed version (ground truth):
/** 
 * Compares this RealTimeEvent with another. Compares the delivery times of these two events.
 * @param other The object comparing to.
 */
public int compareTo(Object other){
  return deliveryTag.compareTo(((RealTimeEvent)other).deliveryTag);
}
Program: 73814
Project: 73814
Buggy source:
/** 
 * Construct a structure that holds a real-time event. This event saves the token to be transmitted, the port and channel this token should be deliverd to, and the time this token should be delivered at.
 * @param port The destination port.
 * @param channel The destination channel.
 * @param token The token to be delivered.
 * @param timestamp The time of delivery of this token.
 */
public RealTimeEvent(IOPort port,int channel,Token token,Time timestamp){
  this.port=port;
  this.channel=channel;
  this.token=token;
  this.deliveryTime=timestamp;
}

Fixed version (ground truth):
/** 
 * Construct a structure that holds a real-time event. This event saves the token to be transmitted, the port and channel this token should be deliverd to, and the time this token should be delivered at.
 * @param port The destination port.
 * @param channel The destination channel.
 * @param token The token to be delivered.
 * @param timestamp The time of delivery of this token.
 */
public RealTimeEvent(IOPort port,int channel,Token token,Tag tag){
  this.port=port;
  this.channel=channel;
  this.token=token;
  this.deliveryTag=tag;
}
Program: 73815
Project: 73815
Buggy source:
/** 
 * Return whether we want to preempt the currently executing actor and instead execute the earliest event on the event queue.
 * @return whether we want to preempt the executing event.
 * @exception IllegalActionException
 */
protected boolean _preemptExecutingActor() throws IllegalActionException {
  PtidesEvent event=(PtidesEvent)_eventQueue.get();
  if (event.isPureEvent()) {
    if (_debugging) {
      _debug("String_Node_Str" + "String_Node_Str" + event.actor());
    }
    return true;
  }
  Time absNextDeadline=_getAbsoluteDeadline(event);
  DoubleTimedEvent doubleTimedEvent=_currentlyExecutingStack.peek();
  List eventList=(List<PtidesEvent>)(doubleTimedEvent.contents);
  for (int i=0; i < eventList.size(); i++) {
    Time absExecutingDeadline=_getAbsoluteDeadline((PtidesEvent)eventList.get(i));
    if (absExecutingDeadline.compareTo(absNextDeadline) <= 0) {
      return false;
    }
  }
  if (_debugging) {
    _debug("String_Node_Str" + "String_Node_Str" + ((PtidesEvent)eventList.get(0)).actor() + "String_Node_Str"+ event.actor()+ "String_Node_Str"+ getPhysicalTime());
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Return whether we want to preempt the currently executing actor and instead execute the earliest event on the event queue.
 * @return whether we want to preempt the executing event.
 * @exception IllegalActionException
 */
protected boolean _preemptExecutingActor() throws IllegalActionException {
  PtidesEvent event=(PtidesEvent)_eventQueue.get();
  if (event.isPureEvent()) {
    if (_debugging) {
      _debug("String_Node_Str" + "String_Node_Str" + event.actor());
    }
    return true;
  }
  Time absNextDeadline=_getAbsoluteDeadline(event);
  DoubleTimedEvent doubleTimedEvent=_currentlyExecutingStack.peek();
  List eventList=(List<PtidesEvent>)(doubleTimedEvent.contents);
  for (int i=0; i < eventList.size(); i++) {
    Time absExecutingDeadline=_getAbsoluteDeadline((PtidesEvent)eventList.get(i));
    if (absExecutingDeadline.compareTo(absNextDeadline) <= 0) {
      return false;
    }
  }
  if (_debugging) {
    _debug("String_Node_Str" + "String_Node_Str" + ((PtidesEvent)eventList.get(0)).actor() + "String_Node_Str"+ event.actor()+ "String_Node_Str"+ getPhysicalTag().timestamp+ "String_Node_Str"+ getPhysicalTag().microstep);
  }
  return true;
}
Program: 73817
Project: 73817
Buggy source:
/** 
 * Construct a Tag.
 * @param timestamp The timestamp.
 * @param microstep The microstep.
 */
public Tag(Time timestamp,int microstep){
  this.timestamp=timestamp;
  this.microstep=microstep;
}

Fixed version (ground truth):
/** 
 * Construct an empty Tag.
 */
public Tag(){
}
Program: 73819
Project: 73819
Buggy source:
/** 
 * Generate code for replacing the get() macro. This delegates to the receiver adapter for the specified channel and asks it to generate the get code.
 * @param channel The channel for which to generate the get code.
 * @param offset The offset in the array representation of the port.
 * @return The code that gets data from the specified channel.
 * @exception IllegalActionException If the receiver adapter is not found or it encounters an error while generating the get code.
 */
public String generateGetCode(String channel,String offset) throws IllegalActionException {
  Receiver[][] receivers=getReceiverAdapters();
  int channelIndex=Integer.parseInt(channel);
  if (receivers.length != 0) {
    if (receivers[channelIndex].length > 1) {
      throw new IllegalActionException("String_Node_Str" + "String_Node_Str");
    }
    if (receivers[channelIndex].length > 0) {
      return receivers[channelIndex][0].generateGetCode(offset);
    }
  }
  Type type=((TypedIOPort)getComponent()).getType();
  if (((TypedIOPort)getComponent()) instanceof ParameterPort) {
    if (type == BaseType.STRING) {
      return "String_Node_Str";
    }
  }
  String typeString=getCodeGenerator().codeGenType(type);
  return "String_Node_Str" + getCodeGenerator().codeGenType(BaseType.INT) + "String_Node_Str"+ typeString+ "String_Node_Str";
}

Fixed version (ground truth):
/** 
 * Generate code for replacing the get() macro. This delegates to the receiver adapter for the specified channel and asks it to generate the get code.
 * @param channel The channel for which to generate the get code.
 * @param offset The offset in the array representation of the port.
 * @return The code that gets data from the specified channel.
 * @exception IllegalActionException If the receiver adapter is not found or it encounters an error while generating the get code.
 */
public String generateGetCode(String channel,String offset) throws IllegalActionException {
  Receiver[][] receivers=getReceiverAdapters();
  int channelIndex=Integer.parseInt(channel);
  if (receivers.length != 0) {
    if (receivers[channelIndex].length > 1) {
      throw new IllegalActionException("String_Node_Str" + "String_Node_Str");
    }
    if (receivers[channelIndex].length > 0) {
      return receivers[channelIndex][0].generateGetCode(offset);
    }
  }
  Type type=((TypedIOPort)getComponent()).getType();
  if (((TypedIOPort)getComponent()) instanceof ParameterPort) {
    return ((ParameterPort)getComponent()).getParameter().getValueAsString();
  }
  String typeString=getCodeGenerator().codeGenType(type);
  return "String_Node_Str" + getCodeGenerator().codeGenType(BaseType.INT) + "String_Node_Str"+ typeString+ "String_Node_Str";
}
Program: 73820
Project: 73820
Buggy source:
/** 
 * Generate code to check if the receiver has a token.    This delegates to the receiver adapter for the specified channel and asks it to generate the hasToken code.
 * @param channel The channel for which to generate the hasToken code.
 * @param offset The offset in the array representation of the port.
 * @return The code that checks whether there is data in the specified channel.
 * @exception IllegalActionException If the receiver adapter isnot found or it encounters an error while generating the hasToken code.
 */
public String generateHasTokenCode(String channel,String offset) throws IllegalActionException {
  Receiver[][] receivers=getReceiverAdapters();
  int channelNumber=0;
  channelNumber=Integer.parseInt(channel);
  if (receivers.length != 0) {
    if (receivers[channelNumber].length > 1) {
      throw new IllegalActionException("String_Node_Str" + "String_Node_Str");
    }
    if (receivers[channelNumber].length > 0) {
      return receivers[channelNumber][0].generateHasTokenCode(offset);
    }
  }
  return "String_Node_Str";
}

Fixed version (ground truth):
/** 
 * Generate code to check if the receiver has a token. This delegates to the receiver adapter for the specified channel and asks it to generate the hasToken code.
 * @param channel The channel for which to generate the hasToken code.
 * @param offset The offset in the array representation of the port.
 * @return The code that checks whether there is data in the specifiedchannel.
 * @exception IllegalActionException If the receiver adapter is not found or it encounters an error while generating the hasToken code.
 */
public String generateHasTokenCode(String channel,String offset) throws IllegalActionException {
  Receiver[][] receivers=getReceiverAdapters();
  int channelNumber=0;
  channelNumber=Integer.parseInt(channel);
  if (receivers.length != 0) {
    if (receivers[channelNumber].length > 1) {
      throw new IllegalActionException("String_Node_Str" + "String_Node_Str");
    }
    if (receivers[channelNumber].length > 0) {
      return receivers[channelNumber][0].generateHasTokenCode(offset);
    }
  }
  return "String_Node_Str";
}
Program: 73821
Project: 73821
Buggy source:
/** 
 * Get the adapters for the remote receivers connected to this port.
 * @return The adapters.
 * @exception IllegalActionException Thrown if {@link #getAdapter(Object)}throws it.
 */
public Receiver[][] getRemoteReceiverAdapters() throws IllegalActionException {
  ptolemy.actor.IOPort port=(ptolemy.actor.IOPort)getComponent();
  ptolemy.actor.Receiver[][] farReceivers=port.getRemoteReceivers();
  Receiver[][] receiverAdapters=new Receiver[farReceivers.length][];
  for (int i=0; i < farReceivers.length; i++) {
    if (farReceivers[i] != null) {
      receiverAdapters[i]=new Receiver[farReceivers[i].length];
      for (int j=0; j < farReceivers[i].length; j++) {
        receiverAdapters[i][j]=(Receiver)getAdapter(farReceivers[i][j]);
      }
    }
  }
  return receiverAdapters;
}

Fixed version (ground truth):
/** 
 * Get the adapters for the remote receivers connected to this port.
 * @return The adapters.
 * @exception IllegalActionException Thrown if  {@link #getAdapter(Object)} throws it.
 */
public Receiver[][] getRemoteReceiverAdapters() throws IllegalActionException {
  ptolemy.actor.IOPort port=(ptolemy.actor.IOPort)getComponent();
  ptolemy.actor.Receiver[][] farReceivers=port.getRemoteReceivers();
  Receiver[][] receiverAdapters=new Receiver[farReceivers.length][];
  for (int i=0; i < farReceivers.length; i++) {
    if (farReceivers[i] != null) {
      receiverAdapters[i]=new Receiver[farReceivers[i].length];
      for (int j=0; j < farReceivers[i].length; j++) {
        receiverAdapters[i][j]=(Receiver)getAdapter(farReceivers[i][j]);
      }
    }
  }
  return receiverAdapters;
}
Program: 73822
Project: 73822
Buggy source:
/** 
 * Generate code for replacing the get() macro. This delegates to the receiver adapter for the specified channel and asks it to generate the get code.
 * @param channel The channel for which to generate the get code.
 * @param offset The offset in the array representation of the port.
 * @return The code that gets data from the specified channel.
 * @exception IllegalActionException If the receiver adapter isnot found or it encounters an error while generating the get code.
 */
public String generateGetCode(String channel,String offset) throws IllegalActionException {
  Receiver[][] receivers=getReceiverAdapters();
  int channelIndex=Integer.parseInt(channel);
  if (receivers.length != 0) {
    if (receivers[channelIndex].length > 1) {
      throw new IllegalActionException("String_Node_Str" + "String_Node_Str");
    }
    if (receivers[channelIndex].length > 0) {
      return receivers[channelIndex][0].generateGetCode(offset);
    }
  }
  Type type=((TypedIOPort)getComponent()).getType();
  String typeString=getCodeGenerator().codeGenType(type);
  return "String_Node_Str" + getCodeGenerator().codeGenType(BaseType.INT) + "String_Node_Str"+ typeString+ "String_Node_Str";
}

Fixed version (ground truth):
/** 
 * Generate code for replacing the get() macro. This delegates to the receiver adapter for the specified channel and asks it to generate the get code.
 * @param channel The channel for which to generate the get code.
 * @param offset The offset in the array representation of the port.
 * @return The code that gets data from the specified channel.
 * @exception IllegalActionException If the receiver adapter is not found or it encounters an error while generating the get code.
 */
public String generateGetCode(String channel,String offset) throws IllegalActionException {
  Receiver[][] receivers=getReceiverAdapters();
  int channelIndex=Integer.parseInt(channel);
  if (receivers.length != 0) {
    if (receivers[channelIndex].length > 1) {
      throw new IllegalActionException("String_Node_Str" + "String_Node_Str");
    }
    if (receivers[channelIndex].length > 0) {
      return receivers[channelIndex][0].generateGetCode(offset);
    }
  }
  Type type=((TypedIOPort)getComponent()).getType();
  if (((TypedIOPort)getComponent()) instanceof ParameterPort) {
    if (type == BaseType.STRING) {
      return "String_Node_Str";
    }
  }
  String typeString=getCodeGenerator().codeGenType(type);
  return "String_Node_Str" + getCodeGenerator().codeGenType(BaseType.INT) + "String_Node_Str"+ typeString+ "String_Node_Str";
}
Program: 73823
Project: 73823
Buggy source:
/** 
 * Get the adapters for receiver contained in this port.
 * @return The adapters.
 * @exception IllegalActionException Thrown if {@link #getAdapter(Object)}throws it.
 */
public Receiver[][] getReceiverAdapters() throws IllegalActionException {
  ptolemy.actor.IOPort port=(ptolemy.actor.IOPort)getComponent();
  ptolemy.actor.Receiver[][] receivers=port.getReceivers();
  Receiver[][] receiverAdapters=new Receiver[receivers.length][];
  for (int i=0; i < receivers.length; i++) {
    receiverAdapters[i]=new Receiver[receivers[i].length];
    for (int j=0; j < receivers[i].length; j++) {
      receiverAdapters[i][j]=(Receiver)getAdapter(receivers[i][j]);
    }
  }
  return receiverAdapters;
}

Fixed version (ground truth):
/** 
 * Get the adapters for receiver contained in this port.
 * @return The adapters.
 * @exception IllegalActionException Thrown if  {@link #getAdapter(Object)} throws it.
 */
public Receiver[][] getReceiverAdapters() throws IllegalActionException {
  ptolemy.actor.IOPort port=(ptolemy.actor.IOPort)getComponent();
  ptolemy.actor.Receiver[][] receivers=port.getReceivers();
  Receiver[][] receiverAdapters=new Receiver[receivers.length][];
  for (int i=0; i < receivers.length; i++) {
    receiverAdapters[i]=new Receiver[receivers[i].length];
    for (int j=0; j < receivers[i].length; j++) {
      receiverAdapters[i][j]=(Receiver)getAdapter(receivers[i][j]);
    }
  }
  return receiverAdapters;
}
Program: 73824
Project: 73824
Buggy source:
/** 
 * Generate code for replacing the send() macro. This delegates to the receiver adapter for the specified channel and asks it to generate the send code.
 * @param channel The channel for which to generate the send code.
 * @param offset The offset in the array representation of the port.
 * @param dataToken The token to be sent.
 * @return The code that sends data to the specified channel.
 * @exception IllegalActionException If the receiver adapter isnot found or it encounters an error while generating the send code.
 */
public String generatePutCode(String channel,String offset,String dataToken) throws IllegalActionException {
  Receiver[][] remoteReceivers=getRemoteReceiverAdapters();
  int channelIndex=Integer.parseInt(channel);
  if ((remoteReceivers == null) || (remoteReceivers.length <= channelIndex) || (remoteReceivers[channelIndex] == null)) {
    return "String_Node_Str";
  }
  StringBuffer code=new StringBuffer();
  for (int i=0; i < remoteReceivers[channelIndex].length; i++) {
    code.append(remoteReceivers[channelIndex][i].generatePutCode((ptolemy.actor.IOPort)this.getComponent(),offset,dataToken));
  }
  return code.toString();
}

Fixed version (ground truth):
/** 
 * Generate code for replacing the send() macro. This delegates to the receiver adapter for the specified channel and asks it to generate the send code.
 * @param channel The channel for which to generate the send code.
 * @param offset The offset in the array representation of the port.
 * @param dataToken The token to be sent.
 * @return The code that sends data to the specified channel.
 * @exception IllegalActionException If the receiver adapter is not found or it encounters an error while generating the send code.
 */
public String generatePutCode(String channel,String offset,String dataToken) throws IllegalActionException {
  Receiver[][] remoteReceivers=getRemoteReceiverAdapters();
  int channelIndex=Integer.parseInt(channel);
  if ((remoteReceivers == null) || (remoteReceivers.length <= channelIndex) || (remoteReceivers[channelIndex] == null)) {
    return "String_Node_Str";
  }
  StringBuffer code=new StringBuffer();
  for (int i=0; i < remoteReceivers[channelIndex].length; i++) {
    code.append(remoteReceivers[channelIndex][i].generatePutCode((ptolemy.actor.IOPort)this.getComponent(),offset,dataToken));
  }
  return code.toString();
}
Program: 73825
Project: 73825
Buggy source:
/** 
 * Generate the initialize code for this IOPort. The initialize code is generated by appending the initialize code for each receiver contained by this IOPort.
 * @return The generated initialize code.
 * @exception IllegalActionException If an error occurs whengetting the receiver adapters or generating their initialize code.
 */
public String generateInitializeCode() throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  Receiver[][] receivers=getReceiverAdapters();
  for (int i=0; i < receivers.length; i++) {
    for (int j=0; j < receivers[i].length; j++) {
      code.append(receivers[i][j].generateInitializeCode());
    }
  }
  return code.toString();
}

Fixed version (ground truth):
/** 
 * Generate the initialize code for this IOPort. The initialize code is generated by appending the initialize code for each receiver contained by this IOPort.
 * @return The generated initialize code.
 * @exception IllegalActionException If an error occurs when getting the receiver adapters or generating their initialize code.
 */
public String generateInitializeCode() throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  Receiver[][] receivers=getReceiverAdapters();
  for (int i=0; i < receivers.length; i++) {
    for (int j=0; j < receivers[i].length; j++) {
      code.append(receivers[i][j].generateInitializeCode());
    }
  }
  return code.toString();
}
Program: 73826
Project: 73826
Buggy source:
/** 
 * Generate fire code. The method generates code that loops through each input [multi-ports] and combines (add or subtract) them.
 * @return The generated code.
 * @exception IllegalActionException If the code stream encounters anerror in processing the specified code block(s).
 */
protected String _generateFireCode() throws IllegalActionException {
  super._generateFireCode();
  ptolemy.actor.lib.MultiplyDivide actor=(ptolemy.actor.lib.MultiplyDivide)getComponent();
  String outputType=getCodeGenerator().codeGenType(actor.output.getType());
  String multiplyType=getCodeGenerator().codeGenType(actor.multiply.getType());
  String divideType=getCodeGenerator().codeGenType(actor.divide.getType());
  ArrayList args=new ArrayList();
  CodeStream codeStream=getTemplateParser().getCodeStream();
  codeStream.appendCodeBlock("String_Node_Str");
  args.add("String_Node_Str");
  args.add(outputType);
  args.add(multiplyType);
  for (int i=0; i < actor.multiply.getWidth(); i++) {
    args.set(0,Integer.toString(i));
    codeStream.appendCodeBlock("String_Node_Str",args);
  }
  for (int i=0; i < actor.divide.getWidth(); i++) {
    args.set(0,Integer.toString(i));
    args.set(2,divideType);
    codeStream.appendCodeBlock("String_Node_Str",args);
  }
  codeStream.appendCodeBlock("String_Node_Str");
  return processCode(codeStream.toString());
}

Fixed version (ground truth):
/** 
 * Generate fire code. The method generates code that loops through each input [multi-ports] and combines (add or subtract) them.
 * @return The generated code.
 * @exception IllegalActionException If the code stream encounters anerror in processing the specified code block(s).
 */
protected String _generateFireCode() throws IllegalActionException {
  super._generateFireCode();
  ptolemy.actor.lib.MultiplyDivide actor=(ptolemy.actor.lib.MultiplyDivide)getComponent();
  String outputType=getCodeGenerator().codeGenType(actor.output.getType());
  String multiplyType=getCodeGenerator().codeGenType(actor.multiply.getType());
  String divideType=getCodeGenerator().codeGenType(actor.divide.getType());
  boolean divideOnly=!actor.multiply.isOutsideConnected();
  ArrayList<String> args=new ArrayList<String>();
  ArrayList<String> initArgs=new ArrayList<String>();
  if (divideOnly) {
    initArgs.add(divideType);
  }
 else {
    initArgs.add(multiplyType);
    initArgs.add(outputType);
  }
  CodeStream codeStream=getTemplateParser().getCodeStream();
  codeStream.appendCodeBlock(divideOnly ? "String_Node_Str" : "String_Node_Str",initArgs);
  args.add("String_Node_Str");
  args.add(outputType);
  args.add(multiplyType);
  for (int i=1; i < actor.multiply.getWidth(); i++) {
    args.set(0,Integer.toString(i));
    codeStream.appendCodeBlock("String_Node_Str",args);
  }
  for (int i=divideOnly ? 1 : 0; i < actor.divide.getWidth(); i++) {
    args.set(0,Integer.toString(i));
    args.set(2,divideType);
    codeStream.appendCodeBlock("String_Node_Str",args);
  }
  codeStream.appendCodeBlock("String_Node_Str");
  return processCode(codeStream.toString());
}
Program: 73828
Project: 73828
Buggy source:
/** 
 * Output an Ipl image.
 * @exception IllegalActionException If thrown while writing to the port.   
 */
public void fire() throws IllegalActionException {
  if (input.hasToken(0)) {
    ObjectToken inputToken=(ObjectToken)input.get(0);
    Image inputObject=inputToken.getValue();
    if (!(inputObject instanceof Image)) {
      throw new IllegalActionException(this,"String_Node_Str" + inputObject.getClass());
    }
    _frame=new IplImage();
    output.send(0,new ObjectToken(_frame));
  }
}

Fixed version (ground truth):
/** 
 * Output an Ipl image.
 * @exception IllegalActionException If thrown while writing to the port.   
 */
public void fire() throws IllegalActionException {
  if (input.hasToken(0)) {
    ObjectToken inputToken=(ObjectToken)input.get(0);
    Image inputObject=(Image)inputToken.getValue();
    if (!(inputObject instanceof Image)) {
      throw new IllegalActionException(this,"String_Node_Str" + inputObject.getClass());
    }
    _frame=new IplImage();
    output.send(0,new ObjectToken(_frame));
  }
}
Program: 73829
Project: 73829
Buggy source:
/** 
 * Create a Kieler KNode for a Ptolemy inner port. That is the graphical representation for a port of a CompositeActor if you see the contents of this CompositeActor. It is represented by a node where the connection may touch the node corresponding to its type (input, output, both) on the right, left or top. For now this results a crude approximation of the node, because the figure of the original Ptolemy port cannot be obtained by the layout target. Hence we cannot ask the port for its original bounds.
 * @param node The Ptolemy inner port.
 * @return A new Kieler KNode corresponding to the Ptolemy inner port.
 */
private KNode _createKNodeForPort(Port node){
  KNode knode=KimlLayoutUtil.createInitializedNode();
  KShapeLayout layout=KimlLayoutUtil.getShapeLayout(knode);
  layout.setHeight(DEFAULT_INNER_PORT_HEIGHT);
  layout.setWidth(DEFAULT_INNER_PORT_WIDTH);
  LayoutOptions.setFixedSize(layout,true);
  return knode;
}

Fixed version (ground truth):
/** 
 * Create a Kieler KNode for a Ptolemy inner port. That is the graphical representation for a port of a CompositeActor if you see the contents of this CompositeActor. It is represented by a node where the connection may touch the node corresponding to its type (input, output, both) on the right, left or top. For now this results a crude approximation of the node, because the figure of the original Ptolemy port cannot be obtained by the layout target. Hence we cannot ask the port for its original bounds.
 * @param divaLocation Diva Representation of an inner port 
 * @param port The Ptolemy inner port.
 * @return A new Kieler KNode corresponding to the Ptolemy inner port.
 */
private KNode _createKNodeForPort(Object divaLocation,Port port){
  KNode knode=KimlLayoutUtil.createInitializedNode();
  KShapeLayout layout=KimlLayoutUtil.getShapeLayout(knode);
  Rectangle2D bounds=this.getLayoutTarget().getBounds(divaLocation);
  layout.setHeight((float)bounds.getHeight() + INNER_PORT_HEIGHT_OFFSET);
  layout.setWidth((float)bounds.getWidth());
  LayoutOptions.setFixedSize(layout,true);
  return knode;
}
Program: 73832
Project: 73832
Buggy source:
/** 
 * Flush all buffered change requests to the given Actor. Reset the buffer afterwards.
 * @param actor The target of the change request, e.g. the composite actorcontaining the objects for which changes are requested.
 */
protected void _performChangeRequest(CompositeActor actor){
  if (_momlChangeRequest.toString().trim().equals("String_Node_Str")) {
    return;
  }
  _momlChangeRequest.insert(0,"String_Node_Str");
  _momlChangeRequest.append("String_Node_Str");
  MoMLChangeRequest request=new MoMLChangeRequest(this,actor,_momlChangeRequest.toString());
  request.setUndoable(true);
  request.setMergeWithPreviousUndo(true);
  actor.requestChange(request);
  _momlChangeRequest=new StringBuffer();
}

Fixed version (ground truth):
/** 
 * Flush all buffered change requests to the given Actor. Reset the buffer afterwards.
 * @param actor The target of the change request, e.g. the composite actorcontaining the objects for which changes are requested.
 */
protected void _performChangeRequest(CompositeActor actor){
  if (_momlChangeRequest.toString().trim().equals("String_Node_Str")) {
    return;
  }
  _momlChangeRequest.insert(0,"String_Node_Str");
  _momlChangeRequest.append("String_Node_Str");
  MoMLChangeRequest request=new MoMLChangeRequest(this,actor,_momlChangeRequest.toString());
  request.setUndoable(true);
  if (_anyRequestsSoFar) {
    request.setMergeWithPreviousUndo(true);
  }
  actor.requestChange(request);
  _momlChangeRequest=new StringBuffer();
  _anyRequestsSoFar=true;
}
Program: 73833
Project: 73833
Buggy source:
/** 
 * Create a MoMLChangeRequest to move a Ptolemy model object and schedule it immediately. The request is addressed to a specific NamedObj in the Ptolemy model and hence does not get buffered because there is only exactly one move request per layout run per node.
 * @param vertex Ptolemy node to be moved
 * @param relation Ptolemy Relation to be moved
 * @param x new coordinate
 * @param y new coordinate
 */
protected static void _setLocation(Vertex vertex,Relation relation,double x,double y){
  String moml="String_Node_Str" + vertex.getName() + "String_Node_Str"+ x+ "String_Node_Str"+ y+ "String_Node_Str";
  MoMLChangeRequest request=new MoMLChangeRequest(vertex,relation,moml);
  request.setUndoable(true);
  request.setMergeWithPreviousUndo(true);
  relation.requestChange(request);
}

Fixed version (ground truth):
/** 
 * Create a MoMLChangeRequest to move a Ptolemy model object and schedule it immediately. The request is addressed to a specific NamedObj in the Ptolemy model and hence does not get buffered because there is only exactly one move request per layout run per node.
 * @param vertex Ptolemy node to be moved
 * @param relation Ptolemy Relation to be moved
 * @param x new coordinate
 * @param y new coordinate
 */
protected void _setLocation(Vertex vertex,Relation relation,double x,double y){
  String moml="String_Node_Str" + vertex.getName() + "String_Node_Str"+ x+ "String_Node_Str"+ y+ "String_Node_Str";
  MoMLChangeRequest request=new MoMLChangeRequest(vertex,relation,moml);
  request.setUndoable(true);
  if (_anyRequestsSoFar) {
    request.setMergeWithPreviousUndo(true);
  }
  relation.requestChange(request);
  _anyRequestsSoFar=true;
}
Program: 73834
Project: 73834
Buggy source:
/** 
 * Generate the fire code. In this base class, add the name of the associated component in the comment. It checks the inline parameter of the code generator. If the value is true, it generates the actor fire code and the necessary type conversion code. Otherwise, it generate an invocation to the actor function that is generated by generateFireFunctionCode.
 * @return The generated code.
 * @exception IllegalActionException Not thrown in this base class.
 */
public String generateFireCode() throws IllegalActionException {
  List args=new LinkedList();
  CodeStream _codeStream=_templateParser.getCodeStream();
  ptolemy.domains.ptides.lib.luminary.GPOutputDevice actor=(ptolemy.domains.ptides.lib.luminary.GPOutputDevice)getComponent();
  PtidesBasicDirector adapter=(PtidesBasicDirector)getAdapter(actor.getDirector());
  args.add((adapter.actuators.get(actor)).toString());
  _codeStream.clear();
  _codeStream.appendCodeBlock("String_Node_Str",args);
  return processCode(_codeStream.toString());
}

Fixed version (ground truth):
/** 
 * Generate the fire code. In this base class, add the name of the associated component in the comment. It checks the inline parameter of the code generator. If the value is true, it generates the actor fire code and the necessary type conversion code. Otherwise, it generate an invocation to the actor function that is generated by generateFireFunctionCode.
 * @return The generated code.
 * @exception IllegalActionException Not thrown in this base class.
 */
public String generateFireCode() throws IllegalActionException {
  List args=new LinkedList();
  CodeStream _codeStream=_templateParser.getCodeStream();
  ptolemy.domains.ptides.lib.ActuatorOutputDevice actor=(ptolemy.domains.ptides.lib.ActuatorOutputDevice)getComponent();
  PtidesBasicDirector adapter=(PtidesBasicDirector)getAdapter(actor.getDirector());
  args.add((adapter.actuators.get(actor)).toString());
  _codeStream.clear();
  _codeStream.appendCodeBlock("String_Node_Str",args);
  return processCode(_codeStream.toString());
}
Program: 73835
Project: 73835
Buggy source:
/** 
 * Resizes the screen.
 * @see javax.media.opengl.GLEventListener#reshape(javax.media.opengl.GLAutoDrawable,int,int,int,int)
 */
public void reshape(GLAutoDrawable gLDrawable,int x,int y,int width,int height){
  final GL gl=drawable.getGL();
  gl.glViewport(0,0,width,height);
  if (height <= 0) {
    height=1;
  }
}

Fixed version (ground truth):
/** 
 * Resizes the screen.
 * @see javax.media.opengl.GLEventListener#reshape(javax.media.opengl.GLAutoDrawable,int,int,int,int)
 */
public void reshape(GLAutoDrawable gLDrawable,int x,int y,int width,int height){
  final GL gl=gLDrawable.getGL();
  gl.glViewport(0,0,width,height);
  if (height <= 0) {
    height=1;
  }
}
Program: 73840
Project: 73840
Buggy source:
/** 
 * Each receiver is associated with a director, return that director.
 * @return The director associated with this receiver.
 * @exception IllegalActionException FIXME: this is not exactly correct.
 */
protected StaticSchedulingDirector _getDirectorForReceiver() throws IllegalActionException {
  return (StaticSchedulingDirector)super._getDirectorForReceiver();
}

Fixed version (ground truth):
/** 
 * Each receiver is associated with a director, return that director.
 * @return The director associated with this receiver.
 * @exception IllegalActionException FIXME: this is not exactly correct. This is probably because the information of the receiver is in the director of  the container?
 */
protected StaticSchedulingDirector _getDirectorForReceiver() throws IllegalActionException {
  return (StaticSchedulingDirector)super._getDirectorForReceiver();
}
Program: 73851
Project: 73851
Buggy source:
/** 
 * Returns the LCM value.
 */
public int getLCM(){
  return _lcm;
}

Fixed version (ground truth):
/** 
 * Returns the LCM value.
 * @return an int representing the LCM value
 */
public int getLCM(){
  return _lcm;
}
Program: 73853
Project: 73853
Buggy source:
/** 
 * Called once when the SAX driver sees the end of a document, even if errors occured.
 */
public void endDocument(){
}

Fixed version (ground truth):
/** 
 * Called once when the SAX driver sees the end of a document, even if errors occurred.
 */
public void endDocument(){
}
Program: 73854
Project: 73854
Buggy source:
/** 
 * Return the array list index of the variable to be defuzzified. 
 */
public int getIndexToDefuzzify(){
  return _toDefuzzyify;
}

Fixed version (ground truth):
/** 
 * Return the array list index of the variable to be defuzzified. 
 * @return Return the array list index of the variable to be defuzzified.
 */
public int getIndexToDefuzzify(){
  return _toDefuzzyify;
}