@Test(dataProvider="canSetTests") public void testCanSetValue(TableType type, int rowIndex, int columnIndex, boolean isInsertRow, boolean isInsertColumn, boolean expected) { TableStructure structure = getTableStructure(type); assertEquals(structure.canSetValue(rowIndex, columnIndex, isInsertRow, isInsertColumn), expected); }
public boolean canSetValue(int rowIndex, int columnIndex, boolean isInsertRow, boolean isInsertColumn) { if (isInsertRow && isInsertColumn) { return false; } if (rowIndex < 0 || columnIndex < 0) { return false; } if (rowIndex > rowList.size() || columnIndex > columnCount) { return false; } if (type == TableType.ZERO_DIMENSIONAL) { return false; } if (type == TableType.ONE_DIMENSIONAL) { if (columnIndex != 0) { return false; } if (isInsertRow) { return 0<=rowIndex && rowIndex <= rowList.size(); } else { return 0<=rowIndex && rowIndex < rowList.size(); } } if (rowList.size() == 0) { return rowIndex==0 && columnIndex==0 && isInsertRow; } if (isInsertRow) { return columnIndex==0 && 0<=rowIndex && rowIndex <= getRowCount(); } if (rowIndex < 0 || rowIndex >= getRowCount()) { return false; } List<TableCell> row = rowList.get(rowIndex); if (isInsertColumn) { return 0<=columnIndex && columnIndex <= row.size(); } else { return 0<=columnIndex && columnIndex <= row.size() && columnIndex < columnCount; } }
TableStructure { public boolean canSetValue(int rowIndex, int columnIndex, boolean isInsertRow, boolean isInsertColumn) { if (isInsertRow && isInsertColumn) { return false; } if (rowIndex < 0 || columnIndex < 0) { return false; } if (rowIndex > rowList.size() || columnIndex > columnCount) { return false; } if (type == TableType.ZERO_DIMENSIONAL) { return false; } if (type == TableType.ONE_DIMENSIONAL) { if (columnIndex != 0) { return false; } if (isInsertRow) { return 0<=rowIndex && rowIndex <= rowList.size(); } else { return 0<=rowIndex && rowIndex < rowList.size(); } } if (rowList.size() == 0) { return rowIndex==0 && columnIndex==0 && isInsertRow; } if (isInsertRow) { return columnIndex==0 && 0<=rowIndex && rowIndex <= getRowCount(); } if (rowIndex < 0 || rowIndex >= getRowCount()) { return false; } List<TableCell> row = rowList.get(rowIndex); if (isInsertColumn) { return 0<=columnIndex && columnIndex <= row.size(); } else { return 0<=columnIndex && columnIndex <= row.size() && columnIndex < columnCount; } } }
TableStructure { public boolean canSetValue(int rowIndex, int columnIndex, boolean isInsertRow, boolean isInsertColumn) { if (isInsertRow && isInsertColumn) { return false; } if (rowIndex < 0 || columnIndex < 0) { return false; } if (rowIndex > rowList.size() || columnIndex > columnCount) { return false; } if (type == TableType.ZERO_DIMENSIONAL) { return false; } if (type == TableType.ONE_DIMENSIONAL) { if (columnIndex != 0) { return false; } if (isInsertRow) { return 0<=rowIndex && rowIndex <= rowList.size(); } else { return 0<=rowIndex && rowIndex < rowList.size(); } } if (rowList.size() == 0) { return rowIndex==0 && columnIndex==0 && isInsertRow; } if (isInsertRow) { return columnIndex==0 && 0<=rowIndex && rowIndex <= getRowCount(); } if (rowIndex < 0 || rowIndex >= getRowCount()) { return false; } List<TableCell> row = rowList.get(rowIndex); if (isInsertColumn) { return 0<=columnIndex && columnIndex <= row.size(); } else { return 0<=columnIndex && columnIndex <= row.size() && columnIndex < columnCount; } } TableStructure(TableType type, AbstractComponent rootComponent); }
TableStructure { public boolean canSetValue(int rowIndex, int columnIndex, boolean isInsertRow, boolean isInsertColumn) { if (isInsertRow && isInsertColumn) { return false; } if (rowIndex < 0 || columnIndex < 0) { return false; } if (rowIndex > rowList.size() || columnIndex > columnCount) { return false; } if (type == TableType.ZERO_DIMENSIONAL) { return false; } if (type == TableType.ONE_DIMENSIONAL) { if (columnIndex != 0) { return false; } if (isInsertRow) { return 0<=rowIndex && rowIndex <= rowList.size(); } else { return 0<=rowIndex && rowIndex < rowList.size(); } } if (rowList.size() == 0) { return rowIndex==0 && columnIndex==0 && isInsertRow; } if (isInsertRow) { return columnIndex==0 && 0<=rowIndex && rowIndex <= getRowCount(); } if (rowIndex < 0 || rowIndex >= getRowCount()) { return false; } List<TableCell> row = rowList.get(rowIndex); if (isInsertColumn) { return 0<=columnIndex && columnIndex <= row.size(); } else { return 0<=columnIndex && columnIndex <= row.size() && columnIndex < columnCount; } } TableStructure(TableType type, AbstractComponent rootComponent); void notifyTableStructureChanged(); int getRowCount(); int getColumnCount(); boolean isSkeleton(); AbstractComponent getValue(int rowIndex, int columnIndex); void setValue(int rowIndex, int columnIndex, boolean isInsertRow, boolean isInsertColumn, AbstractComponent value); boolean canSetValue(int rowIndex, int columnIndex, boolean isInsertRow, boolean isInsertColumn); AbstractComponent getModifiedComponent(int rowIndex, int columnIndex, boolean isInsertRow, boolean isInsertColumn); TableType getType(); }
TableStructure { public boolean canSetValue(int rowIndex, int columnIndex, boolean isInsertRow, boolean isInsertColumn) { if (isInsertRow && isInsertColumn) { return false; } if (rowIndex < 0 || columnIndex < 0) { return false; } if (rowIndex > rowList.size() || columnIndex > columnCount) { return false; } if (type == TableType.ZERO_DIMENSIONAL) { return false; } if (type == TableType.ONE_DIMENSIONAL) { if (columnIndex != 0) { return false; } if (isInsertRow) { return 0<=rowIndex && rowIndex <= rowList.size(); } else { return 0<=rowIndex && rowIndex < rowList.size(); } } if (rowList.size() == 0) { return rowIndex==0 && columnIndex==0 && isInsertRow; } if (isInsertRow) { return columnIndex==0 && 0<=rowIndex && rowIndex <= getRowCount(); } if (rowIndex < 0 || rowIndex >= getRowCount()) { return false; } List<TableCell> row = rowList.get(rowIndex); if (isInsertColumn) { return 0<=columnIndex && columnIndex <= row.size(); } else { return 0<=columnIndex && columnIndex <= row.size() && columnIndex < columnCount; } } TableStructure(TableType type, AbstractComponent rootComponent); void notifyTableStructureChanged(); int getRowCount(); int getColumnCount(); boolean isSkeleton(); AbstractComponent getValue(int rowIndex, int columnIndex); void setValue(int rowIndex, int columnIndex, boolean isInsertRow, boolean isInsertColumn, AbstractComponent value); boolean canSetValue(int rowIndex, int columnIndex, boolean isInsertRow, boolean isInsertColumn); AbstractComponent getModifiedComponent(int rowIndex, int columnIndex, boolean isInsertRow, boolean isInsertColumn); TableType getType();  }