nus-yam/ex-repair huggingface dataset:
Program: 76126
Project: 76126
Buggy source:
/** 
 * @param name
 */
ColumnMeta(String name){
  this.name=name;
}

Fixed version (ground truth):
/** 
 * @param name
 */
ColumnMeta(String name,boolean isLevelKey){
  this.name=name;
  this.isLevelKey=isLevelKey;
}
Program: 76127
Project: 76127
Buggy source:
/** 
 * @param cubeHandle
 * @param query
 * @param resultMetaList
 */
private void prepareMeasure(TabularCubeHandle cubeHandle,QueryDefinition query,List resultMetaList){
  List measureGroups=cubeHandle.getContents(CubeHandle.MEASURE_GROUPS_PROP);
  for (int i=0; i < measureGroups.size(); i++) {
    MeasureGroupHandle mgh=(MeasureGroupHandle)measureGroups.get(i);
    List measures=mgh.getContents(MeasureGroupHandle.MEASURES_PROP);
    for (int j=0; j < measures.size(); j++) {
      MeasureHandle measure=(MeasureHandle)measures.get(j);
      String function=measure.getFunction();
      if (query.getGroups().size() > 0) {
        ScriptExpression se=populateExpression(query,measure,function);
        query.addResultSetExpression(measure.getName(),se);
      }
 else {
        query.addResultSetExpression(measure.getName(),new ScriptExpression(measure.getMeasureExpression()));
      }
      ColumnMeta meta=new ColumnMeta(measure.getName());
      meta.setDataType(ModelAdapter.adaptModelDataType(measure.getDataType()));
      resultMetaList.add(meta);
    }
  }
}

Fixed version (ground truth):
/** 
 * @param cubeHandle
 * @param query
 * @param resultMetaList
 */
private void prepareMeasure(TabularCubeHandle cubeHandle,QueryDefinition query,List metaList){
  List measureGroups=cubeHandle.getContents(CubeHandle.MEASURE_GROUPS_PROP);
  for (int i=0; i < measureGroups.size(); i++) {
    MeasureGroupHandle mgh=(MeasureGroupHandle)measureGroups.get(i);
    List measures=mgh.getContents(MeasureGroupHandle.MEASURES_PROP);
    for (int j=0; j < measures.size(); j++) {
      MeasureHandle measure=(MeasureHandle)measures.get(j);
      String function=measure.getFunction();
      if (query.getGroups().size() > 0) {
        ScriptExpression se=populateExpression(query,measure,function);
        query.addResultSetExpression(measure.getName(),se);
      }
 else {
        query.addResultSetExpression(measure.getName(),new ScriptExpression(measure.getMeasureExpression()));
      }
      ColumnMeta meta=new ColumnMeta(measure.getName(),false);
      meta.setDataType(ModelAdapter.adaptModelDataType(measure.getDataType()));
      metaList.add(meta);
    }
  }
}
Program: 76128
Project: 76128
Buggy source:
/** 
 * Constructor.
 * @param columnMetas
 */
ResultMeta(List columnMetas){
  this.columnMetaMap=new HashMap();
  this.indexMap=new HashMap();
  for (int i=0; i < columnMetas.size(); i++) {
    ColumnMeta columnMeta=(ColumnMeta)columnMetas.get(i);
    columnMeta.setIndex(i + 1);
    this.columnMetaMap.put(columnMeta.getName(),columnMeta);
    this.indexMap.put(new Integer(i + 1),columnMeta);
  }
}

Fixed version (ground truth):
/** 
 * Constructor.
 * @param columnMetas
 */
ResultMeta(List columnMetas){
  this.columnMetaMap=new HashMap();
  this.indexMap=new HashMap();
  this.nullValueReplacer=new Object[columnMetas.size()];
  for (int i=0; i < columnMetas.size(); i++) {
    ColumnMeta columnMeta=(ColumnMeta)columnMetas.get(i);
    columnMeta.setIndex(i + 1);
    this.columnMetaMap.put(columnMeta.getName(),columnMeta);
    this.indexMap.put(new Integer(i + 1),columnMeta);
    if (columnMeta.isLevelKey()) {
      this.nullValueReplacer[i]=createNullValueReplacer(columnMeta.getType());
    }
  }
}
Program: 76129
Project: 76129
Buggy source:
/** 
 * @param query
 * @param resultMetaList
 * @param levelNameColumnNamePair
 * @param hierHandle
 */
private void prepareLevels(QueryDefinition query,List resultMetaList,Map levelNameColumnNamePair,TabularHierarchyHandle hierHandle){
  List levels=hierHandle.getContents(TabularHierarchyHandle.LEVELS_PROP);
  for (int j=0; j < levels.size(); j++) {
    TabularLevelHandle level=(TabularLevelHandle)levels.get(j);
    ColumnMeta temp=new ColumnMeta(level.getName());
    resultMetaList.add(temp);
    levelNameColumnNamePair.put(level.getColumnName(),temp);
    Iterator it=level.attributesIterator();
    while (it.hasNext()) {
      LevelAttributeHandle levelAttr=(LevelAttributeHandle)it.next();
      ColumnMeta meta=new ColumnMeta(level.getName() + "String_Node_Str" + levelAttr.getName());
      meta.setDataType(ModelAdapter.adaptModelDataType(levelAttr.getDataType()));
      query.addResultSetExpression(meta.getName(),new ScriptExpression(ExpressionUtil.createJSDataSetRowExpression(levelAttr.getName())));
      resultMetaList.add(meta);
    }
    query.addResultSetExpression(level.getName(),new ScriptExpression(ExpressionUtil.createJSDataSetRowExpression(level.getColumnName())));
    GroupDefinition gd=new GroupDefinition();
    gd.setKeyExpression(ExpressionUtil.createJSRowExpression(level.getName()));
    query.addGroup(gd);
  }
}

Fixed version (ground truth):
/** 
 * @param query
 * @param resultMetaList
 * @param levelNameColumnNamePair
 * @param hierHandle
 */
private void prepareLevels(QueryDefinition query,TabularHierarchyHandle hierHandle,List metaList){
  List levels=hierHandle.getContents(TabularHierarchyHandle.LEVELS_PROP);
  for (int j=0; j < levels.size(); j++) {
    TabularLevelHandle level=(TabularLevelHandle)levels.get(j);
    ColumnMeta temp=new ColumnMeta(level.getName(),true);
    int type=ModelAdapter.adaptModelDataType(level.getDataType());
    if (isTimeType(type))     temp.setDataType(DataType.INTEGER_TYPE);
    temp.setDataType(type);
    metaList.add(temp);
    Iterator it=level.attributesIterator();
    while (it.hasNext()) {
      LevelAttributeHandle levelAttr=(LevelAttributeHandle)it.next();
      ColumnMeta meta=new ColumnMeta(OlapExpressionUtil.getAttributeColumnName(level.getName(),levelAttr.getName()),false);
      meta.setDataType(ModelAdapter.adaptModelDataType(levelAttr.getDataType()));
      metaList.add(meta);
      query.addResultSetExpression(meta.getName(),new ScriptExpression(ExpressionUtil.createJSDataSetRowExpression(levelAttr.getName())));
    }
    String exprString=populateLevelKeyExpression(level,type);
    query.addResultSetExpression(level.getName(),new ScriptExpression(exprString));
    GroupDefinition gd=new GroupDefinition();
    gd.setKeyExpression(ExpressionUtil.createJSRowExpression(level.getName()));
    query.addGroup(gd);
  }
}
Program: 76130
Project: 76130
Buggy source:
public void drawBackgroundColor(Color color,float x,float y,float width,float height){
  if (null == color) {
    return;
  }
  y=transformY(y,height);
  cbUnder.saveState();
  cbUnder.setColorFill(color);
  cbUnder.rectangle(x,y,width,height);
  cbUnder.fill();
  cbUnder.restoreState();
}

Fixed version (ground truth):
private void drawBackgroundColor(Color color,float x,float y,float width,float height){
  if (null == color) {
    return;
  }
  y=transformY(y,height);
  cbUnder.saveState();
  cbUnder.setColorFill(color);
  cbUnder.rectangle(x,y,width,height);
  cbUnder.fill();
  cbUnder.restoreState();
}
Program: 76131
Project: 76131
Buggy source:
public void drawTotalPage(String text,float textX,float textY,float width,float height,TextStyle textInfo){
  if (totalPageTemplate != null)   drawText(text,textX,textY,width,height,textInfo.getFontInfo(),textInfo.getCharacterSpacing(),textInfo.getWordSpacing(),textInfo.getColor(),textInfo.isLinethrough(),textInfo.isOverline(),textInfo.isUnderline(),textInfo.getAlign(),true);
}

Fixed version (ground truth):
public void drawTotalPage(String text,int textX,int textY,int width,int height,TextStyle textInfo){
  if (totalPageTemplate != null)   drawText(text,textX,textY,width,height,textInfo.getFontInfo(),textInfo.getLetterSpacing(),textInfo.getWordSpacing(),textInfo.getColor(),textInfo.isLinethrough(),textInfo.isOverline(),textInfo.isUnderline(),textInfo.getAlign(),true);
}
Program: 76132
Project: 76132
Buggy source:
public void createBookmark(String bookmark,float x,float y,float width,float height){
  contentByte.localDestination(bookmark,new PdfDestination(PdfDestination.XYZ,-1,transformY(y),0));
}

Fixed version (ground truth):
private void createBookmark(String bookmark,float x,float y,float width,float height){
  contentByte.localDestination(bookmark,new PdfDestination(PdfDestination.XYZ,-1,transformY(y),0));
}
Program: 76133
Project: 76133
Buggy source:
public void createTotalPageTemplate(float x,float y,float width,float height){
  if (totalPageTemplate == null) {
    totalPageTemplate=contentByte.createTemplate(width,height);
  }
  y=transformY(y,height);
  contentByte.saveState();
  contentByte.addTemplate(totalPageTemplate,x,y);
  contentByte.restoreState();
}

Fixed version (ground truth):
private void createTotalPageTemplate(float x,float y,float width,float height){
  if (totalPageTemplate == null) {
    totalPageTemplate=contentByte.createTemplate(width,height);
  }
  y=transformY(y,height);
  contentByte.saveState();
  contentByte.addTemplate(totalPageTemplate,x,y);
  contentByte.restoreState();
}
Program: 76135
Project: 76135
Buggy source:
/** 
 * Draws a line from the start position to the end position with the given linewidth, color, and style at the given pdf layer.
 * @param startX			the start X coordinate of the line
 * @param startY 			the start Y coordinate of the line
 * @param endX 				the end X coordinate of the line
 * @param endY 				the end Y coordinate of the line
 * @param width 			the lineWidth
 * @param color 			the color of the line
 * @param lineStyle 		the given line style
 * @param contentByte 		the given pdf layer
 */
private void drawLine(float startX,float startY,float endX,float endY,float width,Color color,String lineStyle,PdfContentByte contentByte){
  if (null == color || 0f == width || "String_Node_Str".equalsIgnoreCase(lineStyle)) {
    return;
  }
  contentByte.saveState();
  if ("String_Node_Str".equalsIgnoreCase(lineStyle)) {
    drawRawLine(startX,startY,endX,endY,width,color,contentByte);
  }
  if ("String_Node_Str".equalsIgnoreCase(lineStyle)) {
    contentByte.setLineDash(3 * width,2 * width,0f);
    drawRawLine(startX,startY,endX,endY,width,color,contentByte);
  }
 else   if ("String_Node_Str".equalsIgnoreCase(lineStyle)) {
    contentByte.setLineDash(width,width,0f);
    drawRawLine(startX,startY,endX,endY,width,color,contentByte);
  }
 else   if ("String_Node_Str".equalsIgnoreCase(lineStyle)) {
    return;
  }
 else {
    drawRawLine(startX,startY,endX,endY,width,color,contentByte);
  }
  contentByte.restoreState();
}

Fixed version (ground truth):
/** 
 * Draws a line from the start position to the end position with the given linewidth, color, and style at the given pdf layer.
 * @param startX the start X coordinate of the line
 * @param startY the start Y coordinate of the line
 * @param endX the end X coordinate of the line
 * @param endY the end Y coordinate of the line
 * @param width the lineWidth
 * @param color the color of the line
 * @param lineStyle the given line style
 * @param contentByte the given pdf layer
 */
private void drawLine(float startX,float startY,float endX,float endY,float width,Color color,String lineStyle,PdfContentByte contentByte){
  if (null == color || 0f == width || "String_Node_Str".equalsIgnoreCase(lineStyle)) {
    return;
  }
  contentByte.saveState();
  if ("String_Node_Str".equalsIgnoreCase(lineStyle)) {
    drawRawLine(startX,startY,endX,endY,width,color,contentByte);
  }
  if ("String_Node_Str".equalsIgnoreCase(lineStyle)) {
    contentByte.setLineDash(3 * width,2 * width,0f);
    drawRawLine(startX,startY,endX,endY,width,color,contentByte);
  }
 else   if ("String_Node_Str".equalsIgnoreCase(lineStyle)) {
    contentByte.setLineDash(width,width,0f);
    drawRawLine(startX,startY,endX,endY,width,color,contentByte);
  }
 else   if ("String_Node_Str".equalsIgnoreCase(lineStyle)) {
    return;
  }
 else {
    drawRawLine(startX,startY,endX,endY,width,color,contentByte);
  }
  contentByte.restoreState();
}
Program: 76136
Project: 76136
Buggy source:
public void createHyperlink(String hyperlink,String bookmark,String targetWindow,int type,float x,float y,float width,float height){
  y=transformY(y,height);
  writer.addAnnotation(new PdfAnnotation(writer,x,y,x + width,y + height,createPdfAction(hyperlink,bookmark,targetWindow,type)));
}

Fixed version (ground truth):
private void createHyperlink(String hyperlink,String bookmark,String targetWindow,int type,float x,float y,float width,float height){
  y=transformY(y,height);
  writer.addAnnotation(new PdfAnnotation(writer,x,y,x + width,y + height,createPdfAction(hyperlink,bookmark,targetWindow,type)));
}
Program: 76137
Project: 76137
Buggy source:
public PDFPage(float pageWidth,float pageHeight,Document document,PdfWriter writer){
  this.pageHeight=pageHeight;
  this.writer=writer;
  try {
    Rectangle pageSize=new Rectangle(pageWidth,pageHeight);
    document.setPageSize(pageSize);
    if (!document.isOpen())     document.open();
 else     document.newPage();
    this.contentByte=writer.getDirectContent();
    this.cbUnder=writer.getDirectContentUnder();
  }
 catch (  DocumentException de) {
    logger.log(Level.SEVERE,de.getMessage(),de);
  }
}

Fixed version (ground truth):
public PDFPage(int pageWidth,int pageHeight,Document document,PdfWriter writer){
  float ratio=PDFConstants.LAYOUT_TO_PDF_RATIO;
  this.pageHeight=pageHeight / ratio;
  this.writer=writer;
  try {
    Rectangle pageSize=new Rectangle(pageWidth / ratio,pageHeight / ratio);
    document.setPageSize(pageSize);
    if (!document.isOpen())     document.open();
 else     document.newPage();
    this.contentByte=writer.getDirectContent();
    this.cbUnder=writer.getDirectContentUnder();
  }
 catch (  DocumentException de) {
    logger.log(Level.SEVERE,de.getMessage(),de);
  }
}
Program: 76138
Project: 76138
Buggy source:
public void clip(float startX,float startY,float width,float height){
  startY=transformY(startY,height);
  contentByte.clip();
  contentByte.rectangle(startX,startY,width,height);
  contentByte.newPath();
}

Fixed version (ground truth):
private void clip(float startX,float startY,float width,float height){
  startY=transformY(startY,height);
  contentByte.clip();
  contentByte.rectangle(startX,startY,width,height);
  contentByte.newPath();
}
Program: 76139
Project: 76139
Buggy source:
public IPage newPage(float width,float height,Color backgroundColor){
  currentPage=new PDFPage(width,height,doc,writer);
  currentPage.drawBackgroundColor(backgroundColor,0,0,width,height);
  return currentPage;
}

Fixed version (ground truth):
public IPage newPage(int width,int height,Color backgroundColor){
  currentPage=new PDFPage(width,height,doc,writer);
  currentPage.drawBackgroundColor(backgroundColor,0,0,width,height);
  return currentPage;
}
Program: 76140
Project: 76140
Buggy source:
public void setTotalPage(ITextArea totalPage){
  super.setTotalPage(totalPage);
  ContainerPosition curPos=getContainerPosition();
  float x=curPos.x + getX(totalPage);
  float y=curPos.y + getY(totalPage);
  isTotalPage=true;
  drawTextAt(totalPage,x,y);
}

Fixed version (ground truth):
public void setTotalPage(ITextArea totalPage){
  super.setTotalPage(totalPage);
  ContainerPosition curPos=getContainerPosition();
  int x=curPos.x + getX(totalPage);
  int y=curPos.y + getY(totalPage);
  isTotalPage=true;
  drawTextAt(totalPage,x,y);
}
Program: 76141
Project: 76141
Buggy source:
public void visitText(ITextArea textArea){
  super.visitText(textArea);
  ContainerPosition curPos=getContainerPosition();
  float x=curPos.x + getX(textArea);
  float y=curPos.y + getY(textArea);
  createBookmark(textArea,x,y);
  createHyperlink(textArea,x,y);
}

Fixed version (ground truth):
public void visitText(ITextArea textArea){
  super.visitText(textArea);
  ContainerPosition curPos=getContainerPosition();
  int x=curPos.x + getX(textArea);
  int y=curPos.y + getY(textArea);
  createBookmark(textArea,x,y);
  createHyperlink(textArea,x,y);
}
Program: 76142
Project: 76142
Buggy source:
protected void drawTotalPage(String text,float x,float y,float width,float height,TextStyle textInfo){
  currentPage.drawTotalPage(text,x,y,width,height,textInfo);
}

Fixed version (ground truth):
protected void drawTotalPage(String text,int x,int y,int width,int height,TextStyle textInfo){
  currentPage.drawTotalPage(text,x,y,width,height,textInfo);
}
Program: 76143
Project: 76143
Buggy source:
protected void drawContainer(IContainerArea container){
  super.drawContainer(container);
  ContainerPosition curPos=getContainerPosition();
  float x=curPos.x + getX(container);
  float y=curPos.y + getY(container);
  createBookmark(container,x,y);
  createHyperlink(container,x,y);
}

Fixed version (ground truth):
protected void drawContainer(IContainerArea container){
  super.drawContainer(container);
  ContainerPosition curPos=getContainerPosition();
  int x=curPos.x + getX(container);
  int y=curPos.y + getY(container);
  createBookmark(container,x,y);
  createHyperlink(container,x,y);
}
Program: 76144
Project: 76144
Buggy source:
private void createBookmark(IArea area,float x,float y){
  float height=getHeight(area);
  float width=getWidth(area);
  IContent content=area.getContent();
  if (null != content) {
    String bookmark=content.getBookmark();
    if (null != bookmark) {
      currentPage.createBookmark(bookmark,x,y,width,height);
    }
  }
}

Fixed version (ground truth):
private void createBookmark(IArea area,int x,int y){
  int height=getHeight(area);
  int width=getWidth(area);
  IContent content=area.getContent();
  if (null != content) {
    String bookmark=content.getBookmark();
    if (null != bookmark) {
      currentPage.createBookmark(bookmark,x,y,width,height);
    }
  }
}
Program: 76145
Project: 76145
Buggy source:
private void createHyperlink(IArea area,float x,float y){
  IContent content=area.getContent();
  if (null != content) {
    IHyperlinkAction hlAction=content.getHyperlinkAction();
    String systemId=reportRunnable == null ? null : reportRunnable.getReportName();
    if (null != hlAction)     try {
      float width=getWidth(area);
      float height=getHeight(area);
      String hyperlink=hlAction.getHyperlink();
      String bookmark=hlAction.getBookmark();
      String targetWindow=hlAction.getTargetWindow();
      int type=hlAction.getType();
switch (type) {
case IHyperlinkAction.ACTION_BOOKMARK:
        currentPage.createHyperlink(hyperlink,bookmark,targetWindow,type,x,y,width,height);
      break;
case IHyperlinkAction.ACTION_HYPERLINK:
    currentPage.createHyperlink(hyperlink,null,targetWindow,type,x,y,width,height);
  break;
case IHyperlinkAction.ACTION_DRILLTHROUGH:
Action act=new Action(systemId,hlAction);
IHTMLActionHandler actionHandler=null;
Object ac=services.getOption(RenderOption.ACTION_HANDLER);
if (ac != null && ac instanceof IHTMLActionHandler) {
actionHandler=(IHTMLActionHandler)ac;
}
String link=actionHandler.getURL(act,context);
currentPage.createHyperlink(link,null,targetWindow,type,x,y,width,height);
break;
}
}
 catch (Exception e) {
logger.log(Level.WARNING,e.getMessage(),e);
}
}
}

Fixed version (ground truth):
private void createHyperlink(IArea area,int x,int y){
  IContent content=area.getContent();
  if (null != content) {
    IHyperlinkAction hlAction=content.getHyperlinkAction();
    String systemId=reportRunnable == null ? null : reportRunnable.getReportName();
    if (null != hlAction)     try {
      int width=getWidth(area);
      int height=getHeight(area);
      String hyperlink=hlAction.getHyperlink();
      String bookmark=hlAction.getBookmark();
      String targetWindow=hlAction.getTargetWindow();
      int type=hlAction.getType();
switch (type) {
case IHyperlinkAction.ACTION_BOOKMARK:
        currentPage.createHyperlink(hyperlink,bookmark,targetWindow,type,x,y,width,height);
      break;
case IHyperlinkAction.ACTION_HYPERLINK:
    currentPage.createHyperlink(hyperlink,null,targetWindow,type,x,y,width,height);
  break;
case IHyperlinkAction.ACTION_DRILLTHROUGH:
Action act=new Action(systemId,hlAction);
IHTMLActionHandler actionHandler=null;
Object ac=services.getOption(RenderOption.ACTION_HANDLER);
if (ac != null && ac instanceof IHTMLActionHandler) {
actionHandler=(IHTMLActionHandler)ac;
}
String link=actionHandler.getURL(act,context);
currentPage.createHyperlink(link,null,targetWindow,type,x,y,width,height);
break;
}
}
 catch (Exception e) {
logger.log(Level.WARNING,e.getMessage(),e);
}
}
}
Program: 76146
Project: 76146
Buggy source:
public void visitImage(IImageArea imageArea){
  ContainerPosition curPos=getContainerPosition();
  float imageX=curPos.x + getX(imageArea);
  float imageY=curPos.y + getY(imageArea);
  super.visitImage(imageArea);
  createBookmark(imageArea,imageX,imageY);
  createHyperlink(imageArea,imageX,imageY);
}

Fixed version (ground truth):
public void visitImage(IImageArea imageArea){
  ContainerPosition curPos=getContainerPosition();
  int imageX=curPos.x + getX(imageArea);
  int imageY=curPos.y + getY(imageArea);
  super.visitImage(imageArea);
  createBookmark(imageArea,imageX,imageY);
  createHyperlink(imageArea,imageX,imageY);
}
Program: 76147
Project: 76147
Buggy source:
protected void drawTextAt(ITextArea text,float x,float y,float width,float height,TextStyle textInfo){
  if (isTotalPage) {
    currentPage.drawTotalPage(text.getText(),x,y,width,height,textInfo);
  }
 else {
    currentPage.drawText(text.getText(),x,y,width,height,textInfo);
  }
}

Fixed version (ground truth):
protected void drawTextAt(ITextArea text,int x,int y,int width,int height,TextStyle textInfo){
  if (isTotalPage) {
    currentPage.drawTotalPage(text.getText(),x,y,width,height,textInfo);
  }
 else {
    currentPage.drawText(text.getText(),x,y,width,height,textInfo);
  }
}
Program: 76148
Project: 76148
Buggy source:
public void visitAutoText(ITemplateArea templateArea){
  super.visitAutoText(templateArea);
  ContainerPosition curPos=getContainerPosition();
  float x=curPos.x + getX(templateArea);
  float y=curPos.y + getY(templateArea);
  createTotalPageTemplate(x,y,getWidth(templateArea),getHeight(templateArea));
}

Fixed version (ground truth):
public void visitAutoText(ITemplateArea templateArea){
  super.visitAutoText(templateArea);
  ContainerPosition curPos=getContainerPosition();
  int x=curPos.x + getX(templateArea);
  int y=curPos.y + getY(templateArea);
  createTotalPageTemplate(x,y,getWidth(templateArea),getHeight(templateArea));
}
Program: 76149
Project: 76149
Buggy source:
private void createTotalPageTemplate(float x,float y,float width,float height){
  currentPage.createTotalPageTemplate(x,y,width,height);
}

Fixed version (ground truth):
private void createTotalPageTemplate(int x,int y,int width,int height){
  currentPage.createTotalPageTemplate(x,y,width,height);
}
Program: 76150
Project: 76150
Buggy source:
public void drawImage(String uri,float imageX,float imageY,float height,float width,String helpText) throws Exception {
  if (uri == null) {
    return;
  }
  drawImage(new URL(uri).openStream(),imageX,imageY,height,width,helpText);
}

Fixed version (ground truth):
public void drawImage(String uri,int imageX,int imageY,int height,int width,String helpText) throws Exception {
  if (uri == null) {
    return;
  }
  drawImage(new URL(uri).openStream(),imageX,imageY,height,width,helpText);
}
Program: 76151
Project: 76151
Buggy source:
public void drawText(String text,float textX,float textY,float width,float height,TextStyle fontStyle){
  writer.drawString(text,textX,textY,fontStyle.getFontInfo(),fontStyle.getCharacterSpacing(),fontStyle.getWordSpacing(),fontStyle.getColor(),fontStyle.isLinethrough(),fontStyle.isOverline(),fontStyle.isUnderline(),fontStyle.getAlign());
}

Fixed version (ground truth):
public void drawText(String text,int textX,int textY,int width,int height,TextStyle fontStyle){
  writer.drawString(text,convertToPoint(textX),convertToPoint(textY),fontStyle.getFontInfo(),convertToPoint(fontStyle.getLetterSpacing()),convertToPoint(fontStyle.getWordSpacing()),fontStyle.getColor(),fontStyle.isLinethrough(),fontStyle.isOverline(),fontStyle.isUnderline(),fontStyle.getAlign());
}
Program: 76152
Project: 76152
Buggy source:
public void drawBackgroundImage(float x,float y,float width,float height,String repeat,String imageUrl,float absPosX,float absPosY) throws IOException {
  writer.drawBackgroundImage(imageUrl,x,y,width,height,absPosX,absPosY,repeat);
}

Fixed version (ground truth):
public void drawBackgroundImage(int x,int y,int width,int height,String repeat,String imageUrl,int absPosX,int absPosY) throws IOException {
  writer.drawBackgroundImage(imageUrl,convertToPoint(x),convertToPoint(y),convertToPoint(width),convertToPoint(height),convertToPoint(absPosX),convertToPoint(absPosY),repeat);
}
Program: 76153
Project: 76153
Buggy source:
public void drawLine(float startX,float startY,float endX,float endY,float width,Color color,String lineStyle){
  writer.drawLine(startX,startY,endX,endY,width,color,lineStyle);
}

Fixed version (ground truth):
public void drawLine(int startX,int startY,int endX,int endY,int width,Color color,String lineStyle){
  writer.drawLine(convertToPoint(startX),convertToPoint(startY),convertToPoint(endX),convertToPoint(endY),convertToPoint(width),color,lineStyle);
}
Program: 76154
Project: 76154
Buggy source:
public void drawBackgroundColor(Color color,float x,float y,float width,float height){
  if (color != null) {
    writer.fillRect(x,y,width,height,color);
  }
}

Fixed version (ground truth):
public void drawBackgroundColor(Color color,int x,int y,int width,int height){
  if (color != null) {
    writer.fillRect(convertToPoint(x),convertToPoint(y),convertToPoint(width),convertToPoint(height),color);
  }
}
Program: 76155
Project: 76155
Buggy source:
void setPageSize(float pageWidth,float pageHeight){
  writer.startPage(pageWidth,pageHeight);
}

Fixed version (ground truth):
void setPageSize(int pageWidth,int pageHeight){
  writer.startPage(convertToPoint(pageWidth),convertToPoint(pageHeight));
}
Program: 76156
Project: 76156
Buggy source:
public void clip(float startX,float startY,float width,float height){
  writer.clipRect(startX,startY,width,height);
}

Fixed version (ground truth):
public void clip(int startX,int startY,int width,int height){
  writer.clipRect(convertToPoint(startX),convertToPoint(startY),convertToPoint(width),convertToPoint(height));
}
Program: 76157
Project: 76157
Buggy source:
public IPage newPage(float width,float height,Color backgroundColor){
  if (currentPage != null) {
    currentPage.dispose();
  }
  currentPage=new PostscriptPage(writer);
  currentPage.setPageSize(width,height);
  currentPage.drawPageBackgroundColor(backgroundColor);
  return currentPage;
}

Fixed version (ground truth):
public IPage newPage(int width,int height,Color backgroundColor){
  if (currentPage != null) {
    currentPage.dispose();
  }
  currentPage=new PostscriptPage(writer);
  currentPage.setPageSize(width,height);
  currentPage.drawPageBackgroundColor(backgroundColor);
  return currentPage;
}
Program: 76158
Project: 76158
Buggy source:
public void visitContainer(IContainerArea containerArea){
  addContent(containerArea.getContent());
}

Fixed version (ground truth):
public void visitContainer(IContainerArea container){
  addContent(container.getContent());
  Iterator iter=container.getChildren();
  while (iter.hasNext()) {
    IArea child=(IArea)iter.next();
    child.accept(this);
  }
}
Program: 76160
Project: 76160
Buggy source:
/** 
 * @param query
 * @param resultMetaList
 * @param levelNameColumnNamePair
 * @param hierHandle
 */
private void prepareLevels(QueryDefinition query,TabularHierarchyHandle hierHandle,List metaList){
  List levels=hierHandle.getContents(TabularHierarchyHandle.LEVELS_PROP);
  for (int j=0; j < levels.size(); j++) {
    TabularLevelHandle level=(TabularLevelHandle)levels.get(j);
    ColumnMeta temp=new ColumnMeta(level.getName(),true);
    int type=ModelAdapter.adaptModelDataType(level.getDataType());
    if (isTimeType(type))     temp.setDataType(DataType.INTEGER_TYPE);
    temp.setDataType(type);
    metaList.add(temp);
    Iterator it=level.attributesIterator();
    while (it.hasNext()) {
      LevelAttributeHandle levelAttr=(LevelAttributeHandle)it.next();
      ColumnMeta meta=new ColumnMeta(OlapExpressionUtil.getAttributeColumnName(level.getName(),levelAttr.getName()),false);
      meta.setDataType(ModelAdapter.adaptModelDataType(levelAttr.getDataType()));
      metaList.add(meta);
      query.addResultSetExpression(meta.getName(),new ScriptExpression(ExpressionUtil.createJSDataSetRowExpression(levelAttr.getName())));
    }
    String exprString=populateLevelKeyExpression(level,type);
    query.addResultSetExpression(level.getName(),new ScriptExpression(exprString));
    GroupDefinition gd=new GroupDefinition();
    gd.setKeyExpression(ExpressionUtil.createJSRowExpression(level.getName()));
    query.addGroup(gd);
  }
}

Fixed version (ground truth):
/** 
 * @param query
 * @param resultMetaList
 * @param levelNameColumnNamePair
 * @param hierHandle
 */
private void prepareLevels(QueryDefinition query,TabularHierarchyHandle hierHandle,List metaList){
  List levels=hierHandle.getContents(TabularHierarchyHandle.LEVELS_PROP);
  for (int j=0; j < levels.size(); j++) {
    TabularLevelHandle level=(TabularLevelHandle)levels.get(j);
    ColumnMeta temp=new ColumnMeta(level.getName(),true);
    int type=ModelAdapter.adaptModelDataType(level.getDataType());
    if (isTimeType(type))     temp.setDataType(DataType.INTEGER_TYPE);
    temp.setDataType(type);
    metaList.add(temp);
    Iterator it=level.attributesIterator();
    while (it.hasNext()) {
      LevelAttributeHandle levelAttr=(LevelAttributeHandle)it.next();
      ColumnMeta meta=new ColumnMeta(level.getName() + "String_Node_Str" + levelAttr.getName(),false);
      meta.setDataType(ModelAdapter.adaptModelDataType(levelAttr.getDataType()));
      metaList.add(meta);
      query.addResultSetExpression(meta.getName(),new ScriptExpression(ExpressionUtil.createJSDataSetRowExpression(levelAttr.getName())));
    }
    String exprString=populateLevelKeyExpression(level,type);
    query.addResultSetExpression(level.getName(),new ScriptExpression(exprString));
    GroupDefinition gd=new GroupDefinition();
    gd.setKeyExpression(ExpressionUtil.createJSRowExpression(level.getName()));
    query.addGroup(gd);
  }
}
Program: 76161
Project: 76161
Buggy source:
/** 
 * Test set format of style
 * @throws Exception
 */
public void testSetStyleFormat() throws Exception {
  designHandle=new SessionHandle(ULocale.getDefault()).createDesign();
  design=(ReportDesign)designHandle.getModule();
  ElementFactory factory=new ElementFactory(design);
  StyleHandle style1=factory.newStyle("String_Node_Str");
  try {
    style1.setNumberFormatCategory("String_Node_Str");
    fail();
  }
 catch (  SemanticException e) {
    assertEquals(PropertyValueException.DESIGN_EXCEPTION_CHOICE_NOT_FOUND,e.getErrorCode());
  }
  style1.setNumberFormat("String_Node_Str");
  style1.setNumberFormatCategory(DesignChoiceConstants.NUMBER_FORMAT_TYPE_FIXED);
  FactoryPropertyHandle factoryHandle=style1.getFactoryPropertyHandle(IStyleModel.NUMBER_FORMAT_PROP);
  assertEquals("String_Node_Str",factoryHandle.getStringValue());
}

Fixed version (ground truth):
/** 
 * Test set format of style
 * @throws Exception
 */
public void testSetStyleFormat() throws Exception {
  designHandle=new SessionHandle(ULocale.getDefault()).createDesign();
  design=(ReportDesign)designHandle.getModule();
  ElementFactory factory=new ElementFactory(design);
  StyleHandle style1=factory.newStyle("String_Node_Str");
  try {
    style1.setNumberFormatCategory("String_Node_Str");
    fail();
  }
 catch (  SemanticException e) {
    assertEquals(PropertyValueException.DESIGN_EXCEPTION_CHOICE_NOT_FOUND,e.getErrorCode());
  }
  style1.setNumberFormat("String_Node_Str");
  style1.setNumberFormatCategory(DesignChoiceConstants.NUMBER_FORMAT_TYPE_FIXED);
  FactoryPropertyHandle factoryHandle=style1.getFactoryPropertyHandle(IStyleModel.NUMBER_FORMAT_PROP);
  assertEquals("String_Node_Str",factoryHandle.getStringValue());
  style1.setDateFormatCategory(DesignChoiceConstants.DATE_FORMAT_TYPE_SHORT_DATE);
  style1.setDateFormat("String_Node_Str");
  assertEquals("String_Node_Str",style1.getDateFormat());
  assertEquals(DesignChoiceConstants.DATE_FORMAT_TYPE_SHORT_DATE,style1.getDateFormatCategory());
  style1.setTimeFormatCategory(DesignChoiceConstants.TIME_FORMAT_TYPE_SHORT_TIME);
  style1.setTimeFormat("String_Node_Str");
  assertEquals("String_Node_Str",style1.getTimeFormat());
  assertEquals(DesignChoiceConstants.TIME_FORMAT_TYPE_SHORT_TIME,style1.getTimeFormatCategory());
}
Program: 76162
Project: 76162
Buggy source:
/** 
 * @param query
 * @param resultMetaList
 * @param levelNameColumnNamePair
 * @param hierHandle
 */
private void prepareLevels(QueryDefinition query,List resultMetaList,Map levelNameColumnNamePair,TabularHierarchyHandle hierHandle){
  List levels=hierHandle.getContents(TabularHierarchyHandle.LEVELS_PROP);
  for (int j=0; j < levels.size(); j++) {
    TabularLevelHandle level=(TabularLevelHandle)levels.get(j);
    ColumnMeta temp=new ColumnMeta(level.getName());
    resultMetaList.add(temp);
    levelNameColumnNamePair.put(level.getColumnName(),temp);
    Iterator it=level.attributesIterator();
    while (it.hasNext()) {
      LevelAttributeHandle levelAttr=(LevelAttributeHandle)it.next();
      ColumnMeta meta=new ColumnMeta(level.getName() + "String_Node_Str" + levelAttr.getName());
      meta.setDataType(ModelAdapter.adaptModelDataType(levelAttr.getDataType()));
      query.addResultSetExpression(meta.getName(),new ScriptExpression(ExpressionUtil.createJSDataSetRowExpression(levelAttr.getName())));
      resultMetaList.add(meta);
    }
    query.addResultSetExpression(level.getName(),new ScriptExpression(ExpressionUtil.createJSDataSetRowExpression(level.getColumnName())));
    if (j == levels.size() - 1) {
      GroupDefinition gd=new GroupDefinition();
      gd.setKeyExpression(ExpressionUtil.createJSRowExpression(level.getName()));
      query.addGroup(gd);
    }
  }
}

Fixed version (ground truth):
/** 
 * @param query
 * @param resultMetaList
 * @param levelNameColumnNamePair
 * @param hierHandle
 */
private void prepareLevels(QueryDefinition query,List resultMetaList,Map levelNameColumnNamePair,TabularHierarchyHandle hierHandle){
  List levels=hierHandle.getContents(TabularHierarchyHandle.LEVELS_PROP);
  for (int j=0; j < levels.size(); j++) {
    TabularLevelHandle level=(TabularLevelHandle)levels.get(j);
    ColumnMeta temp=new ColumnMeta(level.getName());
    resultMetaList.add(temp);
    levelNameColumnNamePair.put(level.getColumnName(),temp);
    Iterator it=level.attributesIterator();
    while (it.hasNext()) {
      LevelAttributeHandle levelAttr=(LevelAttributeHandle)it.next();
      ColumnMeta meta=new ColumnMeta(level.getName() + "String_Node_Str" + levelAttr.getName());
      meta.setDataType(ModelAdapter.adaptModelDataType(levelAttr.getDataType()));
      query.addResultSetExpression(meta.getName(),new ScriptExpression(ExpressionUtil.createJSDataSetRowExpression(levelAttr.getName())));
      resultMetaList.add(meta);
    }
    query.addResultSetExpression(level.getName(),new ScriptExpression(ExpressionUtil.createJSDataSetRowExpression(level.getColumnName())));
    GroupDefinition gd=new GroupDefinition();
    gd.setKeyExpression(ExpressionUtil.createJSRowExpression(level.getName()));
    query.addGroup(gd);
  }
}
Program: 76163
Project: 76163
Buggy source:
public abstract void buildImageStyle(IImageContent image,StringBuffer styleBuffer);

Fixed version (ground truth):
public abstract void buildImageStyle(IImageContent image,StringBuffer styleBuffer,int display);
Program: 76164
Project: 76164
Buggy source:
/** 
 * Build the style of image content.
 */
public void buildImageStyle(IImageContent image,StringBuffer styleBuffer){
  buildSize(styleBuffer,HTMLTags.ATTR_WIDTH,image.getWidth());
  buildSize(styleBuffer,HTMLTags.ATTR_HEIGHT,image.getHeight());
  buildStyle(image,styleBuffer);
}

Fixed version (ground truth):
/** 
 * Build the style of image content.
 */
public void buildImageStyle(IImageContent image,StringBuffer styleBuffer,int display){
  buildSize(styleBuffer,HTMLTags.ATTR_WIDTH,image.getWidth());
  buildSize(styleBuffer,HTMLTags.ATTR_HEIGHT,image.getHeight());
  buildStyle(image,styleBuffer);
}
Program: 76166
Project: 76166
Buggy source:
/** 
 * Build the style of image content.
 */
public void buildImageStyle(IImageContent image,StringBuffer styleBuffer){
  buildSize(styleBuffer,HTMLTags.ATTR_WIDTH,image.getWidth());
  buildSize(styleBuffer,HTMLTags.ATTR_HEIGHT,image.getHeight());
  buildStyle(image,styleBuffer);
}

Fixed version (ground truth):
/** 
 * Build the style of image content.
 */
public void buildImageStyle(IImageContent image,StringBuffer styleBuffer,int display){
  buildSize(styleBuffer,HTMLTags.ATTR_WIDTH,image.getWidth());
  buildSize(styleBuffer,HTMLTags.ATTR_HEIGHT,image.getHeight());
  setDisplayProperty(display,0,styleBuffer);
  buildStyle(image,styleBuffer);
}
Program: 76170
Project: 76170
Buggy source:
/** 
 * @param documentObject
 * @param dataType
 * @param value
 * @throws IOException
 */
public static void writeValue(IDocumentObject documentObject,int dataType,Object value) throws IOException {
}

Fixed version (ground truth):
/** 
 * @param documentObject
 * @param dataType
 * @param value
 * @throws IOException
 * @throws DataException 
 */
public static void writeValue(IDocumentObject documentObject,int dataType,Object value) throws IOException, DataException {
}
Program: 76171
Project: 76171
Buggy source:
/** 
 * @param levelMember
 * @param keyDataType
 * @param attributesDataType
 * @throws IOException
 */
private void writeLevelMember(Member levelMember,int keyDataType[],int[] attributesDataType) throws IOException {
  for (int i=0; i < levelMember.keyValues.length; i++) {
    DocumentObjectUtil.writeValue(documentObj,keyDataType[i],levelMember.keyValues[i]);
  }
  if (levelMember.attributes != null) {
    for (int i=0; i < levelMember.attributes.length; i++) {
      DocumentObjectUtil.writeValue(documentObj,attributesDataType[i],levelMember.attributes[i]);
    }
  }
}

Fixed version (ground truth):
/** 
 * @param levelMember
 * @param keyDataType
 * @param attributesDataType
 * @throws IOException
 * @throws DataException 
 */
private void writeLevelMember(Member levelMember,int keyDataType[],int[] attributesDataType) throws IOException, DataException {
  for (int i=0; i < levelMember.keyValues.length; i++) {
    DocumentObjectUtil.writeValue(documentObj,keyDataType[i],levelMember.keyValues[i]);
  }
  if (levelMember.attributes != null) {
    for (int i=0; i < levelMember.attributes.length; i++) {
      DocumentObjectUtil.writeValue(documentObj,attributesDataType[i],levelMember.attributes[i]);
    }
  }
}
Program: 76172
Project: 76172
Buggy source:
/** 
 * @param dimensionMember
 * @param keyDataType
 * @param attributesDataType
 * @throws IOException
 */
private void writeDimensionRow(DimensionRow dimensionMember,int[][] keyDataType,int[][] attributesDataType) throws IOException {
  Member[] levelMembers=dimensionMember.members;
  for (int i=0; i < levelMembers.length; i++) {
    writeLevelMember(levelMembers[i],keyDataType[i],attributesDataType[i]);
  }
}

Fixed version (ground truth):
/** 
 * @param dimensionMember
 * @param keyDataType
 * @param attributesDataType
 * @throws IOException
 * @throws DataException 
 */
private void writeDimensionRow(DimensionRow dimensionMember,int[][] keyDataType,int[][] attributesDataType) throws IOException, DataException {
  Member[] levelMembers=dimensionMember.members;
  for (int i=0; i < levelMembers.length; i++) {
    writeLevelMember(levelMembers[i],keyDataType[i],attributesDataType[i]);
  }
}
Program: 76173
Project: 76173
Buggy source:
/** 
 * @param sortedKeyArray
 * @param startOffset
 * @param level
 * @param sonLevelTotalNumber
 * @return
 * @throws IOException
 */
private IDiskArray writeNonLeafNode(IDiskArray sortedKeyArray,IDiskArray startOffset,int level,int sonLevelTotalNumber) throws IOException {
  int interval=pow(degree,level);
  BufferedPrimitiveDiskArray sonStartOffset=new BufferedPrimitiveDiskArray(Math.min(Constants.LIST_BUFFER_SIZE,startOffset.size() / degree + 1));
  for (int i=0; i < startOffset.size(); i++) {
    if (i % degree == 0) {
      sonStartOffset.add(new Integer((int)documentObject.getFilePointer()));
    }
    if (i != startOffset.size() - 1) {
      documentObject.writeByte(degree);
      DocumentObjectUtil.writeValue(documentObject,keyDataType,((IndexKey)sortedKeyArray.get(i * interval)).key);
      DocumentObjectUtil.writeValue(documentObject,keyDataType,((IndexKey)sortedKeyArray.get((i + 1) * interval - 1)).key);
    }
 else {
      documentObject.writeByte(sonLevelTotalNumber - (startOffset.size() - 1) * degree);
      DocumentObjectUtil.writeValue(documentObject,keyDataType,((IndexKey)sortedKeyArray.get(i * interval)).key);
      DocumentObjectUtil.writeValue(documentObject,keyDataType,((IndexKey)sortedKeyArray.get(sortedKeyArray.size() - 1)).key);
    }
    documentObject.writeInt(((Integer)startOffset.get(i)).intValue());
  }
  return sonStartOffset;
}

Fixed version (ground truth):
/** 
 * @param sortedKeyArray
 * @param startOffset
 * @param level
 * @param sonLevelTotalNumber
 * @return
 * @throws IOException
 * @throws DataException 
 */
private IDiskArray writeNonLeafNode(IDiskArray sortedKeyArray,IDiskArray startOffset,int level,int sonLevelTotalNumber) throws IOException, DataException {
  int interval=pow(degree,level);
  BufferedPrimitiveDiskArray sonStartOffset=new BufferedPrimitiveDiskArray(Math.min(Constants.LIST_BUFFER_SIZE,startOffset.size() / degree + 1));
  for (int i=0; i < startOffset.size(); i++) {
    if (i % degree == 0) {
      sonStartOffset.add(new Integer((int)documentObject.getFilePointer()));
    }
    if (i != startOffset.size() - 1) {
      documentObject.writeByte(degree);
      DocumentObjectUtil.writeValue(documentObject,keyDataType,((IndexKey)sortedKeyArray.get(i * interval)).key);
      DocumentObjectUtil.writeValue(documentObject,keyDataType,((IndexKey)sortedKeyArray.get((i + 1) * interval - 1)).key);
    }
 else {
      documentObject.writeByte(sonLevelTotalNumber - (startOffset.size() - 1) * degree);
      DocumentObjectUtil.writeValue(documentObject,keyDataType,((IndexKey)sortedKeyArray.get(i * interval)).key);
      DocumentObjectUtil.writeValue(documentObject,keyDataType,((IndexKey)sortedKeyArray.get(sortedKeyArray.size() - 1)).key);
    }
    documentObject.writeInt(((Integer)startOffset.get(i)).intValue());
  }
  return sonStartOffset;
}
Program: 76174
Project: 76174
Buggy source:
/** 
 * @param keyObject
 * @throws IOException
 */
private void writeKeyObject(IndexKey keyObject) throws IOException {
  documentObject.writeInt(keyObject.dimensionPos);
  for (int i=0; i < keyDataType.length; i++) {
    DocumentObjectUtil.writeValue(documentObject,keyDataType[i],keyObject.key[i]);
  }
  documentObject.writeInt(keyObject.offset);
}

Fixed version (ground truth):
/** 
 * @param keyObject
 * @throws IOException
 * @throws DataException 
 */
private void writeKeyObject(IndexKey keyObject) throws IOException, DataException {
  documentObject.writeInt(keyObject.dimensionPos);
  for (int i=0; i < keyDataType.length; i++) {
    DocumentObjectUtil.writeValue(documentObject,keyDataType[i],keyObject.key[i]);
  }
  documentObject.writeInt(keyObject.offset);
}
Program: 76175
Project: 76175
Buggy source:
/** 
 * @param sortedKeyArray
 * @param interval
 * @return
 * @throws IOException
 */
private IDiskArray writeLeafNode(IDiskArray sortedKeyArray,int interval) throws IOException {
  BufferedPrimitiveDiskArray offset=new BufferedPrimitiveDiskArray(Constants.LIST_BUFFER_SIZE);
  for (int i=0; i < sortedKeyArray.size(); i++) {
    if (i % interval == 0) {
      offset.add(new Integer((int)documentObject.getFilePointer()));
    }
    offsetDocumentObject.writeInt((int)documentObject.getFilePointer());
    writeKeyObject((IndexKey)sortedKeyArray.get(i));
  }
  return offset;
}

Fixed version (ground truth):
/** 
 * @param sortedKeyArray
 * @param interval
 * @return
 * @throws IOException
 * @throws DataException 
 */
private IDiskArray writeLeafNode(IDiskArray sortedKeyArray,int interval) throws IOException, DataException {
  BufferedPrimitiveDiskArray offset=new BufferedPrimitiveDiskArray(Constants.LIST_BUFFER_SIZE);
  for (int i=0; i < sortedKeyArray.size(); i++) {
    if (i % interval == 0) {
      offset.add(new Integer((int)documentObject.getFilePointer()));
    }
    offsetDocumentObject.writeInt((int)documentObject.getFilePointer());
    writeKeyObject((IndexKey)sortedKeyArray.get(i));
  }
  return offset;
}
Program: 76176
Project: 76176
Buggy source:
/** 
 * @param cubeHandle
 * @param query
 * @param resultMetaList
 */
private void prepareMeasure(TabularCubeHandle cubeHandle,QueryDefinition query,List resultMetaList){
  List measureGroups=cubeHandle.getContents(CubeHandle.MEASURE_GROUPS_PROP);
  for (int i=0; i < measureGroups.size(); i++) {
    MeasureGroupHandle mgh=(MeasureGroupHandle)measureGroups.get(i);
    List measures=mgh.getContents(MeasureGroupHandle.MEASURES_PROP);
    for (int j=0; j < measures.size(); j++) {
      MeasureHandle measure=(MeasureHandle)measures.get(j);
      String function=measure.getFunction();
      if (query.getGroups().size() > 0) {
        ScriptExpression se=populateExpression(query,measure,function);
        query.addResultSetExpression(measure.getName(),se);
      }
 else {
        query.addResultSetExpression(measure.getName(),new ScriptExpression(measure.getMeasureExpression()));
      }
      ColumnMeta meta=new ColumnMeta(measure.getName());
      meta.setDataType(DataType.DOUBLE_TYPE);
      resultMetaList.add(meta);
    }
  }
}

Fixed version (ground truth):
/** 
 * @param cubeHandle
 * @param query
 * @param resultMetaList
 */
private void prepareMeasure(TabularCubeHandle cubeHandle,QueryDefinition query,List resultMetaList){
  List measureGroups=cubeHandle.getContents(CubeHandle.MEASURE_GROUPS_PROP);
  for (int i=0; i < measureGroups.size(); i++) {
    MeasureGroupHandle mgh=(MeasureGroupHandle)measureGroups.get(i);
    List measures=mgh.getContents(MeasureGroupHandle.MEASURES_PROP);
    for (int j=0; j < measures.size(); j++) {
      MeasureHandle measure=(MeasureHandle)measures.get(j);
      String function=measure.getFunction();
      if (query.getGroups().size() > 0) {
        ScriptExpression se=populateExpression(query,measure,function);
        query.addResultSetExpression(measure.getName(),se);
      }
 else {
        query.addResultSetExpression(measure.getName(),new ScriptExpression(measure.getMeasureExpression()));
      }
      ColumnMeta meta=new ColumnMeta(measure.getName());
      meta.setDataType(ModelAdapter.adaptModelDataType(measure.getDataType()));
      resultMetaList.add(meta);
    }
  }
}