Package de.xima.fc.common.data.table
Class AbstractHeaderTable<T>
- java.lang.Object
-
- de.xima.fc.common.data.table.AbstractHeaderTable<T>
-
- Type Parameters:
T
- The type of the cell values.
- All Implemented Interfaces:
IHeaderTable<T>
,Serializable
,Iterable<IHeaderTable.ITableRowEntry<T>>
- Direct Known Subclasses:
ImmutableListHeaderTable
public abstract class AbstractHeaderTable<T> extends Object implements IHeaderTable<T>, Serializable
Abstract implementation ofIHeaderTable
. Implements all methods that can be derived from other methods. You only need to implementIHeaderTable.columnNames()
andIHeaderTable.rows()
. You should also implementcolumnToIndex(String)
andhasColumn(String)
for performance reasons. All other methods cannot are final and cannot be overridden.- Since:
- 8.2.0
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface de.xima.fc.common.data.table.IHeaderTable
IHeaderTable.ITableRowEntry<T>
-
-
Constructor Summary
Constructors Constructor Description AbstractHeaderTable()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description T
cell(int row, int column)
Gets the value at the given row and column.T
cell(int row, String column)
Gets the value at the given row and column.int
columnCount()
Returns the number of columns in the table.Map<Integer,T>
columnsByIndex(int row)
Gets a view of the given row as a map.Map<String,T>
columnsByName(int row)
Gets a view of the given row as a map.int
columnToIndex(String column)
Converts a column name to an index.boolean
equals(Object obj)
boolean
hasColumn(int column)
Checks if the table has a column at the given index.boolean
hasColumn(String column)
Checks if the table has a column with the given name.int
hashCode()
boolean
hasRow(int row)
Checks if the table has a row at the given index.String
indexToColumn(int index)
Converts an index to a column name.List<T>
row(int index)
Returns a view of the given row.int
rowCount()
Returns the number of rows in the table.Iterator<IHeaderTable.ITableRowEntry<T>>
rowIterator()
Returns an iterator over the rows of the table.List<T>
rows(int column)
Returns a view of all rows at the given column.List<T>
rows(String column)
Returns a view of all rows at the given column.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface de.xima.fc.common.data.table.IHeaderTable
columnNames, iterator, rows
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Method Detail
-
cell
public final T cell(int row, String column)
Description copied from interface:IHeaderTable
Gets the value at the given row and column.- Specified by:
cell
in interfaceIHeaderTable<T>
- Parameters:
row
- The row index.column
- The column name.- Returns:
- The value at the given row and column.
-
cell
public final T cell(int row, int column)
Description copied from interface:IHeaderTable
Gets the value at the given row and column.- Specified by:
cell
in interfaceIHeaderTable<T>
- Parameters:
row
- The row index.column
- The column index.- Returns:
- The value at the given row and column.
-
columnCount
public final int columnCount()
Description copied from interface:IHeaderTable
Returns the number of columns in the table.- Specified by:
columnCount
in interfaceIHeaderTable<T>
- Returns:
- The number of columns.
-
columnToIndex
public int columnToIndex(String column)
Description copied from interface:IHeaderTable
Converts a column name to an index.- Specified by:
columnToIndex
in interfaceIHeaderTable<T>
- Parameters:
column
- The column name.- Returns:
- The index of the column.
-
columnsByIndex
public final Map<Integer,T> columnsByIndex(int row)
Description copied from interface:IHeaderTable
Gets a view of the given row as a map. The keys are the column indices.- Specified by:
columnsByIndex
in interfaceIHeaderTable<T>
- Parameters:
row
- Index of a row.- Returns:
- A view of the given row as a map.
-
columnsByName
public final Map<String,T> columnsByName(int row)
Description copied from interface:IHeaderTable
Gets a view of the given row as a map. The keys are the column names.- Specified by:
columnsByName
in interfaceIHeaderTable<T>
- Parameters:
row
- Index of a row.- Returns:
- A view of the given row as a map.
-
hasColumn
public final boolean hasColumn(int column)
Description copied from interface:IHeaderTable
Checks if the table has a column at the given index.- Specified by:
hasColumn
in interfaceIHeaderTable<T>
- Parameters:
column
- The name of the column.- Returns:
true
if the table has a column at the given index,false
otherwise.
-
hasColumn
public boolean hasColumn(String column)
Description copied from interface:IHeaderTable
Checks if the table has a column with the given name.- Specified by:
hasColumn
in interfaceIHeaderTable<T>
- Parameters:
column
- The name of the column.- Returns:
true
if the table has a column with the given name,false
otherwise.
-
hasRow
public final boolean hasRow(int row)
Description copied from interface:IHeaderTable
Checks if the table has a row at the given index.- Specified by:
hasRow
in interfaceIHeaderTable<T>
- Parameters:
row
- The index of the row.- Returns:
true
if the table has a row at the given index,false
otherwise.
-
indexToColumn
public final String indexToColumn(int index)
Description copied from interface:IHeaderTable
Converts an index to a column name.- Specified by:
indexToColumn
in interfaceIHeaderTable<T>
- Parameters:
index
- The index of the column.- Returns:
- The column name.
-
row
public final List<T> row(int index)
Description copied from interface:IHeaderTable
Returns a view of the given row. The list will have the same number of elements as there are columns in the table.- Specified by:
row
in interfaceIHeaderTable<T>
- Parameters:
index
- The index of the row.- Returns:
- A view of the given row.
-
rowCount
public final int rowCount()
Description copied from interface:IHeaderTable
Returns the number of rows in the table.- Specified by:
rowCount
in interfaceIHeaderTable<T>
- Returns:
- The number of rows.
-
rowIterator
public final Iterator<IHeaderTable.ITableRowEntry<T>> rowIterator()
Description copied from interface:IHeaderTable
Returns an iterator over the rows of the table.- Specified by:
rowIterator
in interfaceIHeaderTable<T>
- Returns:
- An iterator over the rows of the table.
-
rows
public final List<T> rows(String column)
Description copied from interface:IHeaderTable
Returns a view of all rows at the given column. The list will have the same number of elements as there are rows.- Specified by:
rows
in interfaceIHeaderTable<T>
- Parameters:
column
- The name of the column.- Returns:
- A view of all rows at the given column.
-
rows
public final List<T> rows(int column)
Description copied from interface:IHeaderTable
Returns a view of all rows at the given column. The list will have the same number of elements as there are rows.- Specified by:
rows
in interfaceIHeaderTable<T>
- Parameters:
column
- The index of the column.- Returns:
- A view of all rows at the given column.
-
-