Program: 36977
Project: 36977
Buggy source:
/** 
 * Parses table, makes matrix of cells and put it into Article object
 * @param article - Article to populate
 * @param parse - Document which is being parsed
 * @return populated Article
 */
public Article ParseTables(Article article,Document parse){
  NodeList tablesxml=parse.getElementsByTagName("String_Node_Str");
  int numOfTables=getNumOfTablesInArticle(tablesxml);
  Table[] tables=new Table[numOfTables];
  article.setTables(tables);
  int tableindex=0;
  for (int i=0; i < tablesxml.getLength(); i++) {
    List<Node> inline_formula=null;
    if ((inline_formula != null && inline_formula.size() == 0) || inline_formula == null) {
      Statistics.addTable();
      String label="String_Node_Str" + tableindex;
      tables[tableindex]=new Table(label);
      tables[tableindex].setDocumentFileName("String_Node_Str" + article.getSpec_id());
      tables[tableindex].setXml(Utilities.CreateXMLStringFromSubNode(tablesxml.item(i)));
      System.out.println("String_Node_Str" + tables[tableindex].getTable_title());
      String caption=readTableLabel(tablesxml.item(i));
      tables[tableindex].setTable_caption(caption);
      String foot=ReadTableFooter(tablesxml.item(i));
      tables[tableindex].setTable_footer(foot);
      System.out.println("String_Node_Str" + foot);
      int headsize=0;
      List<Node> thead=null;
      if (tablesxml.getLength() > 0) {
        thead=getChildrenByTagName(tablesxml.item(0),"String_Node_Str");
        headsize=thead.size();
      }
      List<Node> rowshead=null;
      if (headsize > 0) {
        rowshead=getChildrenByTagName(thead.get(0),"String_Node_Str");
      }
 else {
        tables[tableindex].setHasHeader(false);
        Statistics.TableWithoutHead();
      }
      List<Node> tbody=getChildrenByTagName(tablesxml.item(0),"String_Node_Str");
      if (tbody.size() == 0) {
        Statistics.TableWithoutBody();
        tables[tableindex].setHasBody(false);
        tableindex++;
        continue;
      }
      List<Node> rowsbody=getChildrenByTagName(tbody.get(0),"String_Node_Str");
      int headrowscount=0;
      if (rowshead != null)       headrowscount=rowshead.size();
      int num_of_rows=rowsbody.size() + headrowscount;
      int cols=CountColumns(rowsbody,rowshead);
      int num_of_columns=cols;
      tables[tableindex].setNum_of_columns(num_of_columns);
      tables[tableindex].setNum_of_rows(num_of_rows);
      tables[tableindex].CreateCells(num_of_columns,num_of_rows);
      Cell[][] cells=tables[tableindex].getTable_cells();
      tables[tableindex]=ProcessTableHeader(article,tables[tableindex],cells,rowshead,headrowscount,num_of_columns);
      Statistics.addColumn(num_of_columns);
      Statistics.addRow(num_of_rows);
      tables[tableindex]=ProcessTableBody(article,tables[tableindex],cells,rowsbody,headrowscount,num_of_columns);
      tables[tableindex].setTable_cells(cells);
      for (int j=0; j < cells.length; j++) {
        for (int k=0; k < cells[j].length; k++) {
          System.out.println(j + "String_Node_Str" + k+ "String_Node_Str"+ cells[j][k].getCell_content());
        }
      }
      System.out.println("String_Node_Str" + num_of_rows);
      System.out.println("String_Node_Str" + num_of_columns);
      tableindex++;
    }
  }
  return article;
}

Fixed version (ground truth):
/** 
 * Parses table, makes matrix of cells and put it into Article object
 * @param article - Article to populate
 * @param parse - Document which is being parsed
 * @return populated Article
 */
public Article ParseTables(Article article,Document parse){
  NodeList tablesxml=parse.getElementsByTagName("String_Node_Str");
  int numOfTables=getNumOfTablesInArticle(tablesxml);
  Table[] tables=new Table[numOfTables];
  article.setTables(tables);
  int tableindex=0;
  for (int i=0; i < tablesxml.getLength(); i++) {
    List<Node> inline_formula=null;
    if ((inline_formula != null && inline_formula.size() == 0) || inline_formula == null) {
      Statistics.addTable();
      String label="String_Node_Str" + tableindex;
      tables[tableindex]=new Table(label);
      tables[tableindex].setDocumentFileName("String_Node_Str" + article.getSpec_id());
      tables[tableindex].setXml(Utilities.CreateXMLStringFromSubNode(tablesxml.item(i)));
      System.out.println("String_Node_Str" + tables[tableindex].getTable_title());
      String caption=readTableLabel(tablesxml.item(i));
      tables[tableindex].setTable_caption(caption);
      try {
        Node sibling=tablesxml.item(i).getParentNode().getPreviousSibling();
        System.out.println(sibling.getTextContent());
        while (sibling != null) {
          sibling=sibling.getPreviousSibling();
          if (sibling.getNodeName() == "String_Node_Str") {
            tables[tableindex].setSectionOfTable(sibling.getTextContent().replaceAll("String_Node_Str","String_Node_Str").replaceAll("String_Node_Str","String_Node_Str"));
            break;
          }
        }
      }
 catch (      Exception ex) {
        ex.printStackTrace();
        System.out.println("String_Node_Str");
      }
      System.out.println(tables[tableindex].getSectionOfTable());
      String foot=ReadTableFooter(tablesxml.item(i));
      tables[tableindex].setTable_footer(foot);
      System.out.println("String_Node_Str" + foot);
      int headsize=0;
      List<Node> thead=null;
      if (tablesxml.getLength() > 0) {
        thead=getChildrenByTagName(tablesxml.item(i),"String_Node_Str");
        headsize=thead.size();
      }
      List<Node> rowshead=null;
      if (headsize > 0) {
        rowshead=getChildrenByTagName(thead.get(0),"String_Node_Str");
      }
 else {
        tables[tableindex].setHasHeader(false);
        Statistics.TableWithoutHead();
      }
      List<Node> tbody=getChildrenByTagName(tablesxml.item(i),"String_Node_Str");
      if (tbody.size() == 0) {
        Statistics.TableWithoutBody();
        tables[tableindex].setHasBody(false);
        tableindex++;
        continue;
      }
      List<Node> rowsbody=getChildrenByTagName(tbody.get(0),"String_Node_Str");
      int headrowscount=0;
      if (rowshead != null)       headrowscount=rowshead.size();
      int num_of_rows=rowsbody.size() + headrowscount;
      int cols=CountColumns(rowsbody,rowshead);
      int num_of_columns=cols;
      tables[tableindex].setNum_of_columns(num_of_columns);
      tables[tableindex].setNum_of_rows(num_of_rows);
      tables[tableindex].CreateCells(num_of_columns,num_of_rows);
      Cell[][] cells=tables[tableindex].getTable_cells();
      tables[tableindex]=ProcessTableHeader(article,tables[tableindex],cells,rowshead,headrowscount,num_of_columns);
      Statistics.addColumn(num_of_columns);
      Statistics.addRow(num_of_rows);
      tables[tableindex]=ProcessTableBody(article,tables[tableindex],cells,rowsbody,headrowscount,num_of_columns);
      tables[tableindex].setTable_cells(cells);
      for (int j=0; j < cells.length; j++) {
        for (int k=0; k < cells[j].length; k++) {
          System.out.println(j + "String_Node_Str" + k+ "String_Node_Str"+ cells[j][k].getCell_content());
        }
      }
      System.out.println("String_Node_Str" + num_of_rows);
      System.out.println("String_Node_Str" + num_of_columns);
      tableindex++;
    }
  }
  return article;
}