TableSlice extends Relation { @Override public Column<?> column(int columnIndex) { Column<?> col = table.column(columnIndex); if (isSorted()) { return col.subset(sortOrder); } else if (hasSelection()) { return col.where(selection); } return col; } TableSlice(Table table, Selection rowSelection);  TableSlice(Table table); @Override Column<?> column(int columnIndex); @Override Column<?> column(String columnName); @Override int columnCount(); @Override int rowCount(); @Override List<Column<?>> columns(); @Override int columnIndex(Column<?> column); @Override Object get(int r, int c); @Override String name(); Table getTable(); @Override void clear(); void removeSort(); void removeSelection(); @Override List<String> columnNames(); @Override TableSlice addColumns(Column<?>... column); @Override TableSlice removeColumns(Column<?>... columns); @Override Table first(int nRows); @Override TableSlice setName(String name); Table asTable(); double reduce(String numberColumnName, NumericAggregateFunction function); @Override Iterator<Row> iterator(); int mappedRowNumber(int rowNumber); void sortOn(Sort key);  }
@Test public void column() { TableSlice slice = new TableSlice(source, Selection.withRange(0, 4)); assertEquals(source.column(1).name(), slice.column(1).name()); assertTrue(source.rowCount() > slice.column(1).size()); assertEquals(source.column("date").name(), slice.column("date").name()); assertTrue(source.rowCount() > slice.column("date").size()); assertEquals(slice.column(1).size(), slice.column("date").size()); assertEquals(4, slice.column("date").size()); }
@Test public void columnNoSortNoSelection() { TableSlice tableSlice = new TableSlice(source); assertEquals(tableSlice.column("approval").asList(), source.column("approval").asList()); }