nus-yam/ex-repair huggingface dataset:
Program: 77878
Project: 77878
Buggy source:
public void createPageCustomControl(Composite parent){
  setControl(createPageControl(parent));
  initializeControl();
  getControl().setFocus();
  PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(),this.CONEXT_ID_DATASET_JDBC);
}

Fixed version (ground truth):
public void createPageCustomControl(Composite parent){
  setControl(createPageControl(parent));
  initializeControl();
  Utility.setSystemHelp(getControl(),IHelpConstants.CONEXT_ID_DATASET_JDBC);
}
Program: 77881
Project: 77881
Buggy source:
void createCustomControl(Composite parent){
  Composite content=new Composite(parent,SWT.NONE);
  GridLayout layout=new GridLayout();
  layout.numColumns=2;
  content.setLayout(layout);
  new Label(content,SWT.LEFT).setText(Messages.getMessage("String_Node_Str"));
  m_driverClass=new Label(content,SWT.LEFT);
  m_driverClass.setText(SampleDBConstants.DRIVER_CLASS);
  new Label(content,SWT.LEFT).setText(Messages.getMessage("String_Node_Str"));
  m_driverURL=new Label(content,SWT.LEFT);
  m_driverURL.setText(SampleDBConstants.DRIVER_URL);
  new Label(content,SWT.LEFT).setText(Messages.getMessage("String_Node_Str"));
  m_sampleUser=new Label(content,SWT.LEFT);
  m_sampleUser.setText(SampleDBJDBCConnectionFactory.getDbUser());
  setMessage(DEFAULT_MESSAGE);
  content.setFocus();
  PlatformUI.getWorkbench().getHelpSystem().setHelp(content,CONEXT_ID_DATASOURCE_SAMPLEDB);
}

Fixed version (ground truth):
void createCustomControl(Composite parent){
  Composite content=new Composite(parent,SWT.NONE);
  GridLayout layout=new GridLayout();
  layout.numColumns=2;
  content.setLayout(layout);
  new Label(content,SWT.LEFT).setText(Messages.getMessage("String_Node_Str"));
  m_driverClass=new Label(content,SWT.LEFT);
  m_driverClass.setText(SampleDBConstants.DRIVER_CLASS);
  new Label(content,SWT.LEFT).setText(Messages.getMessage("String_Node_Str"));
  m_driverURL=new Label(content,SWT.LEFT);
  m_driverURL.setText(SampleDBConstants.DRIVER_URL);
  new Label(content,SWT.LEFT).setText(Messages.getMessage("String_Node_Str"));
  m_sampleUser=new Label(content,SWT.LEFT);
  m_sampleUser.setText(SampleDBJDBCConnectionFactory.getDbUser());
  setMessage(DEFAULT_MESSAGE);
  PlatformUI.getWorkbench().getHelpSystem().setHelp(content,CONEXT_ID_DATASOURCE_SAMPLEDB);
}
Program: 77882
Project: 77882
Buggy source:
/** 
 * This method returnt <code>true</code> in following condition: <p> 1. The multi selected elements are same type. <p> 2. And the multi selected elements have extends. <p> 3. If any of the given elements has local properties. <p>
 * @return <code>true</code> if the conditions is met.
 */
public final boolean hasLocalPropertiesForExtendedElements(){
  if (!isSameType())   return false;
  if (!isExtendedElements())   return false;
  List elements=getElements();
  for (Iterator iter=elements.iterator(); iter.hasNext(); ) {
    DesignElementHandle elementHandle=(DesignElementHandle)iter.next();
    if (elementHandle.getElement().hasLocalPropertyValues())     return true;
  }
  return false;
}

Fixed version (ground truth):
/** 
 * This method returnt <code>true</code> in following condition: <p> 1. The multi selected elements are same type. <p> 2. And the multi selected elements have extends. <p> 3. If any of the given elements has local properties. <p>
 * @return <code>true</code> if the conditions is met.
 */
public final boolean hasLocalPropertiesForExtendedElements(){
  if (!isSameType())   return false;
  if (!isExtendedElements())   return false;
  List elements=getElements();
  for (Iterator iter=elements.iterator(); iter.hasNext(); ) {
    DesignElementHandle elementHandle=(DesignElementHandle)iter.next();
    Iterator propIter=elementHandle.getPropertyIterator();
    while (propIter.hasNext()) {
      PropertyHandle propertyHandle=(PropertyHandle)propIter.next();
      String name=propertyHandle.getDefn().getName();
      if (IDesignElementModel.EXTENDS_PROP.equals(name))       continue;
      if (elementHandle.getElement().getLocalProperty(elementHandle.getModule(),name) != null)       return true;
    }
  }
  return false;
}
Program: 77883
Project: 77883
Buggy source:
/** 
 * Determines if the design has changed since it was last read from, or written to, the file. The dirty state reflects the action of the command stack. If the user saves the design and then changes it, the design is dirty. If the user then undoes the change, the design is no longer dirty.
 * @return <code>true</code> if the design has changed since the last loador save; <code>false</code> if it has not changed.
 */
public boolean needsSave(){
  List versionInfos=ModelUtil.checkVersion(module.getVersionManager().getVersion());
  if (!versionInfos.isEmpty())   return true;
  return module.isDirty();
}

Fixed version (ground truth):
/** 
 * Determines if the design has changed since it was last read from, or written to, the file. The dirty state reflects the action of the command stack. If the user saves the design and then changes it, the design is dirty. If the user then undoes the change, the design is no longer dirty.
 * @return <code>true</code> if the design has changed since the last loador save; <code>false</code> if it has not changed.
 */
public boolean needsSave(){
  String version=module.getVersionManager().getVersion();
  if (version != null) {
    List versionInfos=ModelUtil.checkVersion(version);
    if (!versionInfos.isEmpty())     return true;
  }
  return module.isDirty();
}
Program: 77884
Project: 77884
Buggy source:
/** 
 * Validates the input value at the given locale. The format is: short date and medium time.
 * @param value the value to validate
 * @param locale the locale information
 * @return the date value if validation is successful
 * @throws ValidationValueException if the value is invalid
 */
static final Date doVidateDateTime(String value,ULocale locale) throws ValidationValueException {
  DateFormat formatter=DateFormat.getDateTimeInstance(DateFormat.MEDIUM,DateFormat.MEDIUM,locale);
  try {
    return formatter.parse(value);
  }
 catch (  ParseException e) {
    throw new ValidationValueException(value,PropertyValueException.DESIGN_EXCEPTION_INVALID_VALUE,DesignChoiceConstants.PARAM_TYPE_DATETIME);
  }
}

Fixed version (ground truth):
/** 
 * Validates the input value at the given locale. The format is: short date and medium time.
 * @param value the value to validate
 * @param locale the locale information
 * @return the date value if validation is successful
 * @throws ValidationValueException if the value is invalid
 */
static final Date doVidateDateTime(String value,ULocale locale) throws ValidationValueException {
  try {
    return DataTypeUtil.toDate(value,locale);
  }
 catch (  BirtException e) {
    throw new ValidationValueException(value,PropertyValueException.DESIGN_EXCEPTION_INVALID_VALUE,DesignChoiceConstants.PARAM_TYPE_DATETIME);
  }
}
Program: 77885
Project: 77885
Buggy source:
/** 
 * Get vector from the list.
 * @param list
 * @return
 */
private SelectItemChoice[] getVectorFromList(List list){
  SelectItemChoice[] selectionList=new SelectItemChoice[list.size()];
  for (int i=0; i < list.size(); i++) {
    SelectItemChoice item=(SelectItemChoice)list.get(i);
    selectionList[i]=new SelectItemChoice(item.getValue(),item.getLabel());
  }
  return selectionList;
}

Fixed version (ground truth):
/** 
 * Get vector from the list.
 * @param list
 * @return
 */
private SelectItemChoice[] getVectorFromList(List list){
  SelectItemChoice[] selectionList=new SelectItemChoice[list.size()];
  for (int i=0; i < list.size(); i++) {
    SelectItemChoice item=(SelectItemChoice)list.get(i);
    String label=item.getLabel();
    String value=item.getValue();
    if (value == null)     continue;
    if (label == null)     label=value;
    selectionList[i]=new SelectItemChoice(value,label);
  }
  return selectionList;
}
Program: 77886
Project: 77886
Buggy source:
/** 
 * If miss parameter.
 * @return boolean
 */
public boolean isMissingParameter(){
  boolean missingParameter=false;
  ModuleHandle model=SessionHandleAdapter.getInstance().getReportDesignHandle();
  HashMap params=(HashMap)this.getConfigVars();
  List parameters=model.getFlattenParameters();
  if (parameters != null) {
    for (int i=0; i < parameters.size(); i++) {
      if (parameters.get(i) instanceof ScalarParameterHandle) {
        ScalarParameterHandle parameter=((ScalarParameterHandle)parameters.get(i));
        if (parameter.isHidden()) {
          continue;
        }
        String paramValue=null;
        if (params != null && params.containsKey(parameter.getName())) {
          Object curVal=params.get(parameter.getName());
          if (curVal != null)           paramValue=curVal.toString();
        }
 else {
          paramValue=parameter.getDefaultValue();
        }
        if (paramValue == null && !parameter.allowNull()) {
          missingParameter=true;
          break;
        }
        if (paramValue != null && paramValue.trim().length() <= 0 && !parameter.allowBlank() && parameter.getDataType().equalsIgnoreCase(DesignChoiceConstants.PARAM_TYPE_STRING)) {
          missingParameter=true;
          break;
        }
      }
    }
  }
  return missingParameter;
}

Fixed version (ground truth):
/** 
 * If miss parameter.
 * @return boolean
 */
public boolean isMissingParameter(){
  boolean missingParameter=false;
  ModuleHandle model=SessionHandleAdapter.getInstance().getReportDesignHandle();
  HashMap params=(HashMap)this.getConfigVars();
  List parameters=model.getFlattenParameters();
  if (parameters != null) {
    for (int i=0; i < parameters.size(); i++) {
      if (parameters.get(i) instanceof ScalarParameterHandle) {
        ScalarParameterHandle parameter=((ScalarParameterHandle)parameters.get(i));
        if (parameter.isHidden()) {
          continue;
        }
        String paramValue=null;
        if (params != null && params.containsKey(parameter.getName())) {
          Object curVal=params.get(parameter.getName());
          if (curVal != null)           paramValue=curVal.toString();
        }
        if (paramValue == null && !parameter.allowNull()) {
          missingParameter=true;
          break;
        }
        if (paramValue != null && paramValue.trim().length() <= 0 && !parameter.allowBlank() && parameter.getDataType().equalsIgnoreCase(DesignChoiceConstants.PARAM_TYPE_STRING)) {
          missingParameter=true;
          break;
        }
      }
    }
  }
  return missingParameter;
}
Program: 77887
Project: 77887
Buggy source:
/** 
 * @param ob1
 * @param ob2
 * @return
 */
public static int compareObjects(Object ob1,Object ob2){
  int result=0;
  if (ob1 == ob2) {
    return result;
  }
  if (ob1 == null || ob2 == null) {
    if (ob1 == null) {
      result=-1;
    }
 else {
      result=1;
    }
    return result;
  }
  if (ob1.equals(ob2)) {
    return result;
  }
 else   if (ob1 instanceof Comparable && ob1 instanceof Comparable) {
    Comparable comp1=(Comparable)ob1;
    Comparable comp2=(Comparable)ob2;
    if (ob1.getClass() != ob2.getClass() && ob1 instanceof Number && ob1 instanceof Number) {
      try {
        comp1=(Comparable)DataTypeUtil.toDouble(ob1);
        comp2=(Comparable)DataTypeUtil.toDouble(ob2);
      }
 catch (      BirtException ex) {
      }
    }
    result=comp1.compareTo(comp2);
  }
 else   if (ob1 instanceof Boolean && ob2 instanceof Boolean) {
    Boolean bool=(Boolean)ob1;
    if (bool.equals(Boolean.TRUE))     result=1;
 else     result=-1;
  }
 else {
  }
  return result;
}

Fixed version (ground truth):
/** 
 * @param ob1
 * @param ob2
 * @return
 */
public static int compareObjects(Object ob1,Object ob2){
  int result=0;
  if (ob1 == ob2) {
    return result;
  }
  if (ob1 == null || ob2 == null) {
    if (ob1 == null) {
      result=-1;
    }
 else {
      result=1;
    }
    return result;
  }
  if (ob1.equals(ob2)) {
    return result;
  }
 else   if (ob1 instanceof Comparable && ob2 instanceof Comparable) {
    Comparable comp1=(Comparable)ob1;
    Comparable comp2=(Comparable)ob2;
    if (ob1.getClass() != ob2.getClass() && ob1 instanceof Number && ob2 instanceof Number) {
      try {
        comp1=(Comparable)DataTypeUtil.toDouble(ob1);
        comp2=(Comparable)DataTypeUtil.toDouble(ob2);
      }
 catch (      BirtException ex) {
      }
    }
    result=comp1.compareTo(comp2);
  }
 else   if (ob1 instanceof Boolean && ob2 instanceof Boolean) {
    Boolean bool=(Boolean)ob1;
    if (bool.equals(Boolean.TRUE))     result=1;
 else     result=-1;
  }
 else {
  }
  return result;
}
Program: 77888
Project: 77888
Buggy source:
private int compareTwoValues(Object obj1,Object obj2){
  if (obj1 == null || obj2 == null) {
    if (obj1 == null && obj2 != null)     return -1;
 else     if (obj1 != null && obj2 == null)     return 1;
 else     return 0;
  }
  if (obj1 instanceof Boolean) {
    if (obj1.equals(obj2))     return 0;
    Boolean bool=(Boolean)obj1;
    if (bool.equals(Boolean.TRUE))     return 1;
 else     return -1;
  }
 else   if (obj1 instanceof Comparable) {
    return ((Comparable)obj1).compareTo(obj2);
  }
 else {
    return obj1.toString().compareTo(obj2.toString());
  }
}

Fixed version (ground truth):
private int compareTwoValues(Object obj1,Object obj2){
  if (obj1 == null || obj2 == null) {
    if (obj1 == null && obj2 != null)     return -1;
 else     if (obj1 != null && obj2 == null)     return 1;
 else     return 0;
  }
  if (obj1 instanceof Boolean) {
    if (obj1.equals(obj2))     return 0;
    Boolean bool=(Boolean)obj1;
    if (bool.equals(Boolean.TRUE))     return 1;
 else     return -1;
  }
 else   if (obj1 instanceof Comparable) {
    Comparable comp1=(Comparable)obj1;
    Comparable comp2=(Comparable)obj2;
    if (obj1.getClass() != obj2.getClass() && obj1 instanceof Number && obj2 instanceof Number) {
      try {
        comp1=(Comparable)DataTypeUtil.toDouble(obj1);
        comp2=(Comparable)DataTypeUtil.toDouble(obj2);
      }
 catch (      BirtException ex) {
      }
    }
    return comp1.compareTo(comp2);
  }
 else {
    return obj1.toString().compareTo(obj2.toString());
  }
}
Program: 77889
Project: 77889
Buggy source:
protected void __initParameters(HttpServletRequest request) throws Exception {
  this.reportDesignHandle=getDesignHandle(request);
  InputOptions options=new InputOptions();
  options.setOption(InputOptions.OPT_REQUEST,request);
  options.setOption(InputOptions.OPT_LOCALE,locale);
  options.setOption(InputOptions.OPT_RTL,new Boolean(rtl));
  Collection parameterList=getParameterList();
  if (this.isDesigner && !IBirtConstants.SERVLET_PATH_FRAMESET.equalsIgnoreCase(request.getServletPath()))   parseConfigVars(request,parameterList);
  this.parametersAsString=getParsedParametersAsString(parameterList,request,options);
  this.parameters=(HashMap)getParsedParameters(this.reportDesignHandle,parameterList,request,options);
  Collection parameterDefList=getReportService().getParameterDefinitions(this.reportDesignHandle,options,false);
  this.missingParameter=validateParameters(parameterDefList,this.parametersAsString);
}

Fixed version (ground truth):
protected void __initParameters(HttpServletRequest request) throws Exception {
  this.reportDesignHandle=getDesignHandle(request);
  InputOptions options=new InputOptions();
  options.setOption(InputOptions.OPT_REQUEST,request);
  options.setOption(InputOptions.OPT_LOCALE,locale);
  options.setOption(InputOptions.OPT_RTL,new Boolean(rtl));
  Collection parameterList=getParameterList();
  if (this.isDesigner && !IBirtConstants.SERVLET_PATH_FRAMESET.equalsIgnoreCase(request.getServletPath()))   parseConfigVars(request,parameterList);
  this.parametersAsString=getParsedParametersAsString(parameterList,request,options);
  Collection parameterDefList=getReportService().getParameterDefinitions(this.reportDesignHandle,options,false);
  this.missingParameter=validateParameters(parameterDefList,this.parametersAsString);
  this.parametersAsString=getParsedParametersAsStringWithDefaultValue(this.parametersAsString,request,options);
  this.parameters=(HashMap)getParsedParameters(this.reportDesignHandle,parameterList,request,options);
}
Program: 77890
Project: 77890
Buggy source:
/** 
 * get parsed parameters as string.
 * @param parameterList Collection
 * @param request HttpServletRequest
 * @param options InputOptions
 * @return Map
 */
protected Map getParsedParametersAsString(Collection parameterList,HttpServletRequest request,InputOptions options) throws ReportServiceException {
  Map params=new HashMap();
  if (parameterList == null)   return params;
  for (Iterator iter=parameterList.iterator(); iter.hasNext(); ) {
    ScalarParameterHandle parameter=null;
    Object parameterObj=iter.next();
    if (parameterObj instanceof ScalarParameterHandle) {
      parameter=(ScalarParameterHandle)parameterObj;
    }
    if (parameter == null)     continue;
    String paramName=parameter.getName();
    String paramValue=getParamValueAsString(request,parameter);
    if (paramValue == null && !ParameterAccessor.isReportParameterExist(request,paramName) && (IBirtConstants.SERVLET_PATH_FRAMESET.equalsIgnoreCase(request.getServletPath()) || (this.configMap != null && !this.configMap.containsKey(paramName)))) {
      paramValue=this.getParameterDefaultValues(reportDesignHandle,paramName,options);
    }
    if (paramName != null)     params.put(paramName,paramValue);
  }
  return params;
}

Fixed version (ground truth):
/** 
 * get parsed parameters as string.
 * @param parameterList Collection
 * @param request HttpServletRequest
 * @param options InputOptions
 * @return Map
 */
protected Map getParsedParametersAsString(Collection parameterList,HttpServletRequest request,InputOptions options) throws ReportServiceException {
  Map params=new HashMap();
  if (parameterList == null)   return params;
  for (Iterator iter=parameterList.iterator(); iter.hasNext(); ) {
    ScalarParameterHandle parameter=null;
    Object parameterObj=iter.next();
    if (parameterObj instanceof ScalarParameterHandle) {
      parameter=(ScalarParameterHandle)parameterObj;
    }
    if (parameter == null)     continue;
    String paramName=parameter.getName();
    String paramValue=getParamValueAsString(request,parameter);
    if (paramName != null)     params.put(paramName,paramValue);
  }
  return params;
}
Program: 77891
Project: 77891
Buggy source:
/** 
 * Get report locale from a given string.
 * @param locale locale string
 * @return report locale
 */
public static Locale getLocaleFromString(String locale){
  if (locale == null || locale.length() <= 0) {
    return Locale.getDefault();
  }
  int index=locale.indexOf('_');
  if (index != -1) {
    String language=locale.substring(0,index);
    String country=locale.substring(index + 1);
    return new Locale(language,country);
  }
  return new Locale(locale);
}

Fixed version (ground truth):
/** 
 * Get report locale from a given string.
 * @param locale locale string
 * @return report locale
 */
public static Locale getLocaleFromString(String locale){
  if (locale == null || locale.length() <= 0) {
    return null;
  }
  int index=locale.indexOf('_');
  if (index != -1) {
    String language=locale.substring(0,index);
    String country=locale.substring(index + 1);
    return new Locale(language,country);
  }
  return new Locale(locale);
}
Program: 77892
Project: 77892
Buggy source:
/** 
 * Initial the parameters class. Web.xml is in UTF-8 format. No need to do encoding convertion.
 * @param config Servlet configuration
 */
public synchronized static void initParameters(ServletConfig config){
  ServletContext context=config.getServletContext();
  workingFolder=context.getInitParameter(INIT_PARAM_REPORT_DIR);
  if (workingFolder == null || workingFolder.trim().length() <= 0) {
    workingFolder=context.getRealPath("String_Node_Str");
  }
  if (workingFolder != null && workingFolder.trim().endsWith(File.separator)) {
    workingFolder=workingFolder.trim().substring(0,workingFolder.trim().length() - 1);
  }
  webAppLocale=getLocaleFromString(context.getInitParameter(INIT_PARAM_LOCALE));
  isWorkingFolderAccessOnly=Boolean.valueOf(context.getInitParameter(INIT_PARAM_WORKING_FOLDER_ACCESS_ONLY)).booleanValue();
  String s_maxRows=context.getInitParameter(INIT_PARAM_VIEWER_MAXROWS);
  try {
    maxRows=Integer.valueOf(s_maxRows).intValue();
  }
 catch (  NumberFormatException e) {
    maxRows=-1;
  }
  clearDocuments();
}

Fixed version (ground truth):
/** 
 * Initial the parameters class. Web.xml is in UTF-8 format. No need to do encoding convertion.
 * @param config Servlet configuration
 */
public synchronized static void initParameters(ServletConfig config){
  ServletContext context=config.getServletContext();
  workingFolder=context.getInitParameter(INIT_PARAM_REPORT_DIR);
  if (workingFolder == null || workingFolder.trim().length() <= 0) {
    workingFolder=context.getRealPath("String_Node_Str");
  }
  if (workingFolder != null && workingFolder.trim().endsWith(File.separator)) {
    workingFolder=workingFolder.trim().substring(0,workingFolder.trim().length() - 1);
  }
  webAppLocale=getLocaleFromString(context.getInitParameter(INIT_PARAM_LOCALE));
  if (webAppLocale == null)   webAppLocale=Locale.getDefault();
  isWorkingFolderAccessOnly=Boolean.valueOf(context.getInitParameter(INIT_PARAM_WORKING_FOLDER_ACCESS_ONLY)).booleanValue();
  String s_maxRows=context.getInitParameter(INIT_PARAM_VIEWER_MAXROWS);
  try {
    maxRows=Integer.valueOf(s_maxRows).intValue();
  }
 catch (  NumberFormatException e) {
    maxRows=-1;
  }
  clearDocuments();
}
Program: 77893
Project: 77893
Buggy source:
/** 
 * Get report locale from Http request.
 * @param request http request
 * @return report locale
 */
public static Locale getLocale(HttpServletRequest request){
  return getLocaleFromString(getParameter(request,PARAM_LOCALE));
}

Fixed version (ground truth):
/** 
 * Get report locale from Http request.
 * @param request http request
 * @return report locale
 */
public static Locale getLocale(HttpServletRequest request){
  Locale locale=null;
  locale=getLocaleFromString(getParameter(request,PARAM_LOCALE));
  if (locale == null)   locale=request.getLocale();
  if (locale == null)   locale=webAppLocale;
  return locale;
}
Program: 77894
Project: 77894
Buggy source:
/** 
 * @return
 * @throws DataException
 */
private boolean hasOutputParams() throws DataException {
  Collection collection=getParameterMetaData();
  boolean hasOutputParam=false;
  if (collection != null) {
    Iterator it=collection.iterator();
    while (it.hasNext()) {
      IParameterMetaData metaData=(IParameterMetaData)it.next();
      if (metaData.isOutputMode().booleanValue()) {
        hasOutputParam=true;
        break;
      }
    }
  }
  return hasOutputParam;
}

Fixed version (ground truth):
/** 
 * @return
 * @throws DataException
 */
private boolean hasOutputParams(){
  Collection collection=null;
  try {
    collection=getParameterMetaData();
  }
 catch (  DataException e) {
    return false;
  }
  boolean hasOutputParam=false;
  if (collection != null) {
    Iterator it=collection.iterator();
    while (it.hasNext()) {
      IParameterMetaData metaData=(IParameterMetaData)it.next();
      if (metaData.isOutputMode().booleanValue()) {
        hasOutputParam=true;
        break;
      }
    }
  }
  return hasOutputParam;
}
Program: 77896
Project: 77896
Buggy source:
/** 
 * Constructor of KeyHandler
 * @param viewer
 * @param actionRegistry
 */
public ReportViewerKeyHandler(GraphicalViewer viewer,ActionRegistry actionRegistry){
  super(viewer);
  this.actionRegistry=actionRegistry;
  put(KeyStroke.getPressed(SWT.F2,0),actionRegistry.getAction(GEFActionConstants.DIRECT_EDIT));
  tableDelgate=new TableCellKeyDelegate(viewer);
}

Fixed version (ground truth):
/** 
 * Constructor of KeyHandler
 * @param viewer
 * @param actionRegistry
 */
public ReportViewerKeyHandler(GraphicalViewer viewer,ActionRegistry actionRegistry){
  super(viewer);
  this.actionRegistry=actionRegistry;
  put(KeyStroke.getPressed(SWT.F2,0),actionRegistry.getAction(GEFActionConstants.DIRECT_EDIT));
  tableDelgate=new TableCellKeyDelegate(viewer,actionRegistry);
}
Program: 77897
Project: 77897
Buggy source:
/** 
 * Default Constuctor.
 */
public TableCellKeyDelegate(GraphicalViewer viewer){
  super(viewer);
}

Fixed version (ground truth):
/** 
 * Default Constuctor.
 */
public TableCellKeyDelegate(GraphicalViewer viewer,ActionRegistry actionRegistry){
  super(viewer);
  this.actionRegistry=actionRegistry;
  put(KeyStroke.getPressed('r',114,SWT.ALT | SWT.SHIFT),actionRegistry.getAction(SelectRowAction.ID));
  put(KeyStroke.getPressed('R',114,SWT.ALT | SWT.SHIFT),actionRegistry.getAction(SelectRowAction.ID));
  put(KeyStroke.getPressed('c',99,SWT.ALT | SWT.SHIFT),actionRegistry.getAction(SelectColumnAction.ID));
  put(KeyStroke.getPressed('C',99,SWT.ALT | SWT.SHIFT),actionRegistry.getAction(SelectColumnAction.ID));
}
Program: 77898
Project: 77898
Buggy source:
/** 
 * Get vector from the list.
 * @param list
 * @return
 */
private SelectItemChoice[] getVectorFromList(List list){
  SelectItemChoice[] selectionList=new SelectItemChoice[list.size()];
  for (int i=0; i < list.size(); i++) {
    selectionList[i].setValue((String)list.get(i));
  }
  return selectionList;
}

Fixed version (ground truth):
/** 
 * Get vector from the list.
 * @param list
 * @return
 */
private SelectItemChoice[] getVectorFromList(List list){
  SelectItemChoice[] selectionList=new SelectItemChoice[list.size()];
  for (int i=0; i < list.size(); i++) {
    SelectItemChoice item=(SelectItemChoice)list.get(i);
    selectionList[i]=new SelectItemChoice(item.getValue(),item.getLabel());
  }
  return selectionList;
}
Program: 77899
Project: 77899
Buggy source:
private List doQueryCascadeParameterSelectionList(IViewerReportDesignHandle design,String groupName,Object[] groupKeys,InputOptions options) throws RemoteException, ReportServiceException {
  List selectionList=new ArrayList();
  Collection list=getReportService().getSelectionListForCascadingGroup(design,groupName,groupKeys,options);
  if (list != null && list.size() > 0) {
    Iterator iList=list.iterator();
    int index=0;
    while (iList != null && iList.hasNext()) {
      ParameterSelectionChoice item=(ParameterSelectionChoice)iList.next();
      if (item != null && item.getValue() != null) {
        try {
          selectionList.add(index++,(String)DataTypeUtil.convert(item.getValue(),DataType.STRING_TYPE));
        }
 catch (        BirtException e) {
          throw new ReportServiceException(e.getLocalizedMessage());
        }
      }
    }
  }
  return selectionList;
}

Fixed version (ground truth):
private List doQueryCascadeParameterSelectionList(IViewerReportDesignHandle design,String groupName,Object[] groupKeys,InputOptions options) throws RemoteException, ReportServiceException {
  List selectionList=new ArrayList();
  Collection list=getReportService().getSelectionListForCascadingGroup(design,groupName,groupKeys,options);
  if (list != null && list.size() > 0) {
    Iterator iList=list.iterator();
    int index=0;
    while (iList != null && iList.hasNext()) {
      ParameterSelectionChoice item=(ParameterSelectionChoice)iList.next();
      if (item != null && item.getValue() != null) {
        try {
          SelectItemChoice selectItemChoice=new SelectItemChoice();
          selectItemChoice.setLabel(item.getLabel());
          selectItemChoice.setValue((String)DataTypeUtil.convert(item.getValue(),DataType.STRING_TYPE));
          selectionList.add(index++,selectItemChoice);
        }
 catch (        BirtException e) {
          throw new ReportServiceException(e.getLocalizedMessage());
        }
      }
    }
  }
  return selectionList;
}
Program: 77902
Project: 77902
Buggy source:
protected Control createContents(Composite parent){
  ChartUIUtil.bindHelp(parent,ChartHelpContextIds.PREFERENCE_CHART);
  Composite cmpTop=new Composite(parent,SWT.NONE);
{
    GridLayout layout=new GridLayout(2,false);
    cmpTop.setLayout(layout);
  }
  btnEnableLivePreview=new Button(cmpTop,SWT.CHECK);
{
    GridData gd=new GridData();
    gd.horizontalSpan=2;
    btnEnableLivePreview.setLayoutData(gd);
    btnEnableLivePreview.setText(Messages.getString("String_Node_Str"));
    btnEnableLivePreview.setSelection(ChartReportItemUIActivator.getDefault().getPluginPreferences().getBoolean(ChartReportItemUIActivator.PREFERENCE_ENALBE_LIVE));
  }
  txtMaxRow=new IntegerFieldEditor(ChartReportItemUIActivator.PREFERENCE_MAX_ROW,Messages.getString("String_Node_Str"),cmpTop);
{
    txtMaxRow.setErrorMessage(Messages.getString("String_Node_Str",new Object[]{new Integer(MAX_ROW_LIMIT)}));
    txtMaxRow.setValidateStrategy(StringFieldEditor.VALIDATE_ON_KEY_STROKE);
    txtMaxRow.setValidRange(1,MAX_ROW_LIMIT);
    txtMaxRow.setEmptyStringAllowed(false);
    txtMaxRow.setStringValue(ChartReportItemUIActivator.getDefault().getPluginPreferences().getString(ChartReportItemUIActivator.PREFERENCE_MAX_ROW));
    txtMaxRow.setPage(this);
    txtMaxRow.setPropertyChangeListener(this);
  }
  return cmpTop;
}

Fixed version (ground truth):
protected Control createContents(Composite parent){
  PlatformUI.getWorkbench().getHelpSystem().setHelp(parent,ChartHelpContextIds.PREFERENCE_CHART);
  Composite cmpTop=new Composite(parent,SWT.NONE);
{
    GridLayout layout=new GridLayout(2,false);
    cmpTop.setLayout(layout);
  }
  btnEnableLivePreview=new Button(cmpTop,SWT.CHECK);
{
    GridData gd=new GridData();
    gd.horizontalSpan=2;
    btnEnableLivePreview.setLayoutData(gd);
    btnEnableLivePreview.setText(Messages.getString("String_Node_Str"));
    btnEnableLivePreview.setSelection(ChartReportItemUIActivator.getDefault().getPluginPreferences().getBoolean(ChartReportItemUIActivator.PREFERENCE_ENALBE_LIVE));
  }
  txtMaxRow=new IntegerFieldEditor(ChartReportItemUIActivator.PREFERENCE_MAX_ROW,Messages.getString("String_Node_Str"),cmpTop);
{
    txtMaxRow.setErrorMessage(Messages.getString("String_Node_Str",new Object[]{new Integer(MAX_ROW_LIMIT)}));
    txtMaxRow.setValidateStrategy(StringFieldEditor.VALIDATE_ON_KEY_STROKE);
    txtMaxRow.setValidRange(1,MAX_ROW_LIMIT);
    txtMaxRow.setEmptyStringAllowed(false);
    txtMaxRow.setStringValue(ChartReportItemUIActivator.getDefault().getPluginPreferences().getString(ChartReportItemUIActivator.PREFERENCE_MAX_ROW));
    txtMaxRow.setPage(this);
    txtMaxRow.setPropertyChangeListener(this);
  }
  return cmpTop;
}
Program: 77903
Project: 77903
Buggy source:
private void createOperatorsBar(Composite parent){
  Operator[] operators=provider.getOperators();
  if (operators == null || operators.length == 0) {
    return;
  }
  Composite operatorsBar=new Composite(parent,SWT.NONE);
  operatorsBar.setLayout(new GridLayout(2,false));
  operatorsBar.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  Label lable=new Label(operatorsBar,SWT.NONE);
  lable.setText(LABEL_OPERATORS);
  lable.setLayoutData(new GridData(70,SWT.DEFAULT));
  Composite operatorsArea=new Composite(operatorsBar,SWT.NONE);
  operatorsArea.setLayout(UIUtil.createGridLayoutWithoutMargin(operators.length,true));
  SelectionAdapter selectionAdapter=new SelectionAdapter(){
    public void widgetSelected(    SelectionEvent e){
      Button button=(Button)e.getSource();
      insertText((String)button.getData());
    }
  }
;
  for (int i=0; i < operators.length; i++) {
    Button button=new Button(operatorsArea,SWT.PUSH);
    button.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    if (operators[i] != IExpressionProvider.OPERATOR_SEPARATOR) {
      button.setData(operators[i].insertString);
      String text=operators[i].symbol;
      if (text.indexOf("String_Node_Str") != -1) {
        text=text.replaceAll("String_Node_Str","String_Node_Str");
      }
      button.setText(text);
      button.setToolTipText(operators[i].tooltip);
      button.addSelectionListener(selectionAdapter);
    }
 else {
      button.setVisible(false);
    }
  }
}

Fixed version (ground truth):
private void createOperatorsBar(Composite parent){
  Operator[] operators=provider.getOperators();
  if (operators == null || operators.length == 0) {
    return;
  }
  Composite operatorsBar=new Composite(parent,SWT.NONE);
  operatorsBar.setLayout(new GridLayout(2,false));
  operatorsBar.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  Label lable=new Label(operatorsBar,SWT.NONE);
  lable.setText(LABEL_OPERATORS);
  lable.setLayoutData(new GridData(70,SWT.DEFAULT));
  Composite operatorsArea=new Composite(operatorsBar,SWT.NONE);
  operatorsArea.setLayout(UIUtil.createGridLayoutWithoutMargin(operators.length,true));
  SelectionAdapter selectionAdapter=new SelectionAdapter(){
    public void widgetSelected(    SelectionEvent e){
      Button button=(Button)e.getSource();
      insertText((String)button.getData());
    }
  }
;
  for (int i=0; i < operators.length; i++) {
    Button button=new Button(operatorsArea,SWT.PUSH);
    button.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    if (operators[i] != IExpressionProvider.OPERATOR_SEPARATOR) {
      button.setData(operators[i].insertString);
      String text=operators[i].symbol;
      if (text.indexOf("String_Node_Str") != -1) {
        text=text.replaceAll("String_Node_Str","String_Node_Str");
      }
      button.setText(text);
      button.addSelectionListener(selectionAdapter);
    }
 else {
      button.setVisible(false);
    }
  }
}
Program: 77904
Project: 77904
Buggy source:
/** 
 * Retrieves all distinct values of a data set column and return them in a Collection.
 * @param dataSet Handle of data set to query
 * @param inputParamBindings An iterator of ParamBindingHandle objects that defines bindings for the data set's input parameters
 * @param columnBindings An iterator of ComputedColumnHandle objects that define all column binding expressions
 * @param columnName Name of the bound column to retrieve values for
 * @return If boundColumnName is bound to a single data set column, thismethod returns a collection of distinct values for that data set column. If boundColumnName to mapped to any other type of expressions, an empty collection will be returned.
 */
public abstract Collection getColumnValueSet(DataSetHandle dataSet,Iterator inputParamBindings,Iterator columnBindings,String boundColumnName) throws BirtException ;

Fixed version (ground truth):
/** 
 * Retrieves all distinct values of a data set column based on searchInfo and return in a Collection.
 * @param dataSet Handle of data set to query
 * @param inputParamBindings An iterator of ParamBindingHandle objects that defines bindings for the data set's input parameters
 * @param columnBindings An iterator of ComputedColumnHandle objects that define all column binding expressions
 * @param boundColumnName Name of the bound column to retrieve values for
 * @param requestInfo Information on result set retrieving(like start index,return row number...)
 * @return
 * @throws BirtException
 */
public abstract Collection getColumnValueSet(DataSetHandle dataSet,Iterator inputParamBindings,Iterator columnBindings,String boundColumnName,IRequestInfo requestInfo) throws BirtException ;
Program: 77905
Project: 77905
Buggy source:
public Collection getColumnValueSet(DataSetHandle dataSet,Iterator inputParamBindings,Iterator columnBindings,String boundColumnName) throws BirtException {
}

Fixed version (ground truth):
public Collection getColumnValueSet(DataSetHandle dataSet,Iterator inputParamBindings,Iterator columnBindings,String boundColumnName,IRequestInfo requestInfo) throws BirtException {
  IQueryResults queryResults=getGroupingQueryResults(dataSet,inputParamBindings,columnBindings,boundColumnName);
  IResultIterator resultIt=queryResults.getResultIterator();
  int maxRowCount=-1;
  if (requestInfo != null) {
    resultIt.moveTo(requestInfo.getStartRow());
    maxRowCount=requestInfo.getMaxRow();
  }
  ArrayList values=new ArrayList();
  while (resultIt.next() && maxRowCount != 0) {
    Object value=resultIt.getValue(boundColumnName);
    values.add(value);
    resultIt.skipToEnd(1);
    maxRowCount--;
  }
  resultIt.close();
  queryResults.close();
  return values;
}
Program: 77907
Project: 77907
Buggy source:
protected void pageChange(int newPageIndex){
  int oldPageIndex=getCurrentPage();
  if (oldPageIndex == newPageIndex) {
    return;
  }
  if (oldPageIndex != -1) {
    Object oldPage=pages.get(oldPageIndex);
    Object newPage=pages.get(newPageIndex);
    super.pageChange(newPageIndex);
    updateRelatedViews();
    if (!prePageChanges(oldPage,newPage)) {
      super.setActivePage(oldPageIndex);
      updateRelatedViews();
      return;
    }
  }
 else {
    super.pageChange(newPageIndex);
    updateRelatedViews();
  }
}

Fixed version (ground truth):
protected void pageChange(int newPageIndex){
  int oldPageIndex=getCurrentPage();
  if (oldPageIndex == newPageIndex) {
    return;
  }
  if (oldPageIndex != -1) {
    Object oldPage=pages.get(oldPageIndex);
    Object newPage=pages.get(newPageIndex);
    super.pageChange(newPageIndex);
    updateRelatedViews();
    if (!prePageChanges(oldPage,newPage)) {
      super.setActivePage(oldPageIndex);
      updateRelatedViews();
      return;
    }
  }
 else {
    super.pageChange(newPageIndex);
  }
  updateRelatedViews();
}
Program: 77908
Project: 77908
Buggy source:
protected boolean performInsert(Object model,SlotHandle slotHandle,String type,String position,Map extendData) throws Exception {
  DesignElementHandle elementHandle=createElement(slotHandle,type);
  if (extendData != null) {
    extendData.put(IRequestConstants.REQUEST_KEY_RESULT,elementHandle);
  }
  if (elementHandle == null) {
    return false;
  }
  if (position == InsertAction.CURRENT) {
    slotHandle.add(elementHandle);
  }
 else {
    int pos=DNDUtil.calculateNextPosition(model,DNDUtil.handleValidateTargetCanContain(model,elementHandle,true));
    if (pos > 0 && position == InsertAction.ABOVE) {
      pos--;
    }
    if (pos == -1) {
      slotHandle.add(elementHandle);
    }
 else {
      slotHandle.add(elementHandle,pos);
    }
  }
  if (elementHandle instanceof ExtendedItemHandle) {
    if (!ElementProcessorFactory.createProcessor(elementHandle).editElement(elementHandle)) {
      return false;
    }
  }
  return true;
}

Fixed version (ground truth):
protected boolean performInsert(Object model,SlotHandle slotHandle,String type,String position,Map extendData) throws Exception {
  DesignElementHandle elementHandle=createElement(slotHandle,type);
  if (extendData != null) {
    extendData.put(IRequestConstants.REQUEST_KEY_RESULT,elementHandle);
  }
  if (elementHandle == null) {
    return false;
  }
  if (position == InsertAction.CURRENT) {
    slotHandle.add(elementHandle);
  }
 else {
    int pos=DNDUtil.calculateNextPosition(model,DNDUtil.handleValidateTargetCanContain(model,elementHandle,true));
    if (pos > 0 && position == InsertAction.ABOVE) {
      pos--;
    }
    if (pos == -1) {
      slotHandle.add(elementHandle);
    }
 else {
      slotHandle.add(elementHandle,pos);
    }
  }
  return true;
}
Program: 77909
Project: 77909
Buggy source:
/** 
 * @param dataSetName
 * @return
 * @throws BirtException
 */
private IResultMetaData getRealMetaData(DataSetHandle dataSetHandle) throws BirtException {
  QueryDefinition query=new QueryDefinition();
  query.setDataSetName(dataSetHandle.getQualifiedName());
  query.setMaxRows(1);
  boolean useResultHints=dataSetHandle instanceof ScriptDataSetHandle;
  return new QueryExecutionHelper(dataEngine,modelAdaptor,moduleHandle,useResultHints).executeQuery(query).getResultMetaData();
}

Fixed version (ground truth):
/** 
 * @param dataSetName
 * @return
 * @throws BirtException
 */
private IResultMetaData getRealMetaData(DataSetHandle dataSetHandle) throws BirtException {
  QueryDefinition query=new QueryDefinition();
  query.setDataSetName(dataSetHandle.getQualifiedName());
  query.setMaxRows(1);
  boolean useResultHints=needsUseResultHint(dataSetHandle);
  return new QueryExecutionHelper(dataEngine,modelAdaptor,moduleHandle,useResultHints).executeQuery(query).getResultMetaData();
}
Program: 77910
Project: 77910
Buggy source:
private void populateEventData(TypedEvent event){
  TreeItem[] selection=availableDbObjectsTree.getSelection();
  if (selection.length > 0) {
    Object obj=selection[0].getData();
    if (obj instanceof DbObject) {
      event.data=getDnDString(((DbObject)obj).getName());
    }
 else     if (obj instanceof Procedure) {
      event.data=getDnDString(((Procedure)obj).getProcedureNameWithSchema());
    }
 else {
      event.data=getDnDString(selection[0].getData());
    }
  }
}

Fixed version (ground truth):
private void populateEventData(TypedEvent event){
  TreeItem[] selection=availableDbObjectsTree.getSelection();
  if (selection.length > 0) {
    String data="String_Node_Str";
    for (int i=0; i < selection.length; i++) {
      Object obj=selection[i].getData();
      if (obj instanceof DbObject) {
        data+=getDnDString(((DbObject)obj).getName());
      }
 else       if (obj instanceof Procedure) {
        data+=getDnDString(((Procedure)obj).getProcedureNameWithSchema());
      }
 else {
        data+=getDnDString(obj);
      }
      data+=i != selection.length - 1 ? "String_Node_Str" : "String_Node_Str";
    }
    event.data=data;
  }
}
Program: 77911
Project: 77911
Buggy source:
/** 
 * get parsed parameters as string.
 * @param parameterList Collection
 * @param request HttpServletRequest
 * @param options InputOptions
 * @return Map
 */
protected Map getParsedParametersAsString(Collection parameterList,HttpServletRequest request,InputOptions options) throws ReportServiceException {
  Map params=new HashMap();
  if (parameterList == null)   return params;
  for (Iterator iter=parameterList.iterator(); iter.hasNext(); ) {
    ScalarParameterHandle parameter=null;
    Object parameterObj=iter.next();
    if (parameterObj instanceof ScalarParameterHandle) {
      parameter=(ScalarParameterHandle)parameterObj;
    }
    if (parameter == null)     continue;
    String paramName=parameter.getName();
    String paramValue=getParamValueAsString(request,parameter);
    if (paramValue == null && (IBirtConstants.SERVLET_PATH_FRAMESET.equalsIgnoreCase(request.getServletPath()) || (this.configMap != null && !this.configMap.containsKey(paramName)))) {
      paramValue=this.getParameterDefaultValues(reportDesignHandle,paramName,options);
    }
    if (paramName != null)     params.put(paramName,paramValue);
  }
  return params;
}

Fixed version (ground truth):
/** 
 * get parsed parameters as string.
 * @param parameterList Collection
 * @param request HttpServletRequest
 * @param options InputOptions
 * @return Map
 */
protected Map getParsedParametersAsString(Collection parameterList,HttpServletRequest request,InputOptions options) throws ReportServiceException {
  Map params=new HashMap();
  if (parameterList == null)   return params;
  for (Iterator iter=parameterList.iterator(); iter.hasNext(); ) {
    ScalarParameterHandle parameter=null;
    Object parameterObj=iter.next();
    if (parameterObj instanceof ScalarParameterHandle) {
      parameter=(ScalarParameterHandle)parameterObj;
    }
    if (parameter == null)     continue;
    String paramName=parameter.getName();
    String paramValue=getParamValueAsString(request,parameter);
    if (paramValue == null && !ParameterAccessor.isReportParameterExist(request,paramName) && (IBirtConstants.SERVLET_PATH_FRAMESET.equalsIgnoreCase(request.getServletPath()) || (this.configMap != null && !this.configMap.containsKey(paramName)))) {
      paramValue=this.getParameterDefaultValues(reportDesignHandle,paramName,options);
    }
    if (paramName != null)     params.put(paramName,paramValue);
  }
  return params;
}
Program: 77912
Project: 77912
Buggy source:
/** 
 * get parameter object.
 * @param request HttpServletRequest
 * @param parameter ScalarParameterHandle
 * @return
 */
protected String getParamValueAsString(HttpServletRequest request,ScalarParameterHandle parameter){
  String paramName=parameter.getName();
  String paramValue=null;
  if (ParameterAccessor.isReportParameterExist(request,paramName)) {
    paramValue=ParameterAccessor.getReportParameter(request,paramName,null);
  }
  if (paramValue != null)   return paramValue;
  Object paramValueObj=null;
  if (this.isDesigner && (IBirtConstants.SERVLET_PATH_RUN.equalsIgnoreCase(request.getServletPath()) || IBirtConstants.SERVLET_PATH_PARAMETER.equalsIgnoreCase(request.getServletPath())) && this.configMap != null && this.configMap.containsKey(paramName)) {
    paramValueObj=this.configMap.get(paramName);
  }
 else   if (this.parameterMap != null && this.parameterMap.containsKey(paramName)) {
    paramValueObj=this.parameterMap.get(paramName);
    paramValueObj=ParameterValidationUtil.getDisplayValue(null,parameter.getPattern(),paramValueObj,locale);
  }
  if (paramValueObj != null)   paramValue=paramValueObj.toString();
  return paramValue;
}

Fixed version (ground truth):
/** 
 * get parameter object.
 * @param request HttpServletRequest
 * @param parameter ScalarParameterHandle
 * @return
 */
protected String getParamValueAsString(HttpServletRequest request,ScalarParameterHandle parameter){
  String paramName=parameter.getName();
  String paramValue=null;
  if (ParameterAccessor.isReportParameterExist(request,paramName)) {
    paramValue=ParameterAccessor.getReportParameter(request,paramName,null);
    return paramValue;
  }
  Object paramValueObj=null;
  if (this.isDesigner && (IBirtConstants.SERVLET_PATH_RUN.equalsIgnoreCase(request.getServletPath()) || IBirtConstants.SERVLET_PATH_PARAMETER.equalsIgnoreCase(request.getServletPath())) && this.configMap != null && this.configMap.containsKey(paramName)) {
    paramValueObj=this.configMap.get(paramName);
  }
 else   if (this.parameterMap != null && this.parameterMap.containsKey(paramName)) {
    paramValueObj=this.parameterMap.get(paramName);
    paramValueObj=ParameterValidationUtil.getDisplayValue(null,parameter.getPattern(),paramValueObj,locale);
  }
  if (paramValueObj != null)   paramValue=paramValueObj.toString();
  return paramValue;
}
Program: 77913
Project: 77913
Buggy source:
/** 
 * Exports one design to library.
 * @param designToExport handle of the report design to export
 * @param targetLibraryHandle handle of target library
 * @param canOverride indicates whether the element with the same name in target library will be overriden.
 * @param genDefaultName if true, a default name will be generated if an element doesn't has a name. if false, an exception will be throwed indicate that the element to export must has a name
 * @throws SemanticException if error encountered when element name is duplicate in the target library.
 */
public static void exportDesign(ReportDesignHandle designToExport,LibraryHandle targetLibraryHandle,boolean canOverride,boolean genDefaultName) throws SemanticException {
  ElementExporter exporter=new ElementExporter(targetLibraryHandle);
  exporter.exportDesign(designToExport,canOverride,genDefaultName);
}

Fixed version (ground truth):
/** 
 * Exports one design to library.
 * @param designToExport handle of the report design to export
 * @param targetLibraryHandle handle of target library
 * @param canOverride indicates whether the element with the same name in target library will be overriden.
 * @param genDefaultName if true, a default name will be generated if an element doesn't has a name. if false, an exception will be throwed indicate that the element to export must has a name
 * @throws SemanticException if error encountered when element name is duplicate in the target library.
 */
public static void exportDesign(ReportDesignHandle designToExport,LibraryHandle targetLibraryHandle,boolean canOverride,boolean genDefaultName) throws SemanticException {
  if (ModelUtil.hasLibrary(designToExport,targetLibraryHandle)) {
    throw new SemanticException(designToExport.getElement(),LibraryException.DESIGN_EXCEPTION_LIBRARY_INCLUDED_RECURSIVELY);
  }
  ElementExporter exporter=new ElementExporter(targetLibraryHandle);
  exporter.exportDesign(designToExport,canOverride,genDefaultName);
}