nus-yam/ex-repair huggingface dataset:
Program: 79200
Project: 79200
Buggy source:
/** 
 * load report item generation extension definitions 
 */
protected void loadGenerationExtensionDefns(){
  IExtensionRegistry registry=Platform.getExtensionRegistry();
  IExtensionPoint extPoint=registry.getExtensionPoint(EXTENSION_POINT_GENERATION);
  if (extPoint == null)   return;
  IExtension[] exts=extPoint.getExtensions();
  for (int i=0; i < exts.length; i++) {
    IConfigurationElement[] configs=exts[i].getConfigurationElements();
    for (int j=0; j < configs.length; j++) {
      String itemName=configs[j].getAttribute("String_Node_Str");
      generationExtensions.put(itemName,configs[i]);
    }
  }
}

Fixed version (ground truth):
/** 
 * load report item generation extension definitions 
 */
protected void loadGenerationExtensionDefns(){
  IExtensionRegistry registry=Platform.getExtensionRegistry();
  IExtensionPoint extPoint=registry.getExtensionPoint(EXTENSION_POINT_GENERATION);
  if (extPoint == null)   return;
  IExtension[] exts=extPoint.getExtensions();
  for (int i=0; i < exts.length; i++) {
    IConfigurationElement[] configs=exts[i].getConfigurationElements();
    for (int j=0; j < configs.length; j++) {
      String itemName=configs[j].getAttribute("String_Node_Str");
      generationExtensions.put(itemName,configs[j]);
    }
  }
}
Program: 79201
Project: 79201
Buggy source:
/** 
 * Validates whether the given element can recursively resides in the specific slot of specific container type when trying to add an element.
 * @param design the report design
 * @param element the container element
 * @param toAdd the element definition to add
 * @return error list, each of which is the instance of<code>SemanticException</code>.
 */
public List validateForAdding(ReportDesign design,DesignElement element,IElementDefn toAdd){
  ElementDefn listingDefn=(ElementDefn)MetaDataDictionary.getInstance().getElement(ReportDesignConstants.LISTING_ITEM);
  if (!listingDefn.isKindOf(toAdd))   return Collections.EMPTY_LIST;
  return doValidate(design,element);
}

Fixed version (ground truth):
/** 
 * Validates whether the given element can recursively resides in the specific slot of specific container type when trying to add an element.
 * @param design the report design
 * @param element the container element
 * @param toAdd the element definition to add
 * @return error list, each of which is the instance of<code>SemanticException</code>.
 */
public List validateForAdding(ReportDesign design,DesignElement element,IElementDefn toAdd){
  ElementDefn listingDefn=(ElementDefn)MetaDataDictionary.getInstance().getElement(ReportDesignConstants.LISTING_ITEM);
  if (!listingDefn.isKindOf(toAdd))   return Collections.EMPTY_LIST;
  return doValidate(design,element,DesignElement.NO_SLOT);
}
Program: 79202
Project: 79202
Buggy source:
private List doValidate(ReportDesign design,DesignElement toValidate){
  List list=new ArrayList();
  DesignElement curContainer=toValidate.getContainer();
  int curSlotID=toValidate.getContainerSlot();
  while (curContainer != null) {
    IElementDefn containerDefn=curContainer.getDefn();
    if (ReportDesignConstants.TABLE_ITEM.equalsIgnoreCase(containerDefn.getName()) && curSlotID == TableItem.HEADER_SLOT) {
      list.add(new ContentException(curContainer,curSlotID,toValidate,ContentException.DESIGN_EXCEPTION_INVALID_CONTEXT_CONTAINMENT));
    }
    curSlotID=curContainer.getContainerSlot();
    curContainer=curContainer.getContainer();
  }
  return list;
}

Fixed version (ground truth):
/** 
 * Checks whether the <code>toValidate</code> is or is in the table element and its slotId is <code>TableItem.HEADER_SLOT</code>.
 * @param design the report design
 * @param toValidate the element to validate
 * @param slotId the slot id
 * @return <code>true</code> if <code>toValidate</code> is a table itemor nested in the table item and the table slot is <code>TableItem.HEADER_SLOT</code>.
 */
private List doValidate(ReportDesign design,DesignElement toValidate,int slotId){
  List list=new ArrayList();
  DesignElement curContainer=toValidate;
  int curSlotID=slotId;
  if (slotId == DesignElement.NO_SLOT) {
    curContainer=toValidate.getContainer();
    curSlotID=toValidate.getContainerSlot();
  }
  while (curContainer != null) {
    IElementDefn containerDefn=curContainer.getDefn();
    if (ReportDesignConstants.TABLE_ITEM.equalsIgnoreCase(containerDefn.getName()) && curSlotID == TableItem.HEADER_SLOT) {
      list.add(new ContentException(curContainer,curSlotID,toValidate,ContentException.DESIGN_EXCEPTION_INVALID_CONTEXT_CONTAINMENT));
    }
    curSlotID=curContainer.getContainerSlot();
    curContainer=curContainer.getContainer();
  }
  return list;
}
Program: 79203
Project: 79203
Buggy source:
/** 
 * Validates whether the given element can recursively resides in the specific slot of specific container type.
 * @param design the report design
 * @param element the element to validate
 * @return error list, each of which is the instance of<code>SemanticException</code>.
 */
public List validate(ReportDesign design,DesignElement element){
  if (!(element instanceof ListingElement))   return Collections.EMPTY_LIST;
  return doValidate(design,element);
}

Fixed version (ground truth):
/** 
 * Validates whether the given element can recursively resides in the specific slot of specific container type.
 * @param design the report design
 * @param element the element to validate
 * @return error list, each of which is the instance of<code>SemanticException</code>.
 */
public List validate(ReportDesign design,DesignElement element){
  if (!(element instanceof ListingElement))   return Collections.EMPTY_LIST;
  return doValidate(design,element,DesignElement.NO_SLOT);
}
Program: 79204
Project: 79204
Buggy source:
public void setDefaultValue(Element romProp,String defaultValue){
  NodeList list=romProp.getElementsByTagName("String_Node_Str");
  Element valueNode=null;
  if (list.getLength() == 0) {
    valueNode=document.createElement("String_Node_Str");
    romProp.appendChild(valueNode);
  }
 else   valueNode=(Element)list.item(0);
  valueNode.setTextContent(defaultValue);
}

Fixed version (ground truth):
public void setDefaultValue(Element romProp,String defaultValue){
  NodeList list=romProp.getElementsByTagName("String_Node_Str");
  Element valueNode=null;
  if (list.getLength() == 0) {
    valueNode=document.createElement("String_Node_Str");
    romProp.appendChild(valueNode);
  }
 else   valueNode=(Element)list.item(0);
  valueNode.setNodeValue(defaultValue);
}
Program: 79205
Project: 79205
Buggy source:
public String getDefaultValue(Element romProp){
  NodeList list=romProp.getElementsByTagName("String_Node_Str");
  if (list.getLength() == 0)   return null;
  Element valueNode=(Element)list.item(0);
  return valueNode.getTextContent();
}

Fixed version (ground truth):
public String getDefaultValue(Element romProp){
  NodeList list=romProp.getElementsByTagName("String_Node_Str");
  if (list.getLength() == 0)   return null;
  Element valueNode=(Element)list.item(0);
  return valueNode.getNodeValue();
}
Program: 79206
Project: 79206
Buggy source:
public String getContents(){
  ArrayList list=new ArrayList();
  list.addAll(((SlotDefn)defn).getRealContentElements());
  Collections.sort(list,new ElementComparator());
  Iterator iter=list.iterator();
  StringBuffer contents=new StringBuffer();
  while (iter.hasNext()) {
    ElementDefn element=(ElementDefn)iter.next();
    if (contents.length() > 0)     contents.append("String_Node_Str");
    contents.append("String_Node_Str");
    contents.append(element.getName());
    contents.append("String_Node_Str");
    contents.append(element.getName());
    contents.append("String_Node_Str");
  }
  if (defn.isMultipleCardinality())   contents.insert(0,"String_Node_Str");
  return contents.toString();
}

Fixed version (ground truth):
public String getContents(){
  ArrayList list=new ArrayList();
  list.addAll(((SlotDefn)defn).getContentElements());
  Collections.sort(list,new ElementComparator());
  Iterator iter=list.iterator();
  StringBuffer contents=new StringBuffer();
  while (iter.hasNext()) {
    ElementDefn element=(ElementDefn)iter.next();
    if (contents.length() > 0)     contents.append("String_Node_Str");
    contents.append("String_Node_Str");
    contents.append(element.getName());
    contents.append("String_Node_Str");
    contents.append(element.getName());
    contents.append("String_Node_Str");
  }
  if (defn.isMultipleCardinality())   contents.insert(0,"String_Node_Str");
  return contents.toString();
}
Program: 79207
Project: 79207
Buggy source:
private void loadDriverExtensions(){
  if (driverExtensions != null)   return;
  driverExtensions=new HashMap();
  IExtensionRegistry extReg=Platform.getExtensionRegistry();
  IExtensionPoint extPoint=extReg.getExtensionPoint(OdaJdbcDriver.Constants.DRIVER_INFO_EXTENSION);
  IExtension[] exts=extPoint.getExtensions();
  if (exts == null)   return;
  for (int e=0; e < exts.length; e++) {
    IConfigurationElement[] configElems=exts[e].getConfigurationElements();
    if (configElems == null)     continue;
    for (int i=0; i < configElems.length; i++) {
      if (configElems[i].getName().equals(OdaJdbcDriver.Constants.DRIVER_INFO_ELEM_JDBCDRIVER)) {
        String driverClass=configElems[i].getAttribute(OdaJdbcDriver.Constants.DRIVER_INFO_ATTR_DRIVERCLASS);
        String connectionFactory=configElems[i].getAttribute(OdaJdbcDriver.Constants.DRIVER_INFO_ATTR_CONNFACTORY);
        logger.info("String_Node_Str" + driverClass + "String_Node_Str"+ connectionFactory);
        if (driverClass != null && driverClass.length() > 0 && connectionFactory != null && connectionFactory.length() > 0) {
          driverExtensions.put(driverClass,configElems[i]);
        }
      }
    }
  }
}

Fixed version (ground truth):
private void loadDriverExtensions(){
  if (driverExtensions != null)   return;
  driverExtensions=new HashMap();
  IExtensionRegistry extReg=Platform.getExtensionRegistry();
  IExtensionPoint extPoint=extReg.getExtensionPoint(OdaJdbcDriver.Constants.DRIVER_INFO_EXTENSION);
  if (extPoint == null)   return;
  IExtension[] exts=extPoint.getExtensions();
  if (exts == null)   return;
  for (int e=0; e < exts.length; e++) {
    IConfigurationElement[] configElems=exts[e].getConfigurationElements();
    if (configElems == null)     continue;
    for (int i=0; i < configElems.length; i++) {
      if (configElems[i].getName().equals(OdaJdbcDriver.Constants.DRIVER_INFO_ELEM_JDBCDRIVER)) {
        String driverClass=configElems[i].getAttribute(OdaJdbcDriver.Constants.DRIVER_INFO_ATTR_DRIVERCLASS);
        String connectionFactory=configElems[i].getAttribute(OdaJdbcDriver.Constants.DRIVER_INFO_ATTR_CONNFACTORY);
        logger.info("String_Node_Str" + driverClass + "String_Node_Str"+ connectionFactory);
        if (driverClass != null && driverClass.length() > 0 && connectionFactory != null && connectionFactory.length() > 0) {
          driverExtensions.put(driverClass,configElems[i]);
        }
      }
    }
  }
}
Program: 79209
Project: 79209
Buggy source:
/** 
 * Constructs the content event with the container element, content element, the slot within this container and the event operation kind.
 * @param theContainer the container element
 * @param theContent the content element
 * @param theSlot the slot within the container
 * @param theAction the action causing this event
 */
public ContentEvent(DesignElement theContainer,DesignElement theContent,int theSlot,int theAction){
  super(theContainer);
  slot=theSlot;
  action=theAction;
  content=theContent;
}

Fixed version (ground truth):
/** 
 * /** Constructs the content event with the container element, content element, the slot within this container and the event operation kind.
 * @param theContainer the container element
 * @param theContent the content element
 * @param theSlot the slot within the container
 * @param theAction the action causing this event
 */
public ContentEvent(DesignElement theContainer,DesignElement theContent,int theSlot,int theAction){
  super(theContainer);
  slot=theSlot;
  action=theAction;
  content=theContent;
}
Program: 79210
Project: 79210
Buggy source:
/** 
 * Clears references of elements that are referred by the to-be-deleted element, except for extends and style element references. Unlike the method   {@link #adjustReferenceClients(ReferenceableElement)}, this method removes references from those elements that are referred.
 * @param element the element to be deleted
 */
private void adjustReferredClients(DesignElement element){
}

Fixed version (ground truth):
/** 
 * Clears references of elements that are referred by the to-be-deleted element, except for extends and style element references. Unlike the method   {@link #adjustReferenceClients(ReferenceableElement,boolean)}, this method removes references from those elements that are referred.
 * @param element the element to be deleted
 */
private void adjustReferredClients(DesignElement element){
}
Program: 79212
Project: 79212
Buggy source:
public NotificationEvent getEvent(){
  return new ContentEvent(container,slot,ContentEvent.SHIFT);
}

Fixed version (ground truth):
public NotificationEvent getEvent(){
  return new ContentEvent(container,content,slot,ContentEvent.SHIFT);
}
Program: 79213
Project: 79213
Buggy source:
private void loadDriverExtensions(){
  if (driverExtensions != null)   return;
  driverExtensions=new HashMap();
  IExtensionRegistry extReg=Platform.getExtensionRegistry();
  IConfigurationElement[] configElems=extReg.getConfigurationElementsFor(OdaJdbcDriver.Constants.DRIVER_INFO_EXTENSION);
  if (configElems != null) {
    for (int i=0; i < configElems.length; i++) {
      if (configElems[i].getName().equals(OdaJdbcDriver.Constants.DRIVER_INFO_ELEM_JDBCDRIVER)) {
        String driverClass=configElems[i].getAttribute(OdaJdbcDriver.Constants.DRIVER_INFO_ATTR_DRIVERCLASS);
        String connectionFactory=configElems[i].getAttribute(OdaJdbcDriver.Constants.DRIVER_INFO_ATTR_CONNFACTORY);
        logger.info("String_Node_Str" + driverClass + "String_Node_Str"+ connectionFactory);
        if (driverClass != null && driverClass.length() > 0 && connectionFactory != null && connectionFactory.length() > 0) {
          driverExtensions.put(driverClass,configElems[i]);
        }
      }
    }
  }
}

Fixed version (ground truth):
private void loadDriverExtensions(){
  if (driverExtensions != null)   return;
  driverExtensions=new HashMap();
  IExtensionRegistry extReg=Platform.getExtensionRegistry();
  IExtensionPoint extPoint=extReg.getExtensionPoint(OdaJdbcDriver.Constants.DRIVER_INFO_EXTENSION);
  IExtension[] exts=extPoint.getExtensions();
  if (exts == null)   return;
  for (int e=0; e < exts.length; e++) {
    IConfigurationElement[] configElems=exts[e].getConfigurationElements();
    if (configElems == null)     continue;
    for (int i=0; i < configElems.length; i++) {
      if (configElems[i].getName().equals(OdaJdbcDriver.Constants.DRIVER_INFO_ELEM_JDBCDRIVER)) {
        String driverClass=configElems[i].getAttribute(OdaJdbcDriver.Constants.DRIVER_INFO_ATTR_DRIVERCLASS);
        String connectionFactory=configElems[i].getAttribute(OdaJdbcDriver.Constants.DRIVER_INFO_ATTR_CONNFACTORY);
        logger.info("String_Node_Str" + driverClass + "String_Node_Str"+ connectionFactory);
        if (driverClass != null && driverClass.length() > 0 && connectionFactory != null && connectionFactory.length() > 0) {
          driverExtensions.put(driverClass,configElems[i]);
        }
      }
    }
  }
}
Program: 79214
Project: 79214
Buggy source:
public Object validateValue(ReportDesign design,PropertyDefn defn,Object value) throws PropertyValueException {
  if (value == null)   return null;
  if (value instanceof String)   return value;
  throw new PropertyValueException(value,PropertyValueException.DESIGN_EXCEPTION_INVALID_VALUE,EXPRESSION_TYPE);
}

Fixed version (ground truth):
public Object validateValue(ReportDesign design,PropertyDefn defn,Object value) throws PropertyValueException {
  if (value == null)   return null;
  if (value instanceof String) {
    if (StringUtil.isEmpty((String)value))     return null;
    return value;
  }
  throw new PropertyValueException(value,PropertyValueException.DESIGN_EXCEPTION_INVALID_VALUE,EXPRESSION_TYPE);
}
Program: 79215
Project: 79215
Buggy source:
/** 
 * Returns a List jdbc Drivers. The Drivers are searched from predefined directories in the DTE plug-in. Currently it is expected that the jdbc drivers are in the "drivers" directory of the DTE oda.jdbc plug-in.
 */
public static ArrayList getJdbcDriverNames(String driverName){
  if (jdbcDriverInfos != null)   return jdbcDriverInfos;
  jdbcDriverInfos=new ArrayList();
  driverNameMap=new HashMap();
  addDriversFromFiles();
  JDBCDriverInformation driverInfos[]=JDBCDriverInfoManager.getDrivers();
  for (int i=0; i < driverInfos.length; i++) {
    JDBCDriverInformation newInfo=driverInfos[i];
    JDBCDriverInformation existing=(JDBCDriverInformation)driverNameMap.get(newInfo.getDriverClassName());
    if (existing == null) {
    }
 else {
      existing.setDisplayName(newInfo.getDisplayName());
      existing.setUrlFormat(newInfo.getUrlFormat());
    }
  }
  Map preferenceMap=JdbcDriverManagerDialog.getPreferenceDriverInfo();
  for (Iterator itr=jdbcDriverInfos.iterator(); itr.hasNext(); ) {
    JDBCDriverInformation info=(JDBCDriverInformation)itr.next();
    Object ob=preferenceMap.get(info.toString());
    if (ob != null) {
      String[] vals=(String[])ob;
      if (vals[1] != null && vals[1].length() > 0) {
        info.setUrlFormat(vals[1]);
      }
    }
  }
  return jdbcDriverInfos;
}

Fixed version (ground truth):
/** 
 * Returns a List jdbc Drivers. The Drivers are searched from predefined directories in the DTE plug-in. Currently it is expected that the jdbc drivers are in the "drivers" directory of the DTE oda.jdbc plug-in.
 */
public static ArrayList getJdbcDriverNames(String driverName){
  if (jdbcDriverInfos != null)   return jdbcDriverInfos;
  jdbcDriverInfos=new ArrayList();
  driverNameMap=new HashMap();
  addDriversFromFiles();
  JDBCDriverInformation driverInfos[]=JDBCDriverInfoManager.getDrivers();
  for (int i=0; i < driverInfos.length; i++) {
    JDBCDriverInformation newInfo=driverInfos[i];
    JDBCDriverInformation existing=(JDBCDriverInformation)driverNameMap.get(newInfo.getDriverClassName());
    if (existing == null) {
      jdbcDriverInfos.add(newInfo);
      driverNameMap.put(newInfo.getDriverClassName(),newInfo);
    }
 else {
      existing.setDisplayName(newInfo.getDisplayName());
      existing.setUrlFormat(newInfo.getUrlFormat());
    }
  }
  Map preferenceMap=JdbcDriverManagerDialog.getPreferenceDriverInfo();
  for (Iterator itr=jdbcDriverInfos.iterator(); itr.hasNext(); ) {
    JDBCDriverInformation info=(JDBCDriverInformation)itr.next();
    Object ob=preferenceMap.get(info.toString());
    if (ob != null) {
      String[] vals=(String[])ob;
      if (vals[1] != null && vals[1].length() > 0) {
        info.setUrlFormat(vals[1]);
      }
    }
  }
  return jdbcDriverInfos;
}
Program: 79216
Project: 79216
Buggy source:
/** 
 * Sets the image uri property. The source type is automatically set in this method. Whether <code>IMAGE_REF_TYPE_FILE</code> or <code>IMAGE_REF_TYPE_URL</code> depends on the uri to set.
 * @param uri the uri to be set.
 * @throws SemanticException if the property is locked.
 */
public void setURI(String uri) throws SemanticException {
  String source=DesignChoiceConstants.IMAGE_REF_TYPE_URL;
  String filePath=URIUtil.getLocalPath(uri);
  if (filePath != null)   source=DesignChoiceConstants.IMAGE_REF_TYPE_FILE;
  try {
    design.getActivityStack().startTrans();
    setProperty(ImageItem.SOURCE_PROP,source);
    setProperty(ImageItem.URI_PROP,uri);
  }
 catch (  SemanticException e) {
    design.getActivityStack().rollback();
    throw e;
  }
  design.getActivityStack().commit();
}

Fixed version (ground truth):
/** 
 * Sets the image uri property. The source type is automatically set in this method. Whether <code>IMAGE_REF_TYPE_FILE</code> or <code>IMAGE_REF_TYPE_URL</code> depends on the uri to set.
 * @param uri the uri to be set.
 * @throws SemanticException if the property is locked.
 */
public void setURI(String uri) throws SemanticException {
  String source=DesignChoiceConstants.IMAGE_REF_TYPE_URL;
  try {
    design.getActivityStack().startTrans();
    setProperty(ImageItem.SOURCE_PROP,source);
    setProperty(ImageItem.URI_PROP,uri);
  }
 catch (  SemanticException e) {
    design.getActivityStack().rollback();
    throw e;
  }
  design.getActivityStack().commit();
}
Program: 79217
Project: 79217
Buggy source:
public void focusLost(FocusEvent e){
  if (e.getSource().equals(cmpDropDown)) {
    if (btnCustom != null && btnCustom.isFocusControl()) {
      return;
    }
    if (btnGradient != null && btnGradient.isFocusControl()) {
      return;
    }
    if (btnImage != null && btnImage.isFocusControl()) {
      return;
    }
    if (srTransparency != null && srTransparency.isEnabled() && srTransparency.isFocusControl()) {
      return;
    }
    cmpDropDown.getShell().dispose();
    return;
  }
}

Fixed version (ground truth):
public void focusLost(FocusEvent e){
  if (e.getSource().equals(cmpDropDown)) {
    Control cTmp=Display.getCurrent().getCursorControl();
    if (cTmp.equals(btnGradient) || cTmp.equals(btnCustom) || cTmp.equals(btnImage)|| cTmp.equals(srTransparency)) {
      return;
    }
    if (btnCustom != null && btnCustom.isFocusControl()) {
      return;
    }
    if (btnGradient != null && btnGradient.isFocusControl()) {
      return;
    }
    if (btnImage != null && btnImage.isFocusControl()) {
      return;
    }
    if (srTransparency != null && srTransparency.isEnabled() && srTransparency.isFocusControl()) {
      return;
    }
    cmpDropDown.getShell().dispose();
    return;
  }
}
Program: 79219
Project: 79219
Buggy source:
protected String getText(){
  TextItemHandle handle=(TextItemHandle)getModel();
  String text=handle.getDisplayContent();
  if (text == null || text.length() == 0) {
    text=FIGURE_DEFAULT_TEXT;
  }
 else {
    if (text.length() > TRUNCATE_LENGTH && DesignChoiceConstants.CONTENT_TYPE_HTML.equals(handle.getContentType())) {
      text=text.substring(0,TRUNCATE_LENGTH - 2) + ELLIPSIS;
    }
  }
  return text;
}

Fixed version (ground truth):
protected String getText(){
  TextItemHandle handle=(TextItemHandle)getModel();
  String text=handle.getDisplayContent();
  if (text == null || text.length() == 0) {
    text=FIGURE_DEFAULT_TEXT;
  }
 else {
    if (text.length() > TRUNCATE_LENGTH && DesignChoiceConstants.TEXT_CONTENT_TYPE_HTML.equals(handle.getContentType())) {
      text=text.substring(0,TRUNCATE_LENGTH - 2) + ELLIPSIS;
    }
  }
  return text;
}
Program: 79222
Project: 79222
Buggy source:
/** 
 * Returns the content type of this text item. The content type will one of the following constants defined in <code>DesignChoiceConstants</code>: <ul> <li><code>CONTENT_TYPE_AUTO</code> <li><code>CONTENT_TYPE_PLAIN</code> <li><code>CONTENT_TYPE_HTML</code> <li><code>CONTENT_TYPE_RTF</code> </ul>
 * @return the content type. if this property value is not set, return<code>null</code>.
 * @see org.eclipse.birt.report.model.api.elements.DesignChoiceConstants
 */
public String getContentType(){
  return getStringProperty(TextItem.CONTENT_TYPE_PROP);
}

Fixed version (ground truth):
/** 
 * Returns the content type of this text item. The content type will one of the following constants defined in <code>DesignChoiceConstants</code>: <ul> <li><code>TEXT_CONTENT_TYPE_AUTO</code> <li><code>TEXT_CONTENT_TYPE_PLAIN</code> <li><code>TEXT_CONTENT_TYPE_HTML</code> <li><code>TEXT_CONTENT_TYPE_RTF</code> </ul>
 * @return the content type. if this property value is not set, return<code>null</code>.
 * @see org.eclipse.birt.report.model.api.elements.DesignChoiceConstants
 */
public String getContentType(){
  return getStringProperty(TextItem.CONTENT_TYPE_PROP);
}
Program: 79223
Project: 79223
Buggy source:
/** 
 * Sets the content type of this text item. The content type will one of the following constants defined in <code>DesignChoiceConstants</code>: <ul> <li><code>CONTENT_TYPE_AUTO</code> <li><code>CONTENT_TYPE_PLAIN</code> <li><code>CONTENT_TYPE_HTML</code> <li><code>CONTENT_TYPE_RTF</code> </ul>
 * @param contentType the content type of this text item.
 * @throws SemanticException if the value is not a valid choice item.
 * @see org.eclipse.birt.report.model.api.elements.DesignChoiceConstants
 */
public void setContentType(String contentType) throws SemanticException {
  setStringProperty(TextItem.CONTENT_TYPE_PROP,contentType);
}

Fixed version (ground truth):
/** 
 * Sets the content type of this text item. The content type will one of the following constants defined in <code>DesignChoiceConstants</code>: <ul> <li><code>TEXT_CONTENT_TYPE_AUTO</code> <li><code>TEXT_CONTENT_TYPE_PLAIN</code> <li><code>TEXT_CONTENT_TYPE_HTML</code> <li><code>TEXT_CONTENT_TYPE_RTF</code> </ul>
 * @param contentType the content type of this text item.
 * @throws SemanticException if the value is not a valid choice item.
 * @see org.eclipse.birt.report.model.api.elements.DesignChoiceConstants
 */
public void setContentType(String contentType) throws SemanticException {
  setStringProperty(TextItem.CONTENT_TYPE_PROP,contentType);
}
Program: 79225
Project: 79225
Buggy source:
/** 
 * Gets color property of style if it differs from that of parent element's style.
 * @param handle The handle of current report element.
 * @param parentHandle The handle of parent report element.
 * @param name The property name.
 * @return the property or null if it is not set.
 */
protected Object getDistinctColorProperty(DesignElementHandle handle,DesignElementHandle parentHandle,String name){
  Object value=handle.getProperty(name);
  int intValue=getColorValue(value);
  String strValue;
  if (intValue == -1) {
    return null;
  }
  if (value instanceof Integer) {
    value=StringUtil.toRgbText(intValue);
  }
  boolean canInherit=StyleDesign.canInherit(name);
  if (canInherit) {
    int parentValue=getColorValue(parentHandle.getProperty(name));
    if (intValue != parentValue) {
      return value;
    }
  }
 else {
    int defaultValue=getColorValue(reportDefaultStyle.get(name));
    if (intValue != defaultValue) {
      return value;
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Gets color property of style if it differs from that of parent element's style.
 * @param handle The handle of current report element.
 * @param parentHandle The handle of parent report element.
 * @param name The property name.
 * @return the property or null if it is not set.
 */
protected Object getDistinctColorProperty(DesignElementHandle handle,DesignElementHandle parentHandle,String name){
  Object value=handle.getProperty(name);
  int intValue=getColorValue(value);
  String strValue;
  if (intValue == -1) {
    return null;
  }
  if (value instanceof Integer) {
    value=StringUtil.toRgbText(intValue);
  }
  boolean canInherit=StyleDesign.canInherit(name);
  if (canInherit) {
    int parentValue;
    if (this.handle == parentHandle) {
      parentValue=getColorValue(reportDefaultStyle.get(name));
    }
 else {
      parentValue=getColorValue(parentHandle.getProperty(name));
    }
    if (intValue != parentValue) {
      return value;
    }
  }
 else {
    int defaultValue=getColorValue(reportDefaultStyle.get(name));
    if (intValue != defaultValue) {
      return value;
    }
  }
  return null;
}
Program: 79226
Project: 79226
Buggy source:
public IResultSetMetaData getMetaData() throws OdaException {
  JDBCConnectionFactory.log(Level.FINE_LEVEL,"String_Node_Str");
  logger.logp(java.util.logging.Level.FINE,Statement.class.getName(),"String_Node_Str","String_Node_Str");
  assertNotNull(preStat);
  java.sql.ResultSetMetaData resultmd=null;
  try {
    resultmd=preStat.getMetaData();
  }
 catch (  NullPointerException e) {
    resultmd=null;
  }
catch (  SQLException e) {
    throw new JDBCException(ResourceConstants.PREPAREDSTATEMENT_METADATA_CANNOT_GET,e);
  }
  IResultSetMetaData pstmtResultMetaData=null;
  if (resultmd != null) {
    pstmtResultMetaData=new ResultSetMetaData(resultmd);
  }
 else {
    IResultSet mdRs=executeQuery();
    if (mdRs != null)     pstmtResultMetaData=mdRs.getMetaData();
  }
  return pstmtResultMetaData;
}

Fixed version (ground truth):
public IResultSetMetaData getMetaData() throws OdaException {
  JDBCConnectionFactory.log(Level.FINE_LEVEL,"String_Node_Str");
  logger.logp(java.util.logging.Level.FINE,Statement.class.getName(),"String_Node_Str","String_Node_Str");
  assertNotNull(preStat);
  java.sql.ResultSetMetaData resultmd=null;
  try {
    resultmd=preStat.getMetaData();
  }
 catch (  NullPointerException e) {
    resultmd=null;
  }
catch (  SQLException e) {
  }
  IResultSetMetaData pstmtResultMetaData=null;
  if (resultmd != null) {
    pstmtResultMetaData=new ResultSetMetaData(resultmd);
  }
 else {
    IResultSet mdRs=executeQuery();
    if (mdRs != null)     pstmtResultMetaData=mdRs.getMetaData();
  }
  return pstmtResultMetaData;
}
Program: 79227
Project: 79227
Buggy source:
public static Object convert(Object source,int toType) throws BirtException {
switch (toType) {
case DataType.INTEGER_TYPE:
    return toInteger(source);
case DataType.DECIMAL_TYPE:
  return toBigDecimal(source);
case DataType.BOOLEAN_TYPE:
return toBoolean(source);
case DataType.DATE_TYPE:
return toDate(source);
case DataType.DOUBLE_TYPE:
return toDouble(source);
case DataType.STRING_TYPE:
return toString(source);
case DataType.BLOB_TYPE:
return toBlob(source);
default :
throw new BirtException(ResourceConstants.INVALID_TYPE,resourceBundle);
}
}

Fixed version (ground truth):
public static Object convert(Object source,Class toTypeClass) throws BirtException {
  if (toTypeClass == Integer.class)   return toInteger(source);
  if (toTypeClass == BigDecimal.class)   return toBigDecimal(source);
  if (toTypeClass == Boolean.class)   return toBoolean(source);
  if (toTypeClass == Date.class)   return toDate(source);
  if (toTypeClass == Double.class)   return toDouble(source);
  if (toTypeClass == String.class)   return toString(source);
  if (toTypeClass == Blob.class)   return toBlob(source);
  throw new BirtException(ResourceConstants.INVALID_TYPE,resourceBundle);
}
Program: 79230
Project: 79230
Buggy source:
/** 
 * Gets color property of style if it differs from that of parent element's style.
 * @param handle The handle of current report element.
 * @param parentHandle The handle of parent report element.
 * @param name The property name.
 * @return the property or null if it is not set.
 */
protected Object getDistinctColorProperty(DesignElementHandle handle,DesignElementHandle parentHandle,String name){
  Object value;
  Object parentValue;
  value=handle.getProperty(name);
  parentValue=parentHandle.getProperty(name);
  boolean canInherit=StyleDesign.canInherit(name);
  int intValue=getColorValue(value);
  int intContainerValue=getColorValue(parentValue);
  if (value != null && (canInherit || intValue != intContainerValue) && (canInherit || !value.equals(StyleDesign.getDefaultValue(name)))) {
    if (value instanceof Integer) {
      return StringUtil.toRgbText(intValue);
    }
    return value;
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Gets color property of style if it differs from that of parent element's style.
 * @param handle The handle of current report element.
 * @param parentHandle The handle of parent report element.
 * @param name The property name.
 * @return the property or null if it is not set.
 */
protected Object getDistinctColorProperty(DesignElementHandle handle,DesignElementHandle parentHandle,String name){
  Object value;
  Object parentValue;
  value=handle.getProperty(name);
  parentValue=parentHandle.getProperty(name);
  boolean canInherit=StyleDesign.canInherit(name);
  int intValue=getColorValue(value);
  if (value != null && (!canInherit || intValue != getColorValue(parentValue)) && (canInherit || intValue != getColorValue(StyleDesign.getDefaultValue(name)))) {
    if (value instanceof Integer) {
      return StringUtil.toRgbText(intValue);
    }
    return value;
  }
  return null;
}
Program: 79231
Project: 79231
Buggy source:
/** 
 * Pastes a report item to the slot. The item must be newly created and not yet added to the design.
 * @param content the newly created element
 * @param newPos the position index at which the content to be inserted.
 * @return a list containing all errors for the pasted element
 * @throws ContentException if the element is not allowed in the slot
 * @throws NameException if the element has a duplicate or illegal name
 */
public List paste(DesignElementHandle content,int newPos) throws ContentException, NameException {
  add(content,newPos);
  return checkPostPasteErrors(content.getElement());
}

Fixed version (ground truth):
/** 
 * Pastes a report item to the slot. The item must be newly created and not yet added to the design.
 * @param content the newly created element
 * @param newPos the position index at which the content to be inserted.
 * @return a list containing all errors for the pasted element
 * @throws ContentException if the element is not allowed in the slot
 * @throws NameException if the element has a duplicate or illegal name
 */
public List paste(IDesignElement content,int newPos) throws ContentException, NameException {
  add(content.getHandle(getDesign()),newPos);
  return checkPostPasteErrors((DesignElement)content);
}
Program: 79233
Project: 79233
Buggy source:
/** 
 * Makes a clone of this namespace.
 * @return Object the cloned namespace.
 * @see java.lang.Object#clone()
 */
public Object clone() throws CloneNotSupportedException {
  NameSpace ns=(NameSpace)super.clone();
  ns.names=new HashMap();
  Iterator it=names.keySet().iterator();
  while (it.hasNext()) {
    Object key=it.next();
    ns.names.put(key,names.get(key));
  }
  return ns;
}

Fixed version (ground truth):
public Object clone() throws CloneNotSupportedException {
  NameSpace ns=(NameSpace)super.clone();
  ns.names=new HashMap();
  return ns;
}
Program: 79234
Project: 79234
Buggy source:
/** 
 * Makes a clone of this root element. The error list, file name are set to empty. A new ID map was generated for the new cloned element.
 * @return Object the cloned report design element.
 * @see java.lang.Object#clone()
 */
public Object clone() throws CloneNotSupportedException {
  ReportDesign design=(ReportDesign)super.clone();
  design.allErrors=new ArrayList();
  design.initSlots();
  for (int i=0; i < slots.length; i++) {
    design.slots[i]=slots[i].copy(design,i);
  }
  design.translations=(TranslationTable)translations.clone();
  design.fileName=null;
  if (MetaDataDictionary.getInstance().useID()) {
    design.idMap=new HashMap();
    generateIdMap(design,design);
  }
  return design;
}

Fixed version (ground truth):
/** 
 * Makes a clone of this root element. The error list, file name are set to empty. A new ID map was generated for the new cloned element.
 * @return Object the cloned report design element.
 * @see java.lang.Object#clone()
 */
public Object clone() throws CloneNotSupportedException {
  ReportDesign design=(ReportDesign)super.clone();
  design.allErrors=new ArrayList();
  design.initSlots();
  for (int i=0; i < slots.length; i++) {
    design.slots[i]=slots[i].copy(design,i);
  }
  design.translations=(TranslationTable)translations.clone();
  design.fileName=null;
  NameSpace.rebuildNamespace(design);
  return design;
}
Program: 79235
Project: 79235
Buggy source:
/** 
 * Checks whether <code>filePath</code> is a valid file on the disk. <code>filePath</code> can follow these scheme. <ul> <li>./../hello/ <li>C:\\hello\..\ <li>/C:/../hello/. </ul>
 * @param filePath the input filePath
 * @return true if filePath exists on the disk. Otherwise false.
 */
private static boolean isFileProtocol(String filePath){
  File file=new File(filePath);
  if (file.toURI().getScheme().equalsIgnoreCase("String_Node_Str")) {
    return true;
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Checks whether <code>filePath</code> is a valid file on the disk. <code>filePath</code> can follow these scheme. <ul> <li>./../hello/ <li>C:\\hello\..\ <li>/C:/../hello/. </ul>
 * @param filePath the input filePath
 * @return true if filePath exists on the disk. Otherwise false.
 */
private static boolean isFileProtocol(String filePath){
  File file=new File(filePath);
  if (file.toURI().getScheme().equalsIgnoreCase(FILE_SCHEMA)) {
    return true;
  }
  return false;
}
Program: 79236
Project: 79236
Buggy source:
/** 
 * Checks <code>uri</code> is file path. If <code>uri</code> is an absolute uri and refers to a file, removes "file://" and returns the file path. If <code>uri</code> is relative uri and refers to a file, returns the <code>uri</code>. For other cases, returns null.  <p> For examples, following uri are supported: <ul> <li>file://C:/disk/test/data.file <li>/C:/disk/test/data.file <li>/usr/local/disk/test/data.file <li>C:\\disk\\test/data.file <li>C:/disk/test/data.file <li>./test/data.file </ul>
 * @param uri the input uri
 * @return the file path if <code>uri</code> refers to a file. Otherwisenull.
 */
public static String getLocalPath(String uri){
  if (uri == null)   return null;
  URI objURI=null;
  try {
    objURI=new URI(uri);
  }
 catch (  URISyntaxException e) {
    if (isFileProtocol(uri))     return uri;
  }
  if (objURI.getScheme() == null) {
    if (isFileProtocol(uri))     return uri;
  }
 else   if (objURI.getScheme().equalsIgnoreCase("String_Node_Str")) {
    return objURI.getSchemeSpecificPart();
  }
 else {
    if (objURI.getScheme().length() == 1) {
      return uri;
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Checks <code>uri</code> is file path. If <code>uri</code> is an absolute uri and refers to a file, removes "file://" and returns the file path. If <code>uri</code> is relative uri and refers to a file, returns the <code>uri</code>. For other cases, returns null. <p> For examples, following uri are supported: <ul> <li>file://C:/disk/test/data.file <li>/C:/disk/test/data.file <li>/usr/local/disk/test/data.file <li>C:\\disk\\test/data.file <li>C:/disk/test/data.file <li>./test/data.file </ul>
 * @param uri the input uri
 * @return the file path if <code>uri</code> refers to a file. Otherwisenull.
 */
public static String getLocalPath(String uri){
  if (uri == null)   return null;
  URI objURI=null;
  try {
    objURI=new URI(uri);
  }
 catch (  URISyntaxException e) {
    return getLocalFileOfFailedURI(uri);
  }
  if (objURI.getScheme() == null) {
    if (isFileProtocol(uri))     return uri;
  }
 else   if (objURI.getScheme().equalsIgnoreCase(FILE_SCHEMA)) {
    return objURI.getSchemeSpecificPart();
  }
 else {
    if (objURI.getScheme().length() == 1) {
      return uri;
    }
  }
  return null;
}
Program: 79238
Project: 79238
Buggy source:
/** 
 * Creates a new oda data set. The name is required. If the <code>name</code> is null, we will make a unique name for it. The extension name is for the element to find the extension definition. If the extension name is not given, the oda data set will be created as a ROM element.If the extension name is given, the check will be done for the name. Null will be returned if the extension name is not found in the metadata dictionary.
 * @param name the required oda data set name.
 * @param extensionName the element name of the extension
 * @return a handle to oda data set
 */
public OdaDataSetHandle newOdaDataSet(String name,String extensionName){
  if (extensionName != null) {
    MetaDataDictionary dd=MetaDataDictionary.getInstance();
    ExtensionElementDefn extDefn=(ExtensionElementDefn)dd.getExtension(extensionName);
    if (extDefn == null)     return null;
  }
  OdaDataSet element=new OdaDataSet(name);
  design.makeUniqueName(element);
  element.setProperty(OdaDataSource.EXTENSION_NAME_PROP,extensionName);
  return element.handle(design);
}

Fixed version (ground truth):
/** 
 * Creates a new oda data set. The name is required. If the <code>name</code> is null, we will make a unique name for it. The extension name is for the element to find the extension definition. If the extension name is not given, the oda data set will be created as a ROM element.If the extension name is given, the check will be done for the name. Null will be returned if the extension name is not found in the metadata dictionary.
 * @param name the required oda data set name.
 * @param extensionName the element name of the extension
 * @return a handle to oda data set
 */
public OdaDataSetHandle newOdaDataSet(String name,String extensionName){
  if (extensionName != null) {
    MetaDataDictionary dd=MetaDataDictionary.getInstance();
    ExtensionElementDefn extDefn=(ExtensionElementDefn)dd.getExtension(extensionName);
    if (extDefn == null)     return null;
  }
  OdaDataSet element=new OdaDataSet(name);
  design.makeUniqueName(element);
  element.setProperty(OdaDataSet.EXTENSION_NAME_PROP,extensionName);
  return element.handle(design);
}
Program: 79239
Project: 79239
Buggy source:
protected void setIntrinsicProperty(String propName,Object value){
  if (EXTENSION_NAME_PROP.equals(propName)) {
    extensionName=(String)value;
    provider=new PeerExtensibilityProvider(this,extensionName);
  }
 else {
    super.setIntrinsicProperty(propName,value);
  }
}

Fixed version (ground truth):
protected void setIntrinsicProperty(String propName,Object value){
  if (EXTENSION_NAME_PROP.equals(propName)) {
    extensionName=(String)value;
    if (extensionName != null)     provider=new PeerExtensibilityProvider(this,extensionName);
 else     provider=null;
  }
 else {
    super.setIntrinsicProperty(propName,value);
  }
}
Program: 79240
Project: 79240
Buggy source:
protected void setIntrinsicProperty(String propName,Object value){
  if (EXTENSION_NAME_PROP.equals(propName)) {
    extensionName=(String)value;
    provider=new AddOnExtensibilityProvider(this,extensionName);
  }
 else {
    super.setIntrinsicProperty(propName,value);
  }
}

Fixed version (ground truth):
protected void setIntrinsicProperty(String propName,Object value){
  if (EXTENSION_NAME_PROP.equals(propName)) {
    extensionName=(String)value;
    if (extensionName != null)     provider=new AddOnExtensibilityProvider(this,extensionName);
 else     provider=null;
  }
 else {
    super.setIntrinsicProperty(propName,value);
  }
}
Program: 79241
Project: 79241
Buggy source:
protected void setIntrinsicProperty(String propName,Object value){
  if (EXTENSION_NAME_PROP.equals(propName)) {
    extensionName=(String)value;
    provider=new AddOnExtensibilityProvider(this,extensionName);
  }
 else {
    super.setIntrinsicProperty(propName,value);
  }
}

Fixed version (ground truth):
protected void setIntrinsicProperty(String propName,Object value){
  if (EXTENSION_NAME_PROP.equals(propName)) {
    extensionName=(String)value;
    if (extensionName != null)     provider=new AddOnExtensibilityProvider(this,extensionName);
 else     provider=null;
  }
 else {
    super.setIntrinsicProperty(propName,value);
  }
}
Program: 79242
Project: 79242
Buggy source:
public void writeImage(File dest) throws IOException {
  if (source == IImage.INVALID_IMAGE) {
    logger.log(Level.SEVERE,"String_Node_Str",id);
    return;
  }
  InputStream input=null;
  if (in != null) {
    input=in;
  }
 else   if (data != null) {
    input=new ByteArrayInputStream(data);
  }
 else {
    logger.log(Level.SEVERE,"String_Node_Str",id);
  }
  if (!dest.exists()) {
    String parent=new File(dest.getAbsolutePath()).getParent();
    File parentDir=new File(parent);
    if (!parentDir.exists()) {
      parentDir.mkdirs();
    }
    OutputStream output=null;
    try {
      output=new BufferedOutputStream(new FileOutputStream(dest));
      copyStream(input,output);
    }
 catch (    IOException ex) {
      logger.log(Level.SEVERE,ex.getMessage(),ex);
    }
 finally {
      input.close();
      output.close();
    }
  }
}

Fixed version (ground truth):
public void writeImage(File dest) throws IOException {
  if (source == IImage.INVALID_IMAGE) {
    logger.log(Level.SEVERE,"String_Node_Str",id);
    return;
  }
  InputStream input=null;
  if (in != null) {
    input=in;
  }
 else   if (data != null) {
    input=new ByteArrayInputStream(data);
  }
 else {
    logger.log(Level.SEVERE,"String_Node_Str",id);
  }
  if (!dest.exists()) {
    String parent=new File(dest.getAbsolutePath()).getParent();
    File parentDir=new File(parent);
    if (!parentDir.exists()) {
      parentDir.mkdirs();
    }
    OutputStream output=null;
    try {
      output=new BufferedOutputStream(new FileOutputStream(dest));
      copyStream(input,output);
    }
 catch (    IOException ex) {
      logger.log(Level.SEVERE,ex.getMessage(),ex);
    }
 finally {
      if (input != null) {
        input.close();
      }
      if (output != null) {
        output.close();
      }
    }
  }
}
Program: 79243
Project: 79243
Buggy source:
/** 
 * Checks if a given file name contains relative path.
 * @param fileName The file name.
 * @return A <code>boolean</code> value indicating if the file namecontains relative path or not.
 */
public static boolean isRelativePath(String fileName){
  if (fileName == null) {
    return false;
  }
  try {
    URI uri=new URI(fileName);
    return !uri.isAbsolute();
  }
 catch (  URISyntaxException e) {
    File file=new File(fileName);
    return !file.isAbsolute();
  }
}

Fixed version (ground truth):
/** 
 * Checks if a given file name contains relative path.
 * @param fileName The file name.
 * @return A <code>boolean</code> value indicating if the file namecontains relative path or not.
 */
public static boolean isRelativePath(String fileName){
  if (fileName == null || fileName.indexOf(':') > 0 || fileName.startsWith("String_Node_Str")) {
    return false;
  }
  if (File.separatorChar == '/') {
    return !fileName.startsWith(File.separator);
  }
 else   if (File.separatorChar == '\\') {
    File file=new File(fileName);
    return !file.isAbsolute();
  }
  return false;
}
Program: 79244
Project: 79244
Buggy source:
public void writeImage(File dest) throws IOException {
  InputStream input=null;
  if (in != null) {
    input=in;
  }
 else   if (data != null) {
    input=new ByteArrayInputStream(data);
  }
 else {
    logger.log(Level.SEVERE,"String_Node_Str",id);
  }
  if (!dest.exists()) {
    String parent=new File(dest.getAbsolutePath()).getParent();
    File parentDir=new File(parent);
    if (!parentDir.exists()) {
      parentDir.mkdirs();
    }
    OutputStream output=null;
    try {
      output=new BufferedOutputStream(new FileOutputStream(dest));
      copyStream(input,output);
    }
 catch (    IOException ex) {
      logger.log(Level.SEVERE,ex.getMessage(),ex);
    }
 finally {
      input.close();
      output.close();
    }
  }
}

Fixed version (ground truth):
public void writeImage(File dest) throws IOException {
  if (source == IImage.INVALID_IMAGE) {
    logger.log(Level.SEVERE,"String_Node_Str",id);
    return;
  }
  InputStream input=null;
  if (in != null) {
    input=in;
  }
 else   if (data != null) {
    input=new ByteArrayInputStream(data);
  }
 else {
    logger.log(Level.SEVERE,"String_Node_Str",id);
  }
  if (!dest.exists()) {
    String parent=new File(dest.getAbsolutePath()).getParent();
    File parentDir=new File(parent);
    if (!parentDir.exists()) {
      parentDir.mkdirs();
    }
    OutputStream output=null;
    try {
      output=new BufferedOutputStream(new FileOutputStream(dest));
      copyStream(input,output);
    }
 catch (    IOException ex) {
      logger.log(Level.SEVERE,ex.getMessage(),ex);
    }
 finally {
      input.close();
      output.close();
    }
  }
}