/** * get cell value by row/column index(only string is supported) * * @param rowIndex * @param colIndex * @return */ public String getCell(int rowIndex, int colIndex) { checkRowArgument(rowIndex); checkColArgument(colIndex); if (dataTable.getCell(rowIndex, colIndex) == null) { System.out.println("there no content in specified cell"); return null; } return dataTable.getCell(rowIndex, colIndex).toString(); }
/** * return the value by key , for the table only contains 2 columns , the first column is regarded * as key column, and the second is value column * * @param key * @param val * @return */ public boolean doesKeyValueExist(String key, String val) { for (int row = 0; row < dataTable.getRowCount(); ++row) { if (!key.equals(dataTable.getCell(row, 0))) { continue; } else { if (val.equals(dataTable.getCell(row, 1))) { return true; } else { return false; } } } return false; }
/** Print the table content */ public void printTable() { for (int row = 0; row < dataTable.getRowCount(); ++row) { for (int col = 0; col < dataTable.getColumnCount(); ++col) { System.out.print("<>" + dataTable.getCell(row, col) + " "); } } }