nus-yam/ex-repair huggingface dataset:
Program: 73432
Project: 73432
Buggy source:
/** 
 * Update the base component units map with the set of base units from another derived units' base component units map.
 * @param baseUnitsMap The base component units map to be updated.
 * @param baseUnitsMapFromDerivedUnit The base component units map from anotherderived unit concept to be added to the baseUnitsMap.
 */
private static void _addDerivedUnit(Map<BaseDimensionRepresentativeConcept,List<BaseUnitConcept>[]> baseUnitsMap,Map<BaseDimensionRepresentativeConcept,List<BaseUnitConcept>[]> baseUnitsMapFromDerivedUnit){
  for (  BaseDimensionRepresentativeConcept baseDimension : baseUnitsMapFromDerivedUnit.keySet()) {
    List<BaseUnitConcept>[] arrayOfBaseUnitsListsFromDerivedUnit=baseUnitsMapFromDerivedUnit.get(baseDimension);
    List<BaseUnitConcept>[] arrayOfBaseUnitsLists=baseUnitsMap.get(baseDimension);
    if (arrayOfBaseUnitsLists == null) {
      arrayOfBaseUnitsLists=arrayOfBaseUnitsListsFromDerivedUnit;
    }
 else {
      arrayOfBaseUnitsLists[POSITIVE_EXPONENT_INDEX].addAll(arrayOfBaseUnitsListsFromDerivedUnit[POSITIVE_EXPONENT_INDEX]);
      arrayOfBaseUnitsLists[NEGATIVE_EXPONENT_INDEX].addAll(arrayOfBaseUnitsListsFromDerivedUnit[NEGATIVE_EXPONENT_INDEX]);
    }
    baseUnitsMap.put(baseDimension,arrayOfBaseUnitsLists);
  }
}

Fixed version (ground truth):
/** 
 * Update the base component units map with the set of base units from another derived units' base component units map.
 * @param baseUnitsMap The base component units map to be updated.
 * @param baseUnitsMapFromDerivedUnit The base component units map from anotherderived unit concept to be added to the baseUnitsMap.
 */
private static void _addDerivedUnit(Map<BaseDimensionRepresentativeConcept,List<BaseUnitConcept>[]> baseUnitsMap,Map<BaseDimensionRepresentativeConcept,List<BaseUnitConcept>[]> baseUnitsMapFromDerivedUnit){
  for (  Map.Entry<BaseDimensionRepresentativeConcept,List<BaseUnitConcept>[]> baseUnitsMapEntry : baseUnitsMapFromDerivedUnit.entrySet()) {
    BaseDimensionRepresentativeConcept baseDimension=baseUnitsMapEntry.getKey();
    List<BaseUnitConcept>[] arrayOfBaseUnitsListsFromDerivedUnit=baseUnitsMapEntry.getValue();
    List<BaseUnitConcept>[] arrayOfBaseUnitsLists=baseUnitsMap.get(baseDimension);
    if (arrayOfBaseUnitsLists == null) {
      arrayOfBaseUnitsLists=arrayOfBaseUnitsListsFromDerivedUnit;
    }
 else {
      arrayOfBaseUnitsLists[POSITIVE_EXPONENT_INDEX].addAll(arrayOfBaseUnitsListsFromDerivedUnit[POSITIVE_EXPONENT_INDEX]);
      arrayOfBaseUnitsLists[NEGATIVE_EXPONENT_INDEX].addAll(arrayOfBaseUnitsListsFromDerivedUnit[NEGATIVE_EXPONENT_INDEX]);
    }
    baseUnitsMap.put(baseDimension,arrayOfBaseUnitsLists);
  }
}
Program: 73435
Project: 73435
Buggy source:
/** 
 * Return a new list of BaseUnitConcepts that removes all the elements of the elementsToBeRemoved list from the originalList.
 * @param originalList The original list of BaseUnitConcepts.
 * @param elementsToBeRemoved The list of BaseUnitConcepts to be removedfrom the originalList.
 * @return A new list that contains all the elements of the original listminus the elements from the elementsToBeRemoved list.
 * @throws IllegalActionException Thrown if the original list is null,or the original list has fewer elements than the elementsToBeRemoved list.
 */
private static List<BaseUnitConcept> _removeMatchingListElements(List<BaseUnitConcept> originalList,List<BaseUnitConcept> elementsToBeRemoved) throws IllegalActionException {
  if (originalList == null) {
    throw new IllegalActionException("String_Node_Str" + "String_Node_Str");
  }
 else   if (originalList.size() < elementsToBeRemoved.size()) {
    throw new IllegalActionException("String_Node_Str" + "String_Node_Str" + "String_Node_Str");
  }
 else   if (elementsToBeRemoved == null || elementsToBeRemoved.isEmpty()) {
    return new ArrayList<BaseUnitConcept>(originalList);
  }
 else {
    List<BaseUnitConcept> resultList=new ArrayList<BaseUnitConcept>(originalList);
    for (    BaseUnitConcept unitToBeRemoved : elementsToBeRemoved) {
      resultList.remove(unitToBeRemoved);
    }
    return resultList;
  }
}

Fixed version (ground truth):
/** 
 * Return a new list of BaseUnitConcepts that removes all the elements of the elementsToBeRemoved list from the originalList.
 * @param originalList The original list of BaseUnitConcepts.
 * @param elementsToBeRemoved The list of BaseUnitConcepts to be removedfrom the originalList.
 * @return A new list that contains all the elements of the original listminus the elements from the elementsToBeRemoved list.
 * @throws IllegalActionException Thrown if the original list is null,or the original list has fewer elements than the elementsToBeRemoved list.
 */
private static List<BaseUnitConcept> _removeMatchingListElements(List<BaseUnitConcept> originalList,List<BaseUnitConcept> elementsToBeRemoved) throws IllegalActionException {
  if (originalList == null) {
    throw new IllegalActionException("String_Node_Str" + "String_Node_Str");
  }
 else   if (elementsToBeRemoved == null || elementsToBeRemoved.isEmpty()) {
    return new ArrayList<BaseUnitConcept>(originalList);
  }
 else   if (originalList.size() < elementsToBeRemoved.size()) {
    throw new IllegalActionException("String_Node_Str" + "String_Node_Str" + "String_Node_Str");
  }
 else {
    List<BaseUnitConcept> resultList=new ArrayList<BaseUnitConcept>(originalList);
    for (    BaseUnitConcept unitToBeRemoved : elementsToBeRemoved) {
      resultList.remove(unitToBeRemoved);
    }
    return resultList;
  }
}
Program: 73436
Project: 73436
Buggy source:
/** 
 * Apply the individual unit conversion factors and offsets for each component unit to the conversion factor and offset for the derived unit.
 * @throws IllegalActionException Thrown if there is a problem gettingthe component dimensions.
 */
private void _applyComponentUnitConversionFactors() throws IllegalActionException {
  Map<DimensionRepresentativeConcept,Integer> componentDimensions=((DerivedDimensionRepresentativeConcept)_representative).getComponentDimensions();
  for (  DimensionRepresentativeConcept dimension : componentDimensions.keySet()) {
    int dimensionExponent=componentDimensions.get(dimension).intValue();
    List<UnitConcept> unitsList=_componentUnits.get(dimension);
    for (    UnitConcept unit : unitsList) {
      if (dimensionExponent > 0) {
        _unitFactor=(ScalarToken)_unitFactor.multiply(unit._unitFactor);
      }
 else       if (dimensionExponent < 0) {
        _unitFactor=(ScalarToken)_unitFactor.divide(unit._unitFactor);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Apply the individual unit conversion factors and offsets for each component unit to the conversion factor and offset for the derived unit.
 * @throws IllegalActionException Thrown if there is a problem gettingthe component dimensions.
 */
private void _applyComponentUnitConversionFactors() throws IllegalActionException {
  Map<DimensionRepresentativeConcept,Integer> componentDimensions=((DerivedDimensionRepresentativeConcept)_representative).getComponentDimensions();
  for (  Map.Entry<DimensionRepresentativeConcept,Integer> componentDimensionsMapEntry : componentDimensions.entrySet()) {
    DimensionRepresentativeConcept dimension=componentDimensionsMapEntry.getKey();
    int dimensionExponent=componentDimensionsMapEntry.getValue().intValue();
    List<UnitConcept> unitsList=_componentUnits.get(dimension);
    for (    UnitConcept unit : unitsList) {
      if (dimensionExponent > 0) {
        _unitFactor=(ScalarToken)_unitFactor.multiply(unit._unitFactor);
      }
 else       if (dimensionExponent < 0) {
        _unitFactor=(ScalarToken)_unitFactor.divide(unit._unitFactor);
      }
    }
  }
}
Program: 73439
Project: 73439
Buggy source:
/** 
 * Create and return a new dimension map initialized with the given dimension and exponent.
 * @param dimension The dimension to be added to the dimension map.
 * @param exponentValue The exponent value to be assigned to the dimensionin the map.
 * @return The new dimension Map object.
 */
private Map<DimensionRepresentativeConcept,Integer> _createNewDimensionMap(DimensionRepresentativeConcept dimension,int exponentValue){
  Map<DimensionRepresentativeConcept,Integer> dimensionMap=new HashMap<DimensionRepresentativeConcept,Integer>();
  dimensionMap.put(dimension,new Integer(exponentValue));
  return dimensionMap;
}

Fixed version (ground truth):
/** 
 * Create and return a new dimension map initialized with the given dimension and exponent.
 * @param dimension The dimension to be added to the dimension map.
 * @param exponentValue The exponent value to be assigned to the dimensionin the map.
 * @return The new dimension Map object.
 */
private Map<DimensionRepresentativeConcept,Integer> _createNewDimensionMap(DimensionRepresentativeConcept dimension,int exponentValue){
  Map<DimensionRepresentativeConcept,Integer> dimensionMap=new HashMap<DimensionRepresentativeConcept,Integer>();
  dimensionMap.put(dimension,Integer.valueOf(exponentValue));
  return dimensionMap;
}
Program: 73440
Project: 73440
Buggy source:
/** 
 * If there are still tokens in the queue and a token has been produced in the fire,  schedule a refiring.
 */
public boolean postfire() throws IllegalActionException {
  boolean refiringScheduled=false;
  Time currentTime=getDirector().getModelTime();
  if (_nextTimeFree != null && _tokens.size() > 0 && currentTime.compareTo(_nextTimeFree) == 0) {
    _tokens.take();
    if (_tokens.size() > 0) {
      _nextTimeFree=currentTime.add(_serviceTimeValue);
      _nextReceiver=(Receiver)((Object[])_tokens.get(0))[0];
      _fireAt(_nextTimeFree);
      refiringScheduled=true;
    }
 else {
      refiringScheduled=false;
    }
  }
  if (!(getDirector() instanceof DEDirector) && _receiversAndTokensToSendTo != null) {
    for (    Receiver receiver : _receiversAndTokensToSendTo.keySet()) {
      Token token=_receiversAndTokensToSendTo.get(receiver);
      if (token != null) {
        _tokens.put(new Object[]{receiver,token});
      }
    }
    _receiversAndTokensToSendTo.clear();
    if (!refiringScheduled && _tokens.size() > 0) {
      _nextTimeFree=currentTime.add(_serviceTimeValue);
      _nextReceiver=(Receiver)((Object[])_tokens.get(0))[0];
      _fireAt(_nextTimeFree);
    }
  }
  return super.postfire();
}

Fixed version (ground truth):
/** 
 * If there are still tokens in the queue and a token has been produced in the fire,  schedule a refiring.
 */
public boolean postfire() throws IllegalActionException {
  boolean refiringScheduled=false;
  Time currentTime=getDirector().getModelTime();
  if (_nextTimeFree != null && _tokens.size() > 0 && currentTime.compareTo(_nextTimeFree) == 0) {
    _tokens.take();
  }
  if ((getDirector() instanceof FixedPointDirector) && _receiversAndTokensToSendTo != null) {
    for (    Receiver receiver : _receiversAndTokensToSendTo.keySet()) {
      Token token=_receiversAndTokensToSendTo.get(receiver);
      if (token != null) {
        _tokens.put(new Object[]{receiver,token});
      }
    }
    _receiversAndTokensToSendTo.clear();
  }
  if (_tokens.size() > 0 && (_nextTimeFree == null || currentTime.compareTo(_nextTimeFree) >= 0)) {
    _scheduleRefire();
  }
  return super.postfire();
}
Program: 73441
Project: 73441
Buggy source:
/** 
 * Initialize the actor.
 * @throws IllegalActionException If the superclass throws it.
 */
public void initialize() throws IllegalActionException {
  super.initialize();
  _receiversAndTokensToSendTo.clear();
}

Fixed version (ground truth):
/** 
 * Initialize the actor.
 * @throws IllegalActionException If the superclass throws it.
 */
public void initialize() throws IllegalActionException {
  super.initialize();
  _receiversAndTokensToSendTo.clear();
  _tokens.clear();
  _nextTimeFree=null;
}
Program: 73442
Project: 73442
Buggy source:
/** 
 * Initiate a send of the specified token to the specified receiver. This method will schedule a refiring of this actor if there is not one already scheduled.
 * @param receiver The receiver to send to.
 * @param token The token to send.
 * @throws IllegalActionException If the refiring request fails.
 */
public void sendToken(Receiver receiver,Token token) throws IllegalActionException {
  Time currentTime=getDirector().getModelTime();
  if (_nextTimeFree == null || _tokens.size() == 0 || currentTime.compareTo(_nextTimeFree) != 0 || receiver != _nextReceiver) {
    receiver.put(null);
  }
  Token tokenToSend=_receiversAndTokensToSendTo.get(receiver);
  if (tokenToSend != null) {
    if (!tokenToSend.equals(token)) {
      throw new IllegalActionException(this,receiver.getContainer(),"String_Node_Str" + tokenToSend + "String_Node_Str"+ token+ "String_Node_Str");
    }
  }
 else {
    if (getDirector() instanceof DEDirector) {
      if (token != null) {
        _tokens.put(new Object[]{receiver,token});
      }
      if (_tokens.size() == 1) {
        _nextTimeFree=currentTime.add(_serviceTimeValue);
        _nextReceiver=(Receiver)((Object[])_tokens.get(0))[0];
        _fireAt(_nextTimeFree);
      }
    }
 else {
      _receiversAndTokensToSendTo.put(receiver,token);
    }
  }
  if (token == null) {
    return;
  }
  if (_debugging) {
    _debug("String_Node_Str" + getDirector().getModelTime() + "String_Node_Str"+ receiver.getContainer().getFullName()+ "String_Node_Str"+ token);
  }
}

Fixed version (ground truth):
/** 
 * Initiate a send of the specified token to the specified receiver. This method will schedule a refiring of this actor if there is not one already scheduled.
 * @param receiver The receiver to send to.
 * @param token The token to send.
 * @throws IllegalActionException If the refiring request fails.
 */
public void sendToken(Receiver receiver,Token token) throws IllegalActionException {
  Time currentTime=getDirector().getModelTime();
  if (_nextTimeFree == null || _tokens.size() == 0 || currentTime.compareTo(_nextTimeFree) != 0 || receiver != _nextReceiver) {
    receiver.put(null);
  }
  Token tokenToSend=_receiversAndTokensToSendTo.get(receiver);
  if (tokenToSend != null) {
    if (!tokenToSend.equals(token)) {
      throw new IllegalActionException(this,receiver.getContainer(),"String_Node_Str" + tokenToSend + "String_Node_Str"+ token+ "String_Node_Str");
    }
  }
 else {
    if (getDirector() instanceof FixedPointDirector) {
      _receiversAndTokensToSendTo.put(receiver,token);
    }
 else {
      _tokens.put(new Object[]{receiver,token});
      if (_tokens.size() == 1) {
        _scheduleRefire();
      }
    }
  }
  if (token == null) {
    return;
  }
  if (_debugging) {
    _debug("String_Node_Str" + getDirector().getModelTime() + "String_Node_Str"+ receiver.getContainer().getFullName()+ "String_Node_Str"+ token);
  }
}
Program: 73445
Project: 73445
Buggy source:
/** 
 * Construct a real time clock, with all the times and clock drifts set to default values: All clock drifts are initialized to Time 1.0, and the oracle time is initialized to Time 0.0. However the corresponding platform is intialized to the initialClockSynchronizationError paramter.
 */
private RealTimeClock(double initialClockSynchronizationError,double clockDrift) throws IllegalActionException {
  _lastPlatformTime=new Time(PtidesBasicDirector.this,initialClockSynchronizationError);
  _clockDrift=new Time(PtidesBasicDirector.this,clockDrift);
  _lastOracleTime=new Time(PtidesBasicDirector.this);
}

Fixed version (ground truth):
/** 
 * Construct a real time clock, with all the times and clock drifts set to default values: All clock drifts are initialized to Time 1.0, and the oracle time is initialized to Time 0.0. However the corresponding platform is intialized to the initialClockSynchronizationError paramter. The <i>clockDrift</i> parameter specifies how much platform time should be incremented for each unit increment of oracle time. A clock drift of 1.0 means that the clocks remain perfectly synchronized. A clock drift less than 1.0 means that the platform time clock progresses more slowly than oracte time, and a clock drift greater than 1.0 means that it progresses more rapidly.
 * @param platformTimeAtOracleTimeZero The platform Time value interpreted to besimultaneous with oracle time zero.
 * @param clockDrift The relative rate of advance of platform time w.r.t.oracle time.
 */
private RealTimeClock(double platformTimeAtOracleTimeZero,double clockDrift) throws IllegalActionException {
  _lastPlatformTime=new Time(PtidesBasicDirector.this,platformTimeAtOracleTimeZero);
  _clockDrift=new Time(PtidesBasicDirector.this,clockDrift);
  _lastOracleTime=new Time(PtidesBasicDirector.this);
}
Program: 73446
Project: 73446
Buggy source:
/** 
 * Generate code for the assembly file.
 * @throws IllegalActionException if getAdaptor throws it, or if thePtidyOSCodeGenerator is not used in a Ptides environment.
 */
protected void _generateAssemblyFile() throws IllegalActionException {
  PtidesPreemptiveEDFDirector directorAdapter=null;
  Director director=((TypedCompositeActor)getContainer()).getDirector();
  if (director instanceof ptolemy.domains.ptides.kernel.PtidesBasicDirector) {
    directorAdapter=(PtidesPreemptiveEDFDirector)getAdapter(director);
    _writeCode(directorAdapter.generateAsseblyFile());
  }
 else   if (director instanceof ptolemy.domains.ptides.kernel.PtidesTopLevelDirector) {
    for (    Actor actor : (List<Actor>)((TypedCompositeActor)getContainer()).deepEntityList()) {
      Director insideDirector=actor.getDirector();
      if (insideDirector instanceof ptolemy.domains.ptides.kernel.PtidesBasicDirector) {
        directorAdapter=(PtidesPreemptiveEDFDirector)getAdapter(director);
        _writeCode(directorAdapter.generateAsseblyFile());
      }
    }
  }
 else {
    throw new IllegalActionException(director,"String_Node_Str" + "String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Generate code for the assembly file.
 * @exception IllegalActionException If getAdaptor() throws it, or if thePtidyOSCodeGenerator is not used in a Ptides environment.
 */
protected void _generateAssemblyFile() throws IllegalActionException {
  PtidesPreemptiveEDFDirector directorAdapter=null;
  Director director=((TypedCompositeActor)getContainer()).getDirector();
  if (director instanceof ptolemy.domains.ptides.kernel.PtidesBasicDirector) {
    directorAdapter=(PtidesPreemptiveEDFDirector)getAdapter(director);
    _writeCode(directorAdapter.generateAsseblyFile());
  }
 else   if (director instanceof ptolemy.domains.ptides.kernel.PtidesTopLevelDirector) {
    for (    Actor actor : (List<Actor>)((TypedCompositeActor)getContainer()).deepEntityList()) {
      Director insideDirector=actor.getDirector();
      if (insideDirector instanceof ptolemy.domains.ptides.kernel.PtidesBasicDirector) {
        directorAdapter=(PtidesPreemptiveEDFDirector)getAdapter(director);
        _writeCode(directorAdapter.generateAsseblyFile());
      }
    }
  }
 else {
    throw new IllegalActionException(director,"String_Node_Str" + "String_Node_Str");
  }
}
Program: 73448
Project: 73448
Buggy source:
/** 
 * Get the simulated physical time of the environment, which is the oracle physical time offset by the clock synchronization error due to clock drift.
 * @return the platform physical time.
 * @exception IllegalActionException If director cannot get token for theparameter platformTimeSynchronizationError.
 * @exception InternalErrorException If the platform physical time of thecorresponding current oracle time cannot be retrieved.
 */
public Tag getPlatformPhysicalTag(int clockId) throws IllegalActionException {
  Tag tag=_getOraclePhysicalTag();
  tag.timestamp=_getPlatformPhysicalTimeForOraclePhysicalTime(tag.timestamp,clockId);
  if (tag.timestamp == null) {
    throw new InternalErrorException("String_Node_Str" + "String_Node_Str");
  }
  return tag;
}

Fixed version (ground truth):
/** 
 * Get the simulated physical time of the environment, which is the oracle physical time offset by the clock synchronization error due to clock drift.
 * @param clockId Clock ID.
 * @return the platform physical time.
 * @exception IllegalActionException If director cannot get token for theparameter platformTimeSynchronizationError.
 * @exception InternalErrorException If the platform physical time of thecorresponding current oracle time cannot be retrieved.
 */
public Tag getPlatformPhysicalTag(int clockId) throws IllegalActionException {
  Tag tag=_getOraclePhysicalTag();
  tag.timestamp=_getPlatformPhysicalTimeForOraclePhysicalTime(tag.timestamp,clockId);
  if (tag.timestamp == null) {
    throw new InternalErrorException("String_Node_Str" + "String_Node_Str");
  }
  return tag;
}
Program: 73450
Project: 73450
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 deliveryTag The platform time of delivery of this token.
 */
public RealTimeEvent(IOPort port,int channel,Token token,Tag deliveryTag,Tag timestampTag){
  this.port=port;
  this.channel=channel;
  this.token=token;
  this.deliveryTag=deliveryTag;
  this.timestampTag=timestampTag;
}

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 deliveryTag The platform time of delivery of this token.
 * @param timestampTag The timestamp tag of this token.
 */
public RealTimeEvent(IOPort port,int channel,Token token,Tag deliveryTag,Tag timestampTag){
  this.port=port;
  this.channel=channel;
  this.token=token;
  this.deliveryTag=deliveryTag;
  this.timestampTag=timestampTag;
}
Program: 73453
Project: 73453
Buggy source:
/** 
 * Return the token (value) of this event.
 * @return The token.
 * @exception If event is not a pure event and token field is null.
 */
public final Token token(){
  if (!isPureEvent() && (_token == null)) {
    throw new InternalErrorException("String_Node_Str" + "String_Node_Str");
  }
  return _token;
}

Fixed version (ground truth):
/** 
 * Return the token (value) of this event.
 * @return The token.
 * @exception InternalErrorException If event is not a pure eventand token field is null.
 */
public final Token token(){
  if (!isPureEvent() && (_token == null)) {
    throw new InternalErrorException("String_Node_Str" + "String_Node_Str");
  }
  return _token;
}
Program: 73456
Project: 73456
Buggy source:
/** 
 * Run concept inference and save the inferred concept values. For values that are correctly resolved to a non-null concept, a string representation of the concept is stored in the <i>_trainedConcept</i> attribute of the NamedObj.  For values that resolve to null, nothing is recorded.
 * @exception IllegalActionException If inference fails..
 */
public void train() throws IllegalActionException {
  try {
    workspace().getWriteAccess();
    invokeSolver();
    for (    NamedObj conceptable : getAllConceptableNamedObjs()) {
      Concept inferred=getConcept(conceptable);
      if (inferred == null) {
        continue;
      }
      StringParameter trained;
      try {
        trained=new StringParameter(conceptable,"String_Node_Str");
      }
 catch (      NameDuplicationException e) {
        trained=(StringParameter)conceptable.getAttribute("String_Node_Str");
      }
      trained.setExpression(inferred.toString());
    }
  }
  finally {
    workspace().doneWriting();
  }
}

Fixed version (ground truth):
/** 
 * Run concept inference and save the inferred concept values. For values that are correctly resolved to a non-null concept, a string representation of the concept is stored in the <i>_trainedConcept</i> attribute of the NamedObj.  For values that resolve to null, nothing is recorded.
 * @exception IllegalActionException If inference fails..
 */
public void train() throws IllegalActionException {
  try {
    workspace().getWriteAccess();
    invokeSolver();
    Set<NamedObj> allNamedObjs=getAllConceptableNamedObjs();
    for (    NamedObj conceptable : allNamedObjs) {
      Concept inferred=getConcept(conceptable);
      if (inferred == null) {
        continue;
      }
      StringParameter trained;
      try {
        trained=new StringParameter(conceptable,"String_Node_Str");
      }
 catch (      NameDuplicationException e) {
        trained=(StringParameter)conceptable.getAttribute("String_Node_Str");
      }
      trained.setExpression(inferred.toString());
      trained.getToken();
    }
  }
  finally {
    workspace().doneWriting();
  }
}
Program: 73457
Project: 73457
Buggy source:
/** 
 * Return the list of lattice ontologies that comprise the product lattice ontology.
 * @return The list of lattice ontology objects.
 * @throws IllegalActionException If the latticeOntologies parameter doesnot return an array token that contains the ontology objects, or at least one of the specified component ontologies is not a lattice.
 */
public List<Ontology> getLatticeOntologies() throws IllegalActionException {
  if (workspace().getVersion() != _latticeVersion) {
    ArrayToken ontologies=(ArrayToken)latticeOntologies.getToken();
    if (ontologies != null && ontologies.length() != 0) {
      Token[] ontologiesTokenArray=(Token[])ontologies.arrayValue();
      List<Ontology> ontologiesList=new ArrayList<Ontology>();
      for (int i=0; i < ontologiesTokenArray.length; i++) {
        Ontology ontology=(Ontology)((ObjectToken)ontologiesTokenArray[i]).getValue();
        if (ontology != null) {
          if (ontology.isLattice()) {
            ontologiesList.add(ontology);
          }
 else {
            throw new IllegalActionException(this,"String_Node_Str" + "String_Node_Str" + "String_Node_Str" + ontology.getName() + "String_Node_Str");
          }
        }
      }
      _latticeOntologies=ontologiesList;
    }
 else {
      _latticeOntologies=null;
    }
    _latticeVersion=workspace().getVersion();
  }
  return _latticeOntologies;
}

Fixed version (ground truth):
/** 
 * Return the list of lattice ontologies that comprise the product lattice ontology.
 * @return The list of lattice ontology objects.
 * @throws IllegalActionException If the latticeOntologies parameter doesnot return an array token that contains the ontology objects, or at least one of the specified component ontologies is not a lattice.
 */
public List<Ontology> getLatticeOntologies() throws IllegalActionException {
  if (workspace().getVersion() != _latticeVersion) {
    ArrayToken ontologies=(ArrayToken)latticeOntologies.getToken();
    List<Ontology> ontologiesList=new ArrayList<Ontology>();
    if (ontologies != null && ontologies.length() != 0) {
      Token[] ontologiesTokenArray=(Token[])ontologies.arrayValue();
      for (int i=0; i < ontologiesTokenArray.length; i++) {
        Ontology ontology=(Ontology)((ObjectToken)ontologiesTokenArray[i]).getValue();
        if (ontology != null) {
          if (ontology.isLattice()) {
            ontologiesList.add(ontology);
          }
 else {
            throw new IllegalActionException(this,"String_Node_Str" + "String_Node_Str" + "String_Node_Str" + ontology.getName() + "String_Node_Str");
          }
        }
      }
    }
    _latticeOntologies=ontologiesList;
    _latticeVersion=workspace().getVersion();
  }
  return _latticeOntologies;
}
Program: 73458
Project: 73458
Buggy source:
/** 
 * Construct a Bus with a name and a container. The container argument must not be null, or a NullPointerException will be thrown.  This actor 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 actor.
 * @exception IllegalActionException If the container is incompatiblewith this actor.
 * @exception NameDuplicationException If the name coincides withan actor already in the container.
 */
public Bus(CompositeEntity container,String name) throws IllegalActionException, NameDuplicationException {
  super(container,name);
  _tokens=new FIFOQueue();
  serviceTime=new Parameter(this,"String_Node_Str");
  serviceTime.setExpression("String_Node_Str");
  serviceTime.setTypeEquals(BaseType.DOUBLE);
}

Fixed version (ground truth):
/** 
 * Construct a Bus with a name and a container. The container argument must not be null, or a NullPointerException will be thrown.  This actor 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 actor.
 * @exception IllegalActionException If the container is incompatiblewith this actor.
 * @exception NameDuplicationException If the name coincides withan actor already in the container.
 */
public Bus(CompositeEntity container,String name) throws IllegalActionException, NameDuplicationException {
  super(container,name);
  _tokens=new FIFOQueue();
  _receiversAndTokensToSendTo=new HashMap();
  serviceTime=new Parameter(this,"String_Node_Str");
  serviceTime.setExpression("String_Node_Str");
  serviceTime.setTypeEquals(BaseType.DOUBLE);
}
Program: 73459
Project: 73459
Buggy source:
/** 
 * If there are still tokens in the queue and a token has been produced in the fire,  schedule a refiring.
 */
public boolean postfire() throws IllegalActionException {
  Time currentTime=getDirector().getModelTime();
  if (_nextTimeFree != null && _tokens.size() > 0 && currentTime.compareTo(_nextTimeFree) == 0) {
    _tokens.take();
    if (_tokens.size() > 0) {
      _nextTimeFree=currentTime.add(_serviceTimeValue);
      _nextReceiver=(Receiver)((Object[])_tokens.get(0))[0];
      _fireAt(_nextTimeFree);
    }
  }
  if (_tokenToSend != null) {
    _tokens.put(new Object[]{_receiverToSendTo,_tokenToSend});
    _tokenToSend=null;
    _receiverToSendTo=null;
    if (_tokens.size() == 1) {
      _nextTimeFree=currentTime.add(_serviceTimeValue);
      _nextReceiver=_receiverToSendTo;
      _fireAt(_nextTimeFree);
    }
  }
  return super.postfire();
}

Fixed version (ground truth):
/** 
 * If there are still tokens in the queue and a token has been produced in the fire,  schedule a refiring.
 */
public boolean postfire() throws IllegalActionException {
  Time currentTime=getDirector().getModelTime();
  if (_nextTimeFree != null && _tokens.size() > 0 && currentTime.compareTo(_nextTimeFree) == 0) {
    _tokens.take();
    if (_tokens.size() > 0) {
      _nextTimeFree=currentTime.add(_serviceTimeValue);
      _nextReceiver=(Receiver)((Object[])_tokens.get(0))[0];
      _fireAt(_nextTimeFree);
    }
  }
  if (_receiversAndTokensToSendTo != null) {
    for (    Receiver receiver : _receiversAndTokensToSendTo.keySet()) {
      Token token=_receiversAndTokensToSendTo.get(receiver);
      if (token != null) {
        _tokens.put(new Object[]{receiver,token});
      }
    }
    _receiversAndTokensToSendTo.clear();
    if (_tokens.size() == 1) {
      _nextTimeFree=currentTime.add(_serviceTimeValue);
      _nextReceiver=(Receiver)((Object[])_tokens.get(0))[0];
      _fireAt(_nextTimeFree);
    }
  }
  return super.postfire();
}
Program: 73460
Project: 73460
Buggy source:
/** 
 * Initialize the actor.
 * @throws IllegalActionException If the superclass throws it.
 */
public void initialize() throws IllegalActionException {
  super.initialize();
  _tokenToSend=null;
  _receiverToSendTo=null;
}

Fixed version (ground truth):
/** 
 * Initialize the actor.
 * @throws IllegalActionException If the superclass throws it.
 */
public void initialize() throws IllegalActionException {
  super.initialize();
  _receiversAndTokensToSendTo.clear();
}
Program: 73461
Project: 73461
Buggy source:
/** 
 * Initiate a send of the specified token to the specified receiver. This method will schedule a refiring of this actor if there is not one already scheduled.
 * @param receiver The receiver to send to.
 * @param token The token to send.
 * @throws IllegalActionException If the refiring request fails.
 */
public void sendToken(Receiver receiver,Token token) throws IllegalActionException {
  Time currentTime=getDirector().getModelTime();
  if (_nextTimeFree == null || _tokens.size() == 0 || currentTime.compareTo(_nextTimeFree) != 0 || receiver != _nextReceiver) {
    receiver.put(null);
  }
  if (_tokenToSend != null) {
    if (!_tokenToSend.equals(token)) {
      throw new IllegalActionException(this,receiver.getContainer(),"String_Node_Str" + _tokenToSend + "String_Node_Str"+ token+ "String_Node_Str");
    }
  }
  _tokenToSend=token;
  _receiverToSendTo=receiver;
  if (token == null) {
    return;
  }
  if (_debugging) {
    _debug("String_Node_Str" + getDirector().getModelTime() + "String_Node_Str"+ receiver.getContainer().getFullName()+ "String_Node_Str"+ token);
  }
}

Fixed version (ground truth):
/** 
 * Initiate a send of the specified token to the specified receiver. This method will schedule a refiring of this actor if there is not one already scheduled.
 * @param receiver The receiver to send to.
 * @param token The token to send.
 * @throws IllegalActionException If the refiring request fails.
 */
public void sendToken(Receiver receiver,Token token) throws IllegalActionException {
  Time currentTime=getDirector().getModelTime();
  if (_nextTimeFree == null || _tokens.size() == 0 || currentTime.compareTo(_nextTimeFree) != 0 || receiver != _nextReceiver) {
    receiver.put(null);
  }
  Token tokenToSend=_receiversAndTokensToSendTo.get(receiver);
  if (tokenToSend != null) {
    if (!tokenToSend.equals(token)) {
      throw new IllegalActionException(this,receiver.getContainer(),"String_Node_Str" + tokenToSend + "String_Node_Str"+ token+ "String_Node_Str");
    }
  }
 else {
    _receiversAndTokensToSendTo.put(receiver,token);
  }
  if (token == null) {
    return;
  }
  if (_debugging) {
    _debug("String_Node_Str" + getDirector().getModelTime() + "String_Node_Str"+ receiver.getContainer().getFullName()+ "String_Node_Str"+ token);
  }
}
Program: 73462
Project: 73462
Buggy source:
/** 
 * Send first token in the queue to the target receiver.
 */
public void fire() throws IllegalActionException {
  Time currentTime=getDirector().getModelTime();
  if (_nextTimeFree != null && _tokens.size() > 0 && currentTime.compareTo(_nextTimeFree) == 0) {
    Object[] output=(Object[])_tokens.get(0);
    Receiver receiver=(Receiver)output[0];
    Token token=(Token)output[1];
    receiver.put(token);
    if (_debugging) {
      _debug("String_Node_Str" + currentTime + "String_Node_Str"+ receiver.getContainer().getFullName()+ "String_Node_Str"+ token);
    }
  }
}

Fixed version (ground truth):
/** 
 * Send first token in the queue to the target receiver.
 */
public void fire() throws IllegalActionException {
  Time currentTime=getDirector().getModelTime();
  if (_nextTimeFree != null && _tokens.size() > 0 && currentTime.compareTo(_nextTimeFree) == 0) {
    Object[] output=(Object[])_tokens.get(0);
    Receiver receiver=(Receiver)output[0];
    Token token=(Token)output[1];
    receiver.put(token);
    if (!(receiver instanceof IntermediateReceiver)) {
      Actor container=(Actor)receiver.getContainer().getContainer();
      if (receiver.getContainer().isOutput()) {
        while (container instanceof CompositeActor) {
          Iterator<?> outports=container.outputPortList().iterator();
          while (outports.hasNext()) {
            IOPort p=(IOPort)outports.next();
            container.getDirector().transferOutputs(p);
          }
          container=(Actor)container.getContainer();
        }
      }
    }
    if (_debugging) {
      _debug("String_Node_Str" + currentTime + "String_Node_Str"+ receiver.getContainer().getFullName()+ "String_Node_Str"+ token);
    }
  }
}
Program: 73463
Project: 73463
Buggy source:
/** 
 * Send first token in the queue to the target receiver.
 */
public void fire() throws IllegalActionException {
  Time currentTime=getDirector().getModelTime();
  if (_nextTimeFree != null && _tokens.size() > 0 && currentTime.compareTo(_nextTimeFree) == 0) {
    Object[] output=(Object[])_tokens.get(0);
    Receiver receiver=(Receiver)output[0];
    Token token=(Token)output[1];
    receiver.put(token);
    if (!(receiver instanceof IntermediateReceiver)) {
      Actor container=(Actor)receiver.getContainer().getContainer();
      if (receiver.getContainer().isOutput()) {
        while (container instanceof CompositeActor) {
          Iterator<?> outports=container.outputPortList().iterator();
          while (outports.hasNext()) {
            IOPort p=(IOPort)outports.next();
            container.getDirector().transferOutputs(p);
          }
          container=(Actor)container.getContainer();
        }
      }
    }
    if (_debugging) {
      _debug("String_Node_Str" + currentTime + "String_Node_Str"+ receiver.getContainer().getFullName()+ "String_Node_Str"+ token);
    }
  }
}

Fixed version (ground truth):
/** 
 * Send first token in the queue to the target receiver.
 */
public void fire() throws IllegalActionException {
  Time currentTime=getDirector().getModelTime();
  if (_nextTimeFree != null && _tokens.size() > 0 && currentTime.compareTo(_nextTimeFree) == 0) {
    Object[] output=(Object[])_tokens.get(0);
    Receiver receiver=(Receiver)output[0];
    Token token=(Token)output[1];
    if (receiver.isKnown() && !receiver.hasToken()) {
      receiver.reset();
    }
    if (!(receiver instanceof IntermediateReceiver)) {
      Actor container=(Actor)receiver.getContainer().getContainer();
      if (receiver.getContainer().isOutput()) {
        receiver.put(token);
        ((Actor)container.getContainer()).getDirector().fireAt(container,currentTime);
      }
 else {
        if (receiver.getContainer().isInput()) {
          ((Actor)container.getContainer()).getDirector().fireAt(container,currentTime);
          receiver.put(token);
          ((Actor)container.getContainer()).getDirector().fireAt(container,currentTime);
        }
      }
    }
    if (_debugging) {
      _debug("String_Node_Str" + currentTime + "String_Node_Str"+ receiver.getContainer().getFullName()+ "String_Node_Str"+ token);
    }
  }
}
Program: 73468
Project: 73468
Buggy source:
/** 
 * Divide a Time object by another BigInterger. Produces a new Time object. The Time object (the dividend, must not have a null _divisorAndRemainder term.
 * @param dividendTime The dividend.
 * @param divisor The divisor.
 * @param resolutionInverse The inverse of the resolution.
 * @return A new Time object.
 */
private Time _timeDivideByBigInteger(Time dividendTime,BigInteger divisor,BigInteger resolutionInverse){
  assert(dividendTime._divisorAndRemainder != null);
  BigInteger dividend=dividendTime._timeValue.multiply(resolutionInverse);
  BigInteger[] q_r=dividend.divideAndRemainder(divisor);
  BigInteger dividend2=q_r[1].multiply(dividendTime._divisorAndRemainder[0]).add(dividendTime._divisorAndRemainder[1]);
  BigInteger divisor2=dividendTime._divisorAndRemainder[0].multiply(divisor);
  BigInteger[] q_r2=dividend2.divideAndRemainder(_divisorAndRemainder[0]);
  assert(q_r2[1].compareTo(BigInteger.ZERO) != 0);
  return new Time(_director,q_r[0].add(q_r2[0]),divisor2,q_r2[1]);
}

Fixed version (ground truth):
/** 
 * Divide a Time object by another BigInterger. Produces a new Time object. The Time object (the dividend), must not have a null _divisorAndRemainder term.
 * @param dividendTime The dividend.
 * @param divisor The divisor.
 * @param resolutionInverse The inverse of the resolution.
 * @return A new Time object.
 */
private Time _timeDivideByBigInteger(Time dividendTime,BigInteger divisor,BigInteger resolutionInverse){
  assert(dividendTime._divisorAndRemainder != null);
  BigInteger dividend=dividendTime._timeValue.multiply(resolutionInverse);
  BigInteger[] q_r=dividend.divideAndRemainder(divisor);
  BigInteger dividend2=q_r[1].multiply(dividendTime._divisorAndRemainder[0]).add(dividendTime._divisorAndRemainder[1].multiply(resolutionInverse));
  BigInteger divisor2=dividendTime._divisorAndRemainder[0].multiply(divisor);
  BigInteger[] q_r2=dividend2.divideAndRemainder(divisor2);
  assert(q_r2[1].compareTo(BigInteger.ZERO) != 0);
  return new Time(_director,q_r[0].add(q_r2[0]),divisor2,q_r2[1]);
}
Program: 73469
Project: 73469
Buggy source:
public void managerStateChanged(Manager manager){
  if (manager.getState() == Manager.PREINITIALIZING) {
    MoMLParser.addMoMLFilter(filter);
    _isModified=MoMLParser.isModified();
    try {
      _lastUndoStack.setContainer(container);
      _lastUndoStack.moveToFirst();
    }
 catch (    KernelException e) {
      e.printStackTrace();
    }
  }
 else   if (manager.getState() == Manager.IDLE) {
    MoMLParser.getMoMLFilters().remove(filter);
    MoMLParser.setModified(_isModified);
    _lastUndoStack=undoStack;
    try {
      undoStack.setContainer(null);
    }
 catch (    KernelException e) {
    }
    attribute.removeExecutionListener(this);
  }
}

Fixed version (ground truth):
@Override public void managerStateChanged(Manager manager){
  if (manager.getState() == Manager.PREINITIALIZING) {
    MoMLParser.addMoMLFilter(filter);
    _isModified=MoMLParser.isModified();
    try {
      _lastUndoStack.setContainer(container);
      _lastUndoStack.moveToFirst();
    }
 catch (    KernelException e) {
      e.printStackTrace();
    }
  }
 else   if (manager.getState() == Manager.IDLE) {
    MoMLParser.getMoMLFilters().remove(filter);
    MoMLParser.setModified(_isModified);
    _lastUndoStack=undoStack;
    try {
      undoStack.setContainer(null);
    }
 catch (    KernelException e) {
    }
    attribute.removeExecutionListener(this);
  }
}
Program: 73470
Project: 73470
Buggy source:
public void executionFinished(Manager manager){
}

Fixed version (ground truth):
@Override public void executionFinished(Manager manager){
}
Program: 73471
Project: 73471
Buggy source:
/** 
 * React to change of an attribute and update the container of this importer.
 * @param settable The attribute changed.
 */
public void valueChanged(Settable settable){
  update();
}

Fixed version (ground truth):
/** 
 * React to change of an attribute and update the container of this importer.
 * @param settable The attribute changed.
 */
@Override public void valueChanged(Settable settable){
  update();
}
Program: 73472
Project: 73472
Buggy source:
/** 
 * Set the created element to be non-persistent.
 * @param container The object defined by the element that thisis the end of.
 * @param elementName The element name.
 * @param currentCharData The character data, which appearsonly in the doc and configure elements
 * @param xmlFile The file currently being parsed.
 * @exception Exception Not thrown in this class.
 */
public void filterEndElement(NamedObj container,String elementName,StringBuffer currentCharData,String xmlFile) throws Exception {
  if (container != null && !"String_Node_Str".equals(elementName)) {
    NamedObj context=getContainer();
    NamedObj parent=container;
    while (parent != null && parent != context) {
      parent=parent.getContainer();
    }
    if (parent == context && container != context) {
      container.setPersistent(false);
    }
  }
}

Fixed version (ground truth):
/** 
 * Set the created element to be non-persistent.
 * @param container The object defined by the element that thisis the end of.
 * @param elementName The element name.
 * @param currentCharData The character data, which appearsonly in the doc and configure elements
 * @param xmlFile The file currently being parsed.
 * @exception Exception Not thrown in this class.
 */
@Override public void filterEndElement(NamedObj container,String elementName,StringBuffer currentCharData,String xmlFile) throws Exception {
  if (container != null && !"String_Node_Str".equals(elementName)) {
    NamedObj context=getContainer();
    NamedObj parent=container;
    while (parent != null && parent != context) {
      parent=parent.getContainer();
    }
    if (parent == context && container != context) {
      if (container.attributeList(PersistenceAttribute.class).isEmpty()) {
        new PersistenceAttribute(container,container.uniqueName("String_Node_Str"));
      }
    }
  }
}
Program: 73473
Project: 73473
Buggy source:
/** 
 * Return the value of the attribute.
 * @param container  The container for XML element.
 * @param element The XML element name.
 * @param attributeName The name of the attribute.
 * @param attributeValue The value of the attribute.
 * @param xmlFile The file currently being parsed.
 * @return The value of the attribute.
 */
public String filterAttributeValue(NamedObj container,String element,String attributeName,String attributeValue,String xmlFile){
  return attributeValue;
}

Fixed version (ground truth):
/** 
 * Return the value of the attribute.
 * @param container  The container for XML element.
 * @param element The XML element name.
 * @param attributeName The name of the attribute.
 * @param attributeValue The value of the attribute.
 * @param xmlFile The file currently being parsed.
 * @return The value of the attribute.
 */
@Override public String filterAttributeValue(NamedObj container,String element,String attributeName,String attributeValue,String xmlFile){
  return attributeValue;
}
Program: 73475
Project: 73475
Buggy source:
public void executionError(Manager manager,Throwable throwable){
}

Fixed version (ground truth):
@Override public void executionError(Manager manager,Throwable throwable){
}
Program: 73476
Project: 73476
Buggy source:
/** 
 * Set the container of this importer, and update the new container if it is not null.
 * @param container The new container.
 * @exception IllegalActionException If thrown by the superclass.
 * @exception NameDuplicationException If thrown by the superclass.
 */
public void setContainer(NamedObj container) throws IllegalActionException, NameDuplicationException {
  NamedObj oldContainer=getContainer();
  try {
    if (oldContainer != null && _lastUndoStack != null) {
      _lastUndoStack.undo();
    }
  }
 catch (  Exception e) {
    throw new InternalErrorException(this,e,"String_Node_Str");
  }
 finally {
    _lastUndoStack=null;
  }
  super.setContainer(container);
  if (container != null) {
    update();
  }
}

Fixed version (ground truth):
/** 
 * Set the container of this importer, and update the new container if it is not null.
 * @param container The new container.
 * @exception IllegalActionException If thrown by the superclass.
 * @exception NameDuplicationException If thrown by the superclass.
 */
@Override public void setContainer(NamedObj container) throws IllegalActionException, NameDuplicationException {
  NamedObj oldContainer=getContainer();
  try {
    if (oldContainer != null && _lastUndoStack != null) {
      _lastUndoStack.undo();
    }
  }
 catch (  Exception e) {
    throw new InternalErrorException(this,e,"String_Node_Str");
  }
 finally {
    _lastUndoStack=null;
  }
  super.setContainer(container);
  if (container != null) {
    update();
  }
}