DataTable extends AbstractDataSource implements MutableDataSource { public Comparable<?> get(int col, int row) { Record r; synchronized (rows) { if (row >= rows.size()) { return null; } r = rows.get(row); } if (r == null) { return null; } return r.get(col); } DataTable();  DataTable(Class<? extends Comparable<?>>... types); @SuppressWarnings("unchecked")  DataTable(int cols, Class<? extends Comparable<?>> type);  DataTable(DataSource source);  DataTable(Column... columns); int add(Comparable<?>... values); int add(List<? extends Comparable<?>> values); int add(Row row); void add(Record row); void remove(int row); void removeLast(); void clear(); Comparable<?> get(int col, int row); @SuppressWarnings("unchecked") Comparable<T> set(int col, int row, Comparable<T> value); int getRowCount(); void sort(final DataComparator... comparators); @Override void setName(String name);  }
@Test public void testDataTableCreatedFromColumnsContainsValuesInColumnOrder() { int someRowIndex = 1; DataSource firstColumnData = new DummyData(1, someRowIndex + 1, 1.0); Column<?> firstColumn = firstColumnData.getColumn(0); DataSource secondColumnData = new DummyData(1, someRowIndex + 1, 2.0); Column<?> secondColumn = secondColumnData.getColumn(0); DataSource table = new DataTable(firstColumn, secondColumn); assertThat(table.getRecord(1), CoreMatchers.<Comparable<?>>hasItems(firstColumn.get(someRowIndex), secondColumn.get(someRowIndex))); }
@Test public void testGetIntInt() { assertEquals(6, table.get(1, 3)); assertEquals(5, table.get(0, 4)); assertEquals(1, table.get(0, 0)); assertEquals(11, table.get(1, 7)); }
@Test public void testIterator() { int i = 0; int colCount = table.getColumnCount(); for (Comparable<?> cell : table) { int col = i % colCount; int row = i / colCount; Comparable<?> expected = table.get(col, row); assertEquals(expected, cell); i++; } }