nus-yam/ex-repair huggingface dataset:
Program: 103322
Project: 103322
Buggy source:
/** 
 * Returns the default chat font color.
 * @return the default chat font color
 */
public static Color getChatDefaultFontColor(){
  return new Color(defaultFontColor);
}

Fixed version (ground truth):
/** 
 * Returns the default chat font color.
 * @return the default chat font color
 */
public static Color getChatDefaultFontColor(){
  return defaultFontColor == -1 ? null : new Color(defaultFontColor);
}
Program: 103323
Project: 103323
Buggy source:
/** 
 * Sets the default isUnderline property.
 * @param isBold indicates if the default chat font is underline
 */
public static void setChatFontIsUnderline(boolean isUnderline){
  isDefaultFontUnderline=isUnderline;
  configService.setProperty("String_Node_Str",isUnderline);
}

Fixed version (ground truth):
/** 
 * Sets the default isUnderline property.
 * @param isUnderline indicates if the default chat font is underline
 */
public static void setChatFontIsUnderline(boolean isUnderline){
  isDefaultFontUnderline=isUnderline;
  configService.setProperty("String_Node_Str",isUnderline);
}
Program: 103324
Project: 103324
Buggy source:
/** 
 * Creates a <tt>UIContact</tt> for the given <tt>metaContact</tt>.
 * @param metaContact the <tt>MetaContact</tt> for which we would like tocreate an <tt>UIContact</tt>
 * @return an <tt>UIContact</tt> for the given <tt>metaContact</tt>
 */
public static UIContact createUIContact(MetaContact metaContact){
  MetaUIContact descriptor=new MetaUIContact(metaContact);
  metaContact.setData(UI_CONTACT_DATA_KEY,descriptor);
  return descriptor;
}

Fixed version (ground truth):
/** 
 * Creates a <tt>UIContact</tt> for the given <tt>metaContact</tt>.
 * @param metaContact the <tt>MetaContact</tt> for which we would like tocreate an <tt>UIContact</tt>
 * @return an <tt>UIContact</tt> for the given <tt>metaContact</tt>
 */
public static UIContact createUIContact(final MetaContact metaContact){
  final MetaUIContact descriptor=new MetaUIContact(metaContact);
  SwingUtilities.invokeLater(new Runnable(){
    public void run(){
      metaContact.setData(UI_CONTACT_DATA_KEY,descriptor);
    }
  }
);
  return descriptor;
}
Program: 103326
Project: 103326
Buggy source:
protected int doProcess(Buffer inputBuffer,Buffer outputBuffer){
  byte[] input=(byte[])inputBuffer.getData();
  int inputLength=inputBuffer.getLength();
  int inputOffset=inputBuffer.getOffset();
  if ((prevInputLength + inputLength) < INPUT_FRAME_SIZE_IN_BYTES) {
    System.arraycopy(input,inputOffset,prevInput,prevInputLength,inputLength);
    prevInputLength+=inputLength;
    return BUFFER_PROCESSED_OK | OUTPUT_BUFFER_NOT_FILLED;
  }
  int readShorts=0;
  if (prevInputLength > 0) {
    readShorts+=readShorts(prevInput,0,sp16,0,prevInputLength / 2);
    prevInputLength=0;
  }
  readShorts=readShorts(input,inputOffset,sp16,readShorts,sp16.length - readShorts);
  int readBytes=2 * readShorts;
  inputLength-=readBytes;
  inputBuffer.setLength(inputLength);
  inputOffset+=readBytes;
  inputBuffer.setOffset(inputOffset);
  coder.process(sp16,serial);
  byte[] output=validateByteArraySize(outputBuffer,outputBuffer.getOffset() + 2 * OUTPUT_FRAME_SIZE_IN_BYTES);
  packetize(serial,output,outputBuffer.getOffset() + OUTPUT_FRAME_SIZE_IN_BYTES * outputFrameCount);
  outputBuffer.setLength(outputBuffer.getLength() + OUTPUT_FRAME_SIZE_IN_BYTES);
  outputBuffer.setFormat(outputFormat);
  int processResult=BUFFER_PROCESSED_OK;
  if (outputFrameCount == 1)   outputFrameCount=0;
 else {
    outputFrameCount=1;
    processResult|=OUTPUT_BUFFER_NOT_FILLED;
  }
  if (inputLength > 0)   processResult|=INPUT_BUFFER_NOT_CONSUMED;
  return processResult;
}

Fixed version (ground truth):
protected int doProcess(Buffer inputBuffer,Buffer outputBuffer){
  byte[] input=(byte[])inputBuffer.getData();
  int inputLength=inputBuffer.getLength();
  int inputOffset=inputBuffer.getOffset();
  if ((prevInputLength + inputLength) < INPUT_FRAME_SIZE_IN_BYTES) {
    System.arraycopy(input,inputOffset,prevInput,prevInputLength,inputLength);
    prevInputLength+=inputLength;
    return BUFFER_PROCESSED_OK | OUTPUT_BUFFER_NOT_FILLED;
  }
  int readShorts=0;
  if (prevInputLength > 0) {
    readShorts+=readShorts(prevInput,0,sp16,0,prevInputLength / 2);
    prevInputLength=0;
  }
  readShorts=readShorts(input,inputOffset,sp16,readShorts,sp16.length - readShorts);
  int readBytes=2 * readShorts;
  inputLength-=readBytes;
  inputBuffer.setLength(inputLength);
  inputOffset+=readBytes;
  inputBuffer.setOffset(inputOffset);
  coder.process(sp16,serial);
  byte[] output=validateByteArraySize(outputBuffer,outputBuffer.getOffset() + 2 * OUTPUT_FRAME_SIZE_IN_BYTES);
  packetize(serial,output,outputBuffer.getOffset() + OUTPUT_FRAME_SIZE_IN_BYTES * outputFrameCount);
  outputBuffer.setLength(outputBuffer.getLength() + OUTPUT_FRAME_SIZE_IN_BYTES);
  outputBuffer.setFormat(outputFormat);
  int processResult=BUFFER_PROCESSED_OK;
  if (outputFrameCount == 1)   outputFrameCount=0;
 else {
    outputFrameCount=1;
    processResult|=OUTPUT_BUFFER_NOT_FILLED;
  }
  if (inputLength > 0)   processResult|=INPUT_BUFFER_NOT_CONSUMED;
  if (processResult == BUFFER_PROCESSED_OK) {
    updateOutput(outputBuffer,getOutputFormat(),outputBuffer.getLength(),outputBuffer.getOffset());
    outputBuffer.setDuration(duration);
  }
  return processResult;
}
Program: 103328
Project: 103328
Buggy source:
/** 
 * Sets the preset.
 * @param preset the desired video settings
 * @throws OperationFailedException
 */
private void setRemoteReceivePreset(QualityPreset preset) throws OperationFailedException {
  if (preset.compareTo(getPreferredSendPreset()) > 0)   this.preset=getPreferredSendPreset();
 else   this.preset=preset;
}

Fixed version (ground truth):
/** 
 * Sets the preset.
 * @param preset the desired video settings
 * @throws OperationFailedException
 */
private void setRemoteReceivePreset(QualityPreset preset) throws OperationFailedException {
  if (preset.compareTo(getPreferredSendPreset()) > 0)   this.preset=getPreferredSendPreset();
 else {
    this.preset=preset;
    if (logger.isInfoEnabled() && preset != null && preset.getResolution() != null) {
      logger.info("String_Node_Str" + preset.getResolution().width + "String_Node_Str"+ preset.getResolution().height);
    }
  }
}
Program: 103330
Project: 103330
Buggy source:
/** 
 * Sets the <tt>MediaFormat</tt> in which this <tt>MediaDeviceSession</tt> outputs the media captured by its <tt>MediaDevice</tt>.
 * @param format the <tt>MediaFormat</tt> in which this<tt>MediaDeviceSession</tt> is to output the media captured by its <tt>MediaDevice</tt>
 */
public void setFormat(MediaFormat format){
  if (format instanceof VideoMediaFormat && ((VideoMediaFormat)format).getFrameRate() != -1) {
    FrameRateControl frameRateControl=(FrameRateControl)getCaptureDevice().getControl(FrameRateControl.class.getName());
    if (frameRateControl != null) {
      float frameRate=((VideoMediaFormat)format).getFrameRate();
      float maxSupportedFrameRate=frameRateControl.getMaxSupportedFrameRate();
      if ((maxSupportedFrameRate > 0) && (frameRate > maxSupportedFrameRate))       frameRate=maxSupportedFrameRate;
      if (frameRate > 0) {
        frameRateControl.setFrameRate(frameRate);
      }
    }
  }
  super.setFormat(format);
}

Fixed version (ground truth):
/** 
 * Sets the <tt>MediaFormat</tt> in which this <tt>MediaDeviceSession</tt> outputs the media captured by its <tt>MediaDevice</tt>.
 * @param format the <tt>MediaFormat</tt> in which this<tt>MediaDeviceSession</tt> is to output the media captured by its <tt>MediaDevice</tt>
 */
public void setFormat(MediaFormat format){
  if (format instanceof VideoMediaFormat && ((VideoMediaFormat)format).getFrameRate() != -1) {
    FrameRateControl frameRateControl=(FrameRateControl)getCaptureDevice().getControl(FrameRateControl.class.getName());
    if (frameRateControl != null) {
      float frameRate=((VideoMediaFormat)format).getFrameRate();
      float maxSupportedFrameRate=frameRateControl.getMaxSupportedFrameRate();
      if ((maxSupportedFrameRate > 0) && (frameRate > maxSupportedFrameRate))       frameRate=maxSupportedFrameRate;
      if (frameRate > 0) {
        frameRateControl.setFrameRate(frameRate);
        if (logger.isInfoEnabled()) {
          logger.info("String_Node_Str" + frameRate);
        }
      }
    }
  }
  super.setFormat(format);
}
Program: 103332
Project: 103332
Buggy source:
/** 
 * Removes the protocol specific group from the specified meta contact group and removes from meta contacts all proto contacts that belong to the same provider as the group which is being removed.
 * @param metaContainer the MetaContactGroup that we'd like to remove acontact group from.
 * @param groupToRemove the ContactGroup that we'd like removed.
 * @param sourceProvider the ProtocolProvider that the contact group belongsto.
 */
public void removeContactGroupFromMetaContactGroup(MetaContactGroupImpl metaContainer,ContactGroup groupToRemove,ProtocolProviderService sourceProvider){
  locallyRemoveAllContactsForProvider(metaContainer,groupToRemove);
  fireMetaContactGroupEvent(metaContainer,sourceProvider,groupToRemove,MetaContactGroupEvent.CONTACT_GROUP_REMOVED_FROM_META_GROUP);
}

Fixed version (ground truth):
/** 
 * Removes the protocol specific group from the specified meta contact group and removes from meta contacts all proto contacts that belong to the same provider as the group which is being removed.
 * @param metaContainer the MetaContactGroup that we'd like to remove acontact group from.
 * @param groupToRemove the ContactGroup that we'd like removed.
 * @param sourceProvider the ProtocolProvider that the contact group belongsto.
 */
public void removeContactGroupFromMetaContactGroup(MetaContactGroupImpl metaContainer,ContactGroup groupToRemove,ProtocolProviderService sourceProvider){
  if (metaContainer == null) {
    return;
  }
  locallyRemoveAllContactsForProvider(metaContainer,groupToRemove);
  fireMetaContactGroupEvent(metaContainer,sourceProvider,groupToRemove,MetaContactGroupEvent.CONTACT_GROUP_REMOVED_FROM_META_GROUP);
}
Program: 103334
Project: 103334
Buggy source:
/** 
 * Publishes the given <tt>status</tt> through the given <tt>presence</tt> operation set.
 * @param presence the operation set through which we publish the status
 * @param status the status to publish
 */
public PublishPresenceStatusThread(OperationSetPresence presence,PresenceStatus status){
  this.presence=presence;
  this.status=status;
}

Fixed version (ground truth):
/** 
 * Publishes the given <tt>status</tt> through the given <tt>presence</tt> operation set.
 * @param presence the operation set through which we publish the status
 * @param status the status to publish
 */
public PublishPresenceStatusThread(ProtocolProviderService protocolProvider,OperationSetPresence presence,PresenceStatus status){
  this.protocolProvider=protocolProvider;
  this.presence=presence;
  this.status=status;
}
Program: 103335
Project: 103335
Buggy source:
@Override public void run(){
  try {
    presence.publishPresenceStatus(status,"String_Node_Str");
  }
 catch (  IllegalArgumentException e1) {
    logger.error("String_Node_Str",e1);
  }
catch (  IllegalStateException e1) {
    logger.error("String_Node_Str",e1);
  }
catch (  OperationFailedException e1) {
    if (e1.getErrorCode() == OperationFailedException.GENERAL_ERROR) {
      String msgText=GuiActivator.getResources().getI18NString("String_Node_Str");
      new ErrorDialog(null,GuiActivator.getResources().getI18NString("String_Node_Str"),msgText,e1).showDialog();
    }
 else     if (e1.getErrorCode() == OperationFailedException.NETWORK_FAILURE) {
      String msgText=GuiActivator.getResources().getI18NString("String_Node_Str");
      new ErrorDialog(null,msgText,GuiActivator.getResources().getI18NString("String_Node_Str"),e1).showDialog();
    }
 else     if (e1.getErrorCode() == OperationFailedException.PROVIDER_NOT_REGISTERED) {
      String msgText=GuiActivator.getResources().getI18NString("String_Node_Str");
      new ErrorDialog(null,GuiActivator.getResources().getI18NString("String_Node_Str"),msgText,e1).showDialog();
    }
    logger.error("String_Node_Str",e1);
  }
}

Fixed version (ground truth):
@Override public void run(){
  try {
    presence.publishPresenceStatus(status,"String_Node_Str");
  }
 catch (  IllegalArgumentException e1) {
    logger.error("String_Node_Str",e1);
  }
catch (  IllegalStateException e1) {
    logger.error("String_Node_Str",e1);
  }
catch (  OperationFailedException e1) {
    if (e1.getErrorCode() == OperationFailedException.GENERAL_ERROR) {
      String msgText=GuiActivator.getResources().getI18NString("String_Node_Str",new String[]{protocolProvider.getAccountID().getUserID(),protocolProvider.getAccountID().getService()});
      new ErrorDialog(null,GuiActivator.getResources().getI18NString("String_Node_Str"),msgText,e1).showDialog();
    }
 else     if (e1.getErrorCode() == OperationFailedException.NETWORK_FAILURE) {
      String msgText=GuiActivator.getResources().getI18NString("String_Node_Str",new String[]{protocolProvider.getAccountID().getUserID(),protocolProvider.getAccountID().getService()});
      new ErrorDialog(null,msgText,GuiActivator.getResources().getI18NString("String_Node_Str"),e1).showDialog();
    }
 else     if (e1.getErrorCode() == OperationFailedException.PROVIDER_NOT_REGISTERED) {
      String msgText=GuiActivator.getResources().getI18NString("String_Node_Str",new String[]{protocolProvider.getAccountID().getUserID(),protocolProvider.getAccountID().getService()});
      new ErrorDialog(null,GuiActivator.getResources().getI18NString("String_Node_Str"),msgText,e1).showDialog();
    }
    logger.error("String_Node_Str",e1);
  }
}
Program: 103337
Project: 103337
Buggy source:
/** 
 * Publish present status. We search for the highest value in the given interval.
 * @param protocolProvider the protocol provider to which wechange the status.
 * @param floorStatusValue the min status value.
 * @param ceilStatusValue the max status value.
 */
private void publishStatus(ProtocolProviderService protocolProvider,int floorStatusValue,int ceilStatusValue){
  if (!protocolProvider.isRegistered())   return;
  OperationSetPresence presence=protocolProvider.getOperationSet(OperationSetPresence.class);
  if (presence == null)   return;
  Iterator<PresenceStatus> statusSet=presence.getSupportedStatusSet();
  PresenceStatus status=null;
  while (statusSet.hasNext()) {
    PresenceStatus currentStatus=statusSet.next();
    if (status == null && currentStatus.getStatus() < ceilStatusValue && currentStatus.getStatus() >= floorStatusValue) {
      status=currentStatus;
    }
    if (status != null) {
      if (currentStatus.getStatus() < ceilStatusValue && currentStatus.getStatus() >= floorStatusValue && currentStatus.getStatus() > status.getStatus()) {
        status=currentStatus;
      }
    }
  }
  if (status != null) {
    new PublishPresenceStatusThread(presence,status).start();
    this.saveStatusInformation(protocolProvider,status.getStatusName());
  }
}

Fixed version (ground truth):
/** 
 * Publish present status. We search for the highest value in the given interval.
 * @param protocolProvider the protocol provider to which wechange the status.
 * @param floorStatusValue the min status value.
 * @param ceilStatusValue the max status value.
 */
private void publishStatus(ProtocolProviderService protocolProvider,int floorStatusValue,int ceilStatusValue){
  if (!protocolProvider.isRegistered())   return;
  OperationSetPresence presence=protocolProvider.getOperationSet(OperationSetPresence.class);
  if (presence == null)   return;
  Iterator<PresenceStatus> statusSet=presence.getSupportedStatusSet();
  PresenceStatus status=null;
  while (statusSet.hasNext()) {
    PresenceStatus currentStatus=statusSet.next();
    if (status == null && currentStatus.getStatus() < ceilStatusValue && currentStatus.getStatus() >= floorStatusValue) {
      status=currentStatus;
    }
    if (status != null) {
      if (currentStatus.getStatus() < ceilStatusValue && currentStatus.getStatus() >= floorStatusValue && currentStatus.getStatus() > status.getStatus()) {
        status=currentStatus;
      }
    }
  }
  if (status != null) {
    new PublishPresenceStatusThread(protocolProvider,presence,status).start();
    this.saveStatusInformation(protocolProvider,status.getStatusName());
  }
}
Program: 103339
Project: 103339
Buggy source:
public PublishPresenceStatusThread(PresenceStatus status){
  this.status=status;
}

Fixed version (ground truth):
public PublishPresenceStatusThread(ProtocolProviderService protocolProvider,PresenceStatus status){
  this.protocolProvider=protocolProvider;
  this.status=status;
}
Program: 103340
Project: 103340
Buggy source:
/** 
 * Selects a specific <tt>PresenceStatus</tt> in this instance and the <tt>ProtocolProviderService</tt> it depicts.
 * @param presenceStatus the <tt>PresenceStatus</tt> to be selected in thisinstance and the <tt>ProtocolProviderService</tt> it depicts
 */
public void updateStatus(PresenceStatus presenceStatus){
  OperationSetPresence presence=MainFrame.getProtocolPresenceOpSet(protocolProvider);
  if (logger.isTraceEnabled())   logger.trace("String_Node_Str" + protocolProvider.getAccountID().getAccountAddress() + "String_Node_Str"+ presenceStatus.getStatusName());
  this.setSelectedStatus(presenceStatus);
  if (protocolProvider.isRegistered() && !presence.getPresenceStatus().equals(presenceStatus))   new PublishPresenceStatusThread(presenceStatus).start();
}

Fixed version (ground truth):
/** 
 * Selects a specific <tt>PresenceStatus</tt> in this instance and the <tt>ProtocolProviderService</tt> it depicts.
 * @param presenceStatus the <tt>PresenceStatus</tt> to be selected in thisinstance and the <tt>ProtocolProviderService</tt> it depicts
 */
public void updateStatus(PresenceStatus presenceStatus){
  OperationSetPresence presence=MainFrame.getProtocolPresenceOpSet(protocolProvider);
  if (logger.isTraceEnabled())   logger.trace("String_Node_Str" + protocolProvider.getAccountID().getAccountAddress() + "String_Node_Str"+ presenceStatus.getStatusName());
  this.setSelectedStatus(presenceStatus);
  if (protocolProvider.isRegistered() && !presence.getPresenceStatus().equals(presenceStatus))   new PublishPresenceStatusThread(protocolProvider,presenceStatus).start();
}
Program: 103341
Project: 103341
Buggy source:
public void run(){
  try {
    presence.publishPresenceStatus(status,"String_Node_Str");
  }
 catch (  IllegalArgumentException e1) {
    logger.error("String_Node_Str",e1);
  }
catch (  IllegalStateException e1) {
    logger.error("String_Node_Str",e1);
  }
catch (  OperationFailedException e1) {
    if (e1.getErrorCode() == OperationFailedException.GENERAL_ERROR) {
      String msgText=GuiActivator.getResources().getI18NString("String_Node_Str");
      new ErrorDialog(null,GuiActivator.getResources().getI18NString("String_Node_Str"),msgText,e1).showDialog();
    }
 else     if (e1.getErrorCode() == OperationFailedException.NETWORK_FAILURE) {
      String msgText=GuiActivator.getResources().getI18NString("String_Node_Str");
      new ErrorDialog(null,GuiActivator.getResources().getI18NString("String_Node_Str"),msgText,e1).showDialog();
    }
 else     if (e1.getErrorCode() == OperationFailedException.PROVIDER_NOT_REGISTERED) {
      String msgText=GuiActivator.getResources().getI18NString("String_Node_Str");
      new ErrorDialog(null,GuiActivator.getResources().getI18NString("String_Node_Str"),msgText,e1).showDialog();
    }
    logger.error("String_Node_Str",e1);
  }
}

Fixed version (ground truth):
public void run(){
  try {
    presence.publishPresenceStatus(status,"String_Node_Str");
  }
 catch (  IllegalArgumentException e1) {
    logger.error("String_Node_Str",e1);
  }
catch (  IllegalStateException e1) {
    logger.error("String_Node_Str",e1);
  }
catch (  OperationFailedException e1) {
    if (e1.getErrorCode() == OperationFailedException.GENERAL_ERROR) {
      String msgText=GuiActivator.getResources().getI18NString("String_Node_Str",new String[]{protocolProvider.getAccountID().getUserID(),protocolProvider.getAccountID().getService()});
      new ErrorDialog(null,GuiActivator.getResources().getI18NString("String_Node_Str"),msgText,e1).showDialog();
    }
 else     if (e1.getErrorCode() == OperationFailedException.NETWORK_FAILURE) {
      String msgText=GuiActivator.getResources().getI18NString("String_Node_Str",new String[]{protocolProvider.getAccountID().getUserID(),protocolProvider.getAccountID().getService()});
      new ErrorDialog(null,GuiActivator.getResources().getI18NString("String_Node_Str"),msgText,e1).showDialog();
    }
 else     if (e1.getErrorCode() == OperationFailedException.PROVIDER_NOT_REGISTERED) {
      String msgText=GuiActivator.getResources().getI18NString("String_Node_Str",new String[]{protocolProvider.getAccountID().getUserID(),protocolProvider.getAccountID().getService()});
      new ErrorDialog(null,GuiActivator.getResources().getI18NString("String_Node_Str"),msgText,e1).showDialog();
    }
    logger.error("String_Node_Str",e1);
  }
}
Program: 103343
Project: 103343
Buggy source:
/** 
 * Process the packet that is about to be sent to the server. The intercepted packet can be modified by the interceptor.<p> <p/> Interceptors are invoked using the same thread that requested the packet to be sent, so it's very important that implementations of this method not block for any extended period of time.
 * @param packet the packet to is going to be sent to the server.
 */
public void interceptPacket(Packet packet){
  try {
    if (packetLogging.isLoggingEnabled(PacketLoggingService.ProtocolName.JABBER)) {
      packetLogging.logPacket(PacketLoggingService.ProtocolName.JABBER,localAddress,connection.getSocket().getLocalPort(),remoteAddress,connection.getPort(),PacketLoggingService.TransportName.TCP,true,packet.toXML().getBytes("String_Node_Str"));
    }
  }
 catch (  Throwable t) {
    t.printStackTrace();
  }
}

Fixed version (ground truth):
/** 
 * Process the packet that is about to be sent to the server. The intercepted packet can be modified by the interceptor.<p> <p/> Interceptors are invoked using the same thread that requested the packet to be sent, so it's very important that implementations of this method not block for any extended period of time.
 * @param packet the packet to is going to be sent to the server.
 */
public void interceptPacket(Packet packet){
  try {
    if (packetLogging.isLoggingEnabled(PacketLoggingService.ProtocolName.JABBER) && packet != null && connection.getSocket() != null) {
      packetLogging.logPacket(PacketLoggingService.ProtocolName.JABBER,localAddress,connection.getSocket().getLocalPort(),remoteAddress,connection.getPort(),PacketLoggingService.TransportName.TCP,true,packet.toXML().getBytes("String_Node_Str"));
    }
  }
 catch (  Throwable t) {
    t.printStackTrace();
  }
}
Program: 103346
Project: 103346
Buggy source:
/** 
 * Adds new <tt>NetworkConfigurationChangeListener</tt> which will be informed for network configuration changes.
 * @param listener the listener.
 */
void addNetworkConfigurationChangeListener(NetworkConfigurationChangeListener listener){
synchronized (listeners) {
    if (!listeners.contains(listener)) {
      listeners.add(listener);
      initialFireEvents(listener);
    }
  }
  NetaddrActivator.getBundleContext().addServiceListener(this);
  if (this.systemActivityNotificationsService == null) {
    SystemActivityNotificationsService systActService=ServiceUtils.getService(NetaddrActivator.getBundleContext(),SystemActivityNotificationsService.class);
    handleNewSystemActivityNotificationsService(systActService);
  }
}

Fixed version (ground truth):
/** 
 * Adds new <tt>NetworkConfigurationChangeListener</tt> which will be informed for network configuration changes.
 * @param listener the listener.
 */
void addNetworkConfigurationChangeListener(NetworkConfigurationChangeListener listener){
  eventDispatcher.addNetworkConfigurationChangeListener(listener);
  initialFireEvents(listener);
  NetaddrActivator.getBundleContext().addServiceListener(this);
  if (this.systemActivityNotificationsService == null) {
    SystemActivityNotificationsService systActService=ServiceUtils.getService(NetaddrActivator.getBundleContext(),SystemActivityNotificationsService.class);
    handleNewSystemActivityNotificationsService(systActService);
  }
}
Program: 103348
Project: 103348
Buggy source:
/** 
 * Stop.
 */
void stop(){
  if (isRunning) {
synchronized (this) {
      isRunning=false;
      notifyAll();
    }
  }
}

Fixed version (ground truth):
/** 
 * Stop.
 */
void stop(){
  if (isRunning) {
synchronized (this) {
      isRunning=false;
      notifyAll();
    }
  }
  if (eventDispatcher != null)   eventDispatcher.stop();
}
Program: 103349
Project: 103349
Buggy source:
/** 
 * Remove <tt>NetworkConfigurationChangeListener</tt>.
 * @param listener the listener.
 */
void removeNetworkConfigurationChangeListener(NetworkConfigurationChangeListener listener){
synchronized (listeners) {
    listeners.remove(listener);
  }
}

Fixed version (ground truth):
/** 
 * Remove <tt>NetworkConfigurationChangeListener</tt>.
 * @param listener the listener.
 */
void removeNetworkConfigurationChangeListener(NetworkConfigurationChangeListener listener){
  eventDispatcher.removeNetworkConfigurationChangeListener(listener);
}
Program: 103350
Project: 103350
Buggy source:
/** 
 * Down all interfaces and fire events for it.
 */
private void downAllInterfaces(){
  Iterator<String> iter=activeInterfaces.keySet().iterator();
  while (iter.hasNext()) {
    String niface=iter.next();
    fireChangeEvent(new ChangeEvent(niface,ChangeEvent.IFACE_DOWN,true));
  }
  activeInterfaces.clear();
}

Fixed version (ground truth):
/** 
 * Down all interfaces and fire events for it.
 */
private void downAllInterfaces(){
  Iterator<String> iter=activeInterfaces.keySet().iterator();
  while (iter.hasNext()) {
    String niface=iter.next();
    eventDispatcher.fireChangeEvent(new ChangeEvent(niface,ChangeEvent.IFACE_DOWN,true));
  }
  activeInterfaces.clear();
}
Program: 103351
Project: 103351
Buggy source:
/** 
 * Used to fire initial events to newly added listers.
 * @param listener the listener to fire.
 */
private void initialFireEvents(NetworkConfigurationChangeListener listener){
  try {
    Enumeration<NetworkInterface> e=NetworkInterface.getNetworkInterfaces();
    while (e.hasMoreElements()) {
      NetworkInterface networkInterface=e.nextElement();
      if (isInterfaceLoopback(networkInterface))       continue;
      if (isInterfaceUp(networkInterface)) {
        Enumeration<InetAddress> as=networkInterface.getInetAddresses();
        boolean hasAddress=false;
        while (as.hasMoreElements()) {
          InetAddress inetAddress=as.nextElement();
          if (inetAddress.isLinkLocalAddress())           continue;
          hasAddress=true;
          fireChangeEvent(new ChangeEvent(networkInterface.getName(),ChangeEvent.ADDRESS_UP,inetAddress,false,true),listener);
        }
        if (hasAddress)         fireChangeEvent(new ChangeEvent(networkInterface.getName(),ChangeEvent.IFACE_UP,null,false,true),listener);
      }
    }
  }
 catch (  SocketException e) {
    logger.error("String_Node_Str",e);
  }
}

Fixed version (ground truth):
/** 
 * Used to fire initial events to newly added listers.
 * @param listener the listener to fire.
 */
private void initialFireEvents(NetworkConfigurationChangeListener listener){
  try {
    Enumeration<NetworkInterface> e=NetworkInterface.getNetworkInterfaces();
    while (e.hasMoreElements()) {
      NetworkInterface networkInterface=e.nextElement();
      if (isInterfaceLoopback(networkInterface))       continue;
      if (isInterfaceUp(networkInterface)) {
        Enumeration<InetAddress> as=networkInterface.getInetAddresses();
        boolean hasAddress=false;
        while (as.hasMoreElements()) {
          InetAddress inetAddress=as.nextElement();
          if (inetAddress.isLinkLocalAddress())           continue;
          hasAddress=true;
          NetworkEventDispatcher.fireChangeEvent(new ChangeEvent(networkInterface.getName(),ChangeEvent.ADDRESS_UP,inetAddress,false,true),listener);
        }
        if (hasAddress)         NetworkEventDispatcher.fireChangeEvent(new ChangeEvent(networkInterface.getName(),ChangeEvent.IFACE_UP,null,false,true),listener);
      }
    }
  }
 catch (  SocketException e) {
    logger.error("String_Node_Str",e);
  }
}
Program: 103353
Project: 103353
Buggy source:
/** 
 * Implements   {@link AbstractCodecExt#doProcess(Buffer,Buffer)}.
 * @param inputBuffer
 * @param outputBuffer
 * @return
 * @see AbstractCodecExt#doProcess(Buffer,Buffer)
 */
protected int doProcess(Buffer inputBuffer,Buffer outputBuffer){
  byte[] input=(byte[])inputBuffer.getData();
  int inputLength=inputBuffer.getLength();
  if (this.inputLength != inputLength)   initDec(inputLength);
  int outputLength=dec.ULP_inst.blockl * 2;
  byte[] output=validateByteArraySize(outputBuffer,outputLength);
  int outputOffset=0;
  dec.decode(output,outputOffset,input,inputBuffer.getOffset(),(short)1);
  updateOutput(outputBuffer,getOutputFormat(),outputLength,outputOffset);
  return BUFFER_PROCESSED_OK;
}

Fixed version (ground truth):
/** 
 * Implements   {@link AbstractCodecExt#doProcess(Buffer,Buffer)}.
 * @param inputBuffer
 * @param outputBuffer
 * @return
 * @see AbstractCodecExt#doProcess(Buffer,Buffer)
 */
protected int doProcess(Buffer inputBuffer,Buffer outputBuffer){
  byte[] input=(byte[])inputBuffer.getData();
  int inputLength=inputBuffer.getLength();
  if (offsets.size() == 0 && ((inputLength > ilbc_constants.NO_OF_BYTES_20MS && inputLength != ilbc_constants.NO_OF_BYTES_30MS) || inputLength > ilbc_constants.NO_OF_BYTES_30MS)) {
    int nb=0;
    int len=0;
    if ((inputLength % ilbc_constants.NO_OF_BYTES_20MS) == 0) {
      nb=(inputLength % ilbc_constants.NO_OF_BYTES_20MS);
      len=ilbc_constants.NO_OF_BYTES_20MS;
    }
 else     if ((inputLength % ilbc_constants.NO_OF_BYTES_30MS) == 0) {
      nb=(inputLength % ilbc_constants.NO_OF_BYTES_30MS);
      len=ilbc_constants.NO_OF_BYTES_30MS;
    }
    if (this.inputLength != len)     initDec(len);
    for (int i=0; i < nb; i++) {
      offsets.add(new Integer(inputLength + (i * len)));
    }
  }
 else   if (this.inputLength != inputLength)   initDec(inputLength);
  int outputLength=dec.ULP_inst.blockl * 2;
  byte[] output=validateByteArraySize(outputBuffer,outputLength);
  int outputOffset=0;
  int offsetToAdd=0;
  if (offsets.size() > 0)   offsetToAdd=offsets.remove(0).intValue();
  dec.decode(output,outputOffset,input,inputBuffer.getOffset() + offsetToAdd,(short)1);
  updateOutput(outputBuffer,getOutputFormat(),outputLength,outputOffset);
  int flags=BUFFER_PROCESSED_OK;
  if (offsets.size() > 0) {
    flags|=INPUT_BUFFER_NOT_CONSUMED;
  }
  return flags;
}
Program: 103354
Project: 103354
Buggy source:
/** 
 * Implements   {@link AbstractCodecExt#doClose()}.
 * @see AbstractCodecExt#doClose()
 */
protected void doClose(){
  enc=null;
  outputLength=0;
  inputLength=0;
  prevInput=null;
  prevInputLength=0;
}

Fixed version (ground truth):
/** 
 * Implements   {@link AbstractCodecExt#doClose()}.
 * @see AbstractCodecExt#doClose()
 */
protected void doClose(){
  enc=null;
  outputLength=0;
  inputLength=0;
  prevInput=null;
  prevInputLength=0;
  duration=0;
}
Program: 103355
Project: 103355
Buggy source:
/** 
 * Implements   {@link AbstractCodecExt#doOpen()}.
 * @see AbstractCodecExt#doOpen()
 */
protected void doOpen(){
  int mode=Constants.ILBC_MODE;
  enc=new ilbc_encoder(mode);
switch (mode) {
case 20:
    outputLength=ilbc_constants.NO_OF_BYTES_20MS;
  break;
case 30:
outputLength=ilbc_constants.NO_OF_BYTES_30MS;
break;
default :
throw new IllegalStateException("String_Node_Str");
}
inputLength=enc.ULP_inst.blockl * 2;
prevInput=new byte[inputLength];
prevInputLength=0;
}

Fixed version (ground truth):
/** 
 * Implements   {@link AbstractCodecExt#doOpen()}.
 * @see AbstractCodecExt#doOpen()
 */
protected void doOpen(){
  int mode=Constants.ILBC_MODE;
  enc=new ilbc_encoder(mode);
switch (mode) {
case 20:
    outputLength=ilbc_constants.NO_OF_BYTES_20MS;
  break;
case 30:
outputLength=ilbc_constants.NO_OF_BYTES_30MS;
break;
default :
throw new IllegalStateException("String_Node_Str");
}
duration=mode * 1000000;
inputLength=enc.ULP_inst.blockl * 2;
prevInput=new byte[inputLength];
prevInputLength=0;
}
Program: 103356
Project: 103356
Buggy source:
/** 
 * Implements   {@link AbstractCodecExt#doProcess(Buffer,Buffer)}.
 * @param inputBuffer
 * @param outputBuffer
 * @return
 * @see AbstractCodecExt#doProcess(Buffer,Buffer)
 */
protected int doProcess(Buffer inputBuffer,Buffer outputBuffer){
  int inputLength=inputBuffer.getLength();
  byte[] input=(byte[])inputBuffer.getData();
  int inputOffset=inputBuffer.getOffset();
  if ((prevInputLength != 0) || (inputLength < this.inputLength)) {
    int bytesToCopy=this.inputLength - prevInputLength;
    if (bytesToCopy > inputLength)     bytesToCopy=inputLength;
    System.arraycopy(input,inputOffset,prevInput,prevInputLength,bytesToCopy);
    prevInputLength+=bytesToCopy;
    inputBuffer.setLength(inputLength - bytesToCopy);
    inputBuffer.setOffset(inputOffset + bytesToCopy);
    inputLength=prevInputLength;
    input=prevInput;
    inputOffset=0;
  }
 else {
    inputBuffer.setLength(inputLength - this.inputLength);
    inputBuffer.setOffset(inputOffset + this.inputLength);
  }
  int ret;
  if (inputLength >= this.inputLength) {
    prevInputLength=0;
    int outputOffset=0;
    byte[] output=validateByteArraySize(outputBuffer,outputOffset + outputLength);
    enc.encode(output,outputOffset,input,inputOffset);
    updateOutput(outputBuffer,outputFormat,outputLength,outputOffset);
    ret=BUFFER_PROCESSED_OK;
  }
 else   ret=OUTPUT_BUFFER_NOT_FILLED;
  if (inputBuffer.getLength() > 0)   ret|=INPUT_BUFFER_NOT_CONSUMED;
  return ret;
}

Fixed version (ground truth):
/** 
 * Implements   {@link AbstractCodecExt#doProcess(Buffer,Buffer)}.
 * @param inputBuffer
 * @param outputBuffer
 * @return
 * @see AbstractCodecExt#doProcess(Buffer,Buffer)
 */
protected int doProcess(Buffer inputBuffer,Buffer outputBuffer){
  int inputLength=inputBuffer.getLength();
  byte[] input=(byte[])inputBuffer.getData();
  int inputOffset=inputBuffer.getOffset();
  if ((prevInputLength != 0) || (inputLength < this.inputLength)) {
    int bytesToCopy=this.inputLength - prevInputLength;
    if (bytesToCopy > inputLength)     bytesToCopy=inputLength;
    System.arraycopy(input,inputOffset,prevInput,prevInputLength,bytesToCopy);
    prevInputLength+=bytesToCopy;
    inputBuffer.setLength(inputLength - bytesToCopy);
    inputBuffer.setOffset(inputOffset + bytesToCopy);
    inputLength=prevInputLength;
    input=prevInput;
    inputOffset=0;
  }
 else {
    inputBuffer.setLength(inputLength - this.inputLength);
    inputBuffer.setOffset(inputOffset + this.inputLength);
  }
  int ret;
  if (inputLength >= this.inputLength) {
    prevInputLength=0;
    int outputOffset=0;
    byte[] output=validateByteArraySize(outputBuffer,outputOffset + outputLength);
    enc.encode(output,outputOffset,input,inputOffset);
    updateOutput(outputBuffer,getOutputFormat(),outputLength,outputOffset);
    outputBuffer.setDuration(duration);
    ret=BUFFER_PROCESSED_OK;
  }
 else   ret=OUTPUT_BUFFER_NOT_FILLED;
  if (inputBuffer.getLength() > 0)   ret|=INPUT_BUFFER_NOT_CONSUMED;
  return ret;
}
Program: 103357
Project: 103357
Buggy source:
/** 
 * Notifies this manager that a specific <tt>ProtocolProviderService</tt> has been registered as a service.
 * @param provider the <tt>ProtocolProviderService</tt> which has beenregistered as a service.
 */
private void handleProviderAdded(final ProtocolProviderService provider){
  new Thread(new Runnable(){
    public void run(){
      String className=provider.getClass().getName();
      className=className.substring(0,className.lastIndexOf('.'));
      String acc=ProtocolProviderFactory.findAccountPrefix(bundleContext,provider.getAccountID(),className);
      String password=getCredentialsService().loadPassword(acc);
      enableContactSource(provider.getAccountID().getAccountAddress(),password);
    }
  }
).start();
}

Fixed version (ground truth):
/** 
 * Notifies this manager that a specific <tt>ProtocolProviderService</tt> has been registered as a service.
 * @param provider the <tt>ProtocolProviderService</tt> which has beenregistered as a service.
 */
private void handleProviderAdded(final ProtocolProviderService provider){
  new Thread(new Runnable(){
    public void run(){
      String className=provider.getClass().getName();
      className=className.substring(0,className.lastIndexOf('.'));
      String acc=ProtocolProviderFactory.findAccountPrefix(bundleContext,provider.getAccountID(),className);
      String password=getCredentialsService().loadPassword(acc);
      if (configService.getBoolean(acc + "String_Node_Str",true)) {
        enableContactSource(provider.getAccountID().getAccountAddress(),password);
      }
    }
  }
).start();
}
Program: 103358
Project: 103358
Buggy source:
public void run(){
  String className=provider.getClass().getName();
  className=className.substring(0,className.lastIndexOf('.'));
  String acc=ProtocolProviderFactory.findAccountPrefix(bundleContext,provider.getAccountID(),className);
  String password=getCredentialsService().loadPassword(acc);
  enableContactSource(provider.getAccountID().getAccountAddress(),password);
}

Fixed version (ground truth):
public void run(){
  String className=provider.getClass().getName();
  className=className.substring(0,className.lastIndexOf('.'));
  String acc=ProtocolProviderFactory.findAccountPrefix(bundleContext,provider.getAccountID(),className);
  String password=getCredentialsService().loadPassword(acc);
  if (configService.getBoolean(acc + "String_Node_Str",true)) {
    enableContactSource(provider.getAccountID().getAccountAddress(),password);
  }
}
Program: 103360
Project: 103360
Buggy source:
/** 
 * Process candidates received.
 * @param sessionInitIQ The {@link SessionIQ} that created the session weare handling here
 * @throws OperationFailedException if something goes wrong
 */
public void processCandidates(SessionIQ sessionInitIQ) throws OperationFailedException {
  Collection<PacketExtension> extensions=sessionInitIQ.getExtensions();
  List<GTalkCandidatePacketExtension> candidates=new ArrayList<GTalkCandidatePacketExtension>();
  for (  PacketExtension ext : extensions) {
    if (ext.getElementName().equalsIgnoreCase(GTalkCandidatePacketExtension.ELEMENT_NAME)) {
      GTalkCandidatePacketExtension cand=(GTalkCandidatePacketExtension)ext;
      candidates.add(cand);
    }
  }
  try {
    getMediaHandler().processCandidates(candidates);
  }
 catch (  OperationFailedException ofe) {
    logger.warn("String_Node_Str",ofe);
    String reasonText="String_Node_Str" + ofe.getMessage();
    SessionIQ errResp=GTalkPacketFactory.createSessionTerminate(sessionInitIQ.getTo(),sessionInitIQ.getFrom(),sessionInitIQ.getID(),Reason.GENERAL_ERROR,reasonText);
    getMediaHandler().getTransportManager().close();
    setState(CallPeerState.FAILED,reasonText);
    getProtocolProvider().getConnection().sendPacket(errResp);
    return;
  }
  if (freeswitchSession != null) {
    if (!isInitiator)     processSessionAccept(freeswitchSession);
 else     answer();
    freeswitchSession=null;
  }
}

Fixed version (ground truth):
/** 
 * Process candidates received.
 * @param sessionInitIQ The {@link SessionIQ} that created the session weare handling here
 */
public void processCandidates(SessionIQ sessionInitIQ){
  Collection<PacketExtension> extensions=sessionInitIQ.getExtensions();
  List<GTalkCandidatePacketExtension> candidates=new ArrayList<GTalkCandidatePacketExtension>();
  for (  PacketExtension ext : extensions) {
    if (ext.getElementName().equalsIgnoreCase(GTalkCandidatePacketExtension.ELEMENT_NAME)) {
      GTalkCandidatePacketExtension cand=(GTalkCandidatePacketExtension)ext;
      candidates.add(cand);
    }
  }
  try {
    getMediaHandler().processCandidates(candidates);
  }
 catch (  OperationFailedException ofe) {
    logger.warn("String_Node_Str",ofe);
    String reasonText="String_Node_Str" + ofe.getMessage();
    SessionIQ errResp=GTalkPacketFactory.createSessionTerminate(sessionInitIQ.getTo(),sessionInitIQ.getFrom(),sessionInitIQ.getID(),Reason.GENERAL_ERROR,reasonText);
    getMediaHandler().getTransportManager().close();
    setState(CallPeerState.FAILED,reasonText);
    getProtocolProvider().getConnection().sendPacket(errResp);
    return;
  }
  if (freeswitchSession != null) {
    if (!isInitiator)     processSessionAccept(freeswitchSession);
 else {
      try {
        answer();
      }
 catch (      OperationFailedException e) {
        logger.info("String_Node_Str");
      }
    }
    freeswitchSession=null;
  }
}
Program: 103361
Project: 103361
Buggy source:
/** 
 * Removes the room that is currently selected.
 */
void removeSelectedRoom(){
  ChatRoomWrapper chatRoomWrapper=chatRoomsTableModel.getValueAt(chatRoomList.getSelectedRow());
  ConferenceChatManager conferenceManager=GuiActivator.getUIService().getConferenceChatManager();
  conferenceManager.removeChatRoom(chatRoomWrapper);
}

Fixed version (ground truth):
/** 
 * Removes the room that is currently selected.
 */
void removeSelectedRoom(){
  if (chatRoomList.getSelectedRow() == -1)   return;
  ChatRoomWrapper chatRoomWrapper=chatRoomsTableModel.getValueAt(chatRoomList.getSelectedRow());
  ConferenceChatManager conferenceManager=GuiActivator.getUIService().getConferenceChatManager();
  conferenceManager.removeChatRoom(chatRoomWrapper);
}
Program: 103362
Project: 103362
Buggy source:
/** 
 * Initializes the chat rooms list interface.
 */
private void initChatRoomList(){
  this.chatRoomsTableModel=new ChatRoomTableModel(chatRoomList);
  this.chatRoomList.addMouseListener(this);
  this.chatRoomList.setDefaultRenderer(ProtocolProviderService.class,new ProtocolProviderTableCellRenderer());
  this.chatRoomList.setDefaultRenderer(ChatRoomWrapper.class,new ChatRoomTableCellRenderer());
  this.chatRoomList.setOpaque(false);
  this.chatRoomList.setModel(chatRoomsTableModel);
  ConferenceChatManager confChatManager=GuiActivator.getUIService().getConferenceChatManager();
  confChatManager.addChatRoomListChangeListener(chatRoomsTableModel);
}

Fixed version (ground truth):
/** 
 * Initializes the chat rooms list interface.
 */
private void initChatRoomList(){
  this.chatRoomsTableModel=new ChatRoomTableModel(chatRoomList);
  this.chatRoomList.addMouseListener(this);
  this.chatRoomList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  this.chatRoomList.setDefaultRenderer(ProtocolProviderService.class,new ProtocolProviderTableCellRenderer());
  this.chatRoomList.setDefaultRenderer(ChatRoomWrapper.class,new ChatRoomTableCellRenderer());
  this.chatRoomList.setOpaque(false);
  this.chatRoomList.setModel(chatRoomsTableModel);
  ConferenceChatManager confChatManager=GuiActivator.getUIService().getConferenceChatManager();
  confChatManager.addChatRoomListChangeListener(chatRoomsTableModel);
}
Program: 103364
Project: 103364
Buggy source:
/** 
 * Called when a new room occupant has joined the room. Note: Take in consideration that when you join a room you will receive the list of current occupants in the room. This message will be sent for each occupant.
 * @param participant the participant that has just joined the room(e.g. room@conference.jabber.org/nick).
 */
public void joined(String participant){
  if (logger.isInfoEnabled())   logger.info(participant + "String_Node_Str" + getName()+ "String_Node_Str");
  String participantName=StringUtils.parseResource(participant);
  if (nickname.equals(getNickName(participantName)) || members.containsKey(participantName))   return;
  if (members.contains(participantName))   return;
  Occupant occupant=multiUserChat.getOccupant(participant);
  ChatRoomMemberJabberImpl member=new ChatRoomMemberJabberImpl(ChatRoomJabberImpl.this,occupant.getNick(),occupant.getJid());
  members.put(participantName,member);
  fireMemberPresenceEvent(member,ChatRoomMemberPresenceChangeEvent.MEMBER_JOINED,null);
}

Fixed version (ground truth):
/** 
 * Called when a new room occupant has joined the room. Note: Take in consideration that when you join a room you will receive the list of current occupants in the room. This message will be sent for each occupant.
 * @param participant the participant that has just joined the room(e.g. room@conference.jabber.org/nick).
 */
public void joined(String participant){
  if (logger.isInfoEnabled())   logger.info(participant + "String_Node_Str" + getName()+ "String_Node_Str");
  String participantName=StringUtils.parseResource(participant);
  if (nickname.equals(participantName) || members.containsKey(participantName))   return;
  if (members.contains(participantName))   return;
  Occupant occupant=multiUserChat.getOccupant(participant);
  ChatRoomMemberJabberImpl member=new ChatRoomMemberJabberImpl(ChatRoomJabberImpl.this,occupant.getNick(),occupant.getJid());
  members.put(participantName,member);
  fireMemberPresenceEvent(member,ChatRoomMemberPresenceChangeEvent.MEMBER_JOINED,null);
}
Program: 103365
Project: 103365
Buggy source:
/** 
 * Compares to presets and its dimensions.
 * @param o object to compare to.
 * @return a negative integer, zero, or a positive integer as this object isless than, equal to, or greater than the specified object.
 */
public int compareTo(QualityPreset o){
  if (resolution.equals(o.resolution))   return 0;
 else   if ((resolution.height < o.resolution.height) && (resolution.width < o.resolution.width))   return -1;
 else   return 1;
}

Fixed version (ground truth):
/** 
 * Compares to presets and its dimensions.
 * @param o object to compare to.
 * @return a negative integer, zero, or a positive integer as this object isless than, equal to, or greater than the specified object.
 */
public int compareTo(QualityPreset o){
  if (resolution == null)   return -1;
 else   if (o == null)   return 1;
 else   if (resolution.equals(o.resolution))   return 0;
 else   if ((resolution.height < o.resolution.height) && (resolution.width < o.resolution.width))   return -1;
 else   return 1;
}