Class DataView
java.lang.Object
com.github.martincooper.datatable.DataView
- All Implemented Interfaces:
IBaseTable,IQuickSort,Iterable<DataRow>
DataView. Provides a view over a DataTable to store filtered data sets.
Created by Martin Cooper on 19/07/2017.
-
Method Summary
Modifier and TypeMethodDescriptionstatic io.vavr.control.Try<DataView>Builds an instance of a DataView.Accessor to a specific column by index.Accessor to a specific column by name.columns()Filters the row data using the specified predicate, returning the results as a DataView over the original table.<U> io.vavr.collection.Seq<U>FlatMap implementation for the DataRowCollection class.<U> UfoldLeft(U zero, BiFunction<? super U, ? super DataRow, ? extends U> folder) Fold Left implementation for the DataRowCollection class.<U> UfoldRight(U zero, BiFunction<? super DataRow, ? super U, ? extends U> folder) Fold Right implementation for the DataRowCollection class.<C> io.vavr.collection.Map<C,io.vavr.collection.Vector<DataRow>> GroupBy implementation for the DataRowCollection class.iterator()Returns an iterator over elements of type DataRow.<U> io.vavr.collection.Seq<U>Map operation across the Data Rows in the table.name()io.vavr.control.Try<DataView>Table QuickSort by single sort item.io.vavr.control.Try<DataView>Table QuickSort by single column index.io.vavr.control.Try<DataView>Table QuickSort by single column index and a sort order.io.vavr.control.Try<DataView>Table QuickSort by multiple sort items.io.vavr.control.Try<DataView>Table QuickSort by single column name.io.vavr.control.Try<DataView>Table QuickSort by single column name and a sort order.reduce(BiFunction<? super DataRow, ? super DataRow, ? extends DataRow> reducer) Reduce implementation for the DataRowCollection class.Accessor to a specific row by index.rowCount()Returns the rowCount / row count of the table.rows()Return a new DataTable based on this table (clone).Return a new Data View based on this tableMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Method Details
-
iterator
Returns an iterator over elements of type DataRow. -
name
- Specified by:
namein interfaceIBaseTable- Returns:
- Returns the table name.
-
columns
- Specified by:
columnsin interfaceIBaseTable- Returns:
- Returns the columns collection.
-
rows
- Specified by:
rowsin interfaceIBaseTable- Returns:
- Returns the row collection.
-
row
Accessor to a specific row by index.- Specified by:
rowin interfaceIBaseTable- Parameters:
rowIdx- The index of the row to return.- Returns:
- Returns a single row.
-
column
Accessor to a specific column by index.- Parameters:
colIdx- The index of the column to return.- Returns:
- Returns a single column.
-
column
Accessor to a specific column by name.- Parameters:
colName- The name of the column to return.- Returns:
- Returns a single column.
-
rowCount
Returns the rowCount / row count of the table.- Specified by:
rowCountin interfaceIBaseTable- Returns:
- The row count of the table.
-
toDataTable
Return a new DataTable based on this table (clone).- Specified by:
toDataTablein interfaceIBaseTable- Returns:
- Returns a new DataTable based on the columns and data in this view.
-
toDataView
Return a new Data View based on this table- Specified by:
toDataViewin interfaceIBaseTable- Returns:
- A new Data View based on this table.
-
filter
Filters the row data using the specified predicate, returning the results as a DataView over the original table.- Parameters:
predicate- The filter criteria.- Returns:
- Returns a DataView with the filter results.
-
map
Map operation across the Data Rows in the table.- Type Parameters:
U- The return type.- Parameters:
mapper- The mapper function.- Returns:
- Returns the mapped results.
-
flatMap
public <U> io.vavr.collection.Seq<U> flatMap(Function<? super DataRow, ? extends Iterable<? extends U>> mapper) FlatMap implementation for the DataRowCollection class.- Type Parameters:
U- Mapped return type.- Parameters:
mapper- The map function.- Returns:
- Returns a sequence of the applied flatMap.
-
reduce
Reduce implementation for the DataRowCollection class.- Parameters:
reducer- The reduce function.- Returns:
- Returns a single, reduced DataRow.
-
groupBy
public <C> io.vavr.collection.Map<C,io.vavr.collection.Vector<DataRow>> groupBy(Function<? super DataRow, ? extends C> grouper) GroupBy implementation for the DataRowCollection class.- Parameters:
grouper- The group by function.- Returns:
- Returns a map containing the grouped data.
-
foldLeft
Fold Left implementation for the DataRowCollection class.- Type Parameters:
U- Fold return type.- Parameters:
folder- The fold function.- Returns:
- Returns a single value of U.
-
foldRight
Fold Right implementation for the DataRowCollection class.- Type Parameters:
U- Fold return type.- Parameters:
folder- The fold function.- Returns:
- Returns a single value of U.
-
quickSort
Table QuickSort by single column name.- Specified by:
quickSortin interfaceIQuickSort- Parameters:
columnName- The column name to sort.- Returns:
- Returns the results as a sorted Data View.
-
quickSort
Table QuickSort by single column name and a sort order.- Specified by:
quickSortin interfaceIQuickSort- Parameters:
columnName- The column name to sort.sortOrder- The sort order.- Returns:
- Returns the results as a sorted Data View.
-
quickSort
Table QuickSort by single column index.- Specified by:
quickSortin interfaceIQuickSort- Parameters:
columnIndex- The column index to sort.- Returns:
- Returns the results as a sorted Data View.
-
quickSort
Table QuickSort by single column index and a sort order.- Specified by:
quickSortin interfaceIQuickSort- Parameters:
columnIndex- The column index to sort.sortOrder- The sort order.- Returns:
- Returns the results as a sorted Data View.
-
quickSort
Table QuickSort by single sort item.- Specified by:
quickSortin interfaceIQuickSort- Parameters:
sortItem- The sort item.- Returns:
- Returns the results as a sorted Data View.
-
quickSort
Table QuickSort by multiple sort items.- Specified by:
quickSortin interfaceIQuickSort- Parameters:
sortItems- The sort items.- Returns:
- Returns the results as a sorted Data View.
-
build
Builds an instance of a DataView. DataRows are validated before creation, returning a Failure on error.- Parameters:
table- The underlying table.rows- The Data Rows.- Returns:
- Returns a DataView wrapped in a Try.
-