C
- R
- public class Table<C,R>
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
class |
Table.Col
A column of the table
|
static interface |
Table.Formatter<C,R>
Formatter; converts table entries when printing.
|
static class |
Table.NumberFormatGenerator |
static class |
Table.Sorter<C>
Implements a sort of rows based on the natural order of the various table
cols.
|
static class |
Table.TransformFormatter<C,R>
Adapter to convert a Transform into a Formatter
|
Constructor and Description |
---|
Table() |
Table(Table<C,R> t)
Construct a duplicate of the supplied table
|
Modifier and Type | Method and Description |
---|---|
void |
add(Table<C,R> t)
Add contents of existing table
|
void |
addAttribute(C col,
R row,
java.lang.String name,
java.lang.String value)
add attribute to a single cell.
|
void |
addCategoryTotals(C sum_col,
C cat_Col,
Transform cat_to_key)
Generate a series of column sums grouped into categories based on the
values of a different column.
|
void |
addCategoryTotals(C sum_col,
C cat_Col,
Transform cat_to_key,
C label_col,
java.lang.Boolean highlight)
Generate a series of column sums grouped into categories based on the
values of a different column.
|
void |
addCategoryTotalToCol(C sum_col,
C cat_Col) |
void |
addCategoryTotalToCol(C sum_col,
C cat_Col,
java.util.Map selection)
Generate sums of a column based on categories provided by a different
column.
|
void |
addColAttribute(C col,
java.lang.String name,
java.lang.String value)
Add attribute to all cells in col
|
<X> void |
addColumnAsRow(R row_key,
X col_key,
Table<X,C> t)
Take a column from one table and add it as a row
to this one.
|
void |
addMap(C col_name,
java.util.Map<R,?> data)
Add a
Map of data into a column
If the data is a Number it is accumulated. |
void |
addMap(C col_name,
java.util.Map<R,R> row_mapping,
java.util.Map<R,?> data)
Add a
Map of data into a column
If the data is a Number it is accumulated. |
java.lang.Object |
addNumber(C col_key,
R row_key,
java.lang.Number value) |
void |
addPercentCol(C old_name,
C new_name)
Add a column containing the percentage of the values from an existing
column against the total of that column
|
void |
addPercentCol(C old_name,
C new_name,
java.lang.Double sum)
add a column giving the percentage of a columns values against a
specified total.
|
void |
addPercentCol(C old_name,
C new_name,
java.lang.Double sum,
java.text.NumberFormat nf) |
void |
addPercentCol(C old_name,
C new_name,
java.text.NumberFormat nf)
Add a column containing the percentage of the values from an existing
column against the total of that column
|
void |
addRow(R key) |
void |
addRow(R key,
java.util.Map<C,java.lang.Object> data)
Add a Map as a table row using the map keys
to set the columns
|
void |
addRows(Table<C,R> t)
Add rows (including formatting) from a table.
|
<X> void |
addTable(C key_col,
Table<C,X> donor)
Add contents from donor table taking the keys to use from a Column in
the donor table.
|
<X> void |
addTable(Transform key_transform,
Table<C,X> donor)
Add contents from donor table transforming the keys
|
void |
addToGroup(C group,
C col) |
java.lang.Double |
addTotalToCol(C col_name,
R key)
Add a totals entry to column
This is a noop if the specified col does not exist
|
void |
addTotalToCol(int col_index,
R key)
Add a totals entry to a column
|
void |
colOperation(C result_col,
Operator op,
C left_col,
C right_col) |
java.util.Collection<C> |
cols()
Deprecated.
|
boolean |
containsCol(C col_name)
Do we have a col of this name
|
java.lang.Object |
get(C col_key,
R row_key) |
java.util.Map<java.lang.String,java.lang.String> |
getAttributes(C col_key,
R row_key) |
Table.Col |
getCol(C col_key)
Find or create a col by key
|
Table.Formatter |
getColFormat(C col_key) |
java.util.List<C> |
getCols()
Get a copy of the list of col keys.
|
java.util.List<C> |
getColumNames() |
java.lang.Iterable<C> |
getColumnGroup(C name) |
java.lang.Iterable<C> |
getColumnGroups()
get all the defined Column Groups
|
java.util.Hashtable<java.lang.String,java.lang.Number> |
getHashtable(C col_key) |
java.util.Hashtable<java.lang.String,java.lang.Number> |
getHashtable(C col_key,
C label_key)
get a hashtable of the contents of one Col keyed by the contents of
another
|
boolean |
getHighlight(R row_key)
should we highlight this row.
|
java.lang.String |
getId() |
java.lang.String |
getKeyName() |
java.lang.Object |
getKeyText(R key)
Convert a row key into printable text
|
java.lang.Number |
getNumber(C col_key,
R row_key) |
java.util.List<R> |
getRows()
Get a copy of the list of row keys.
|
java.lang.String |
getString()
get the table as a pure String
|
java.lang.String |
getText(C col_key,
R row_key) |
java.lang.String |
getText(java.text.NumberFormat nf,
C col_key,
R row_key) |
boolean |
getWarning(R row_key)
should we mark this row with warning highlight.
|
boolean |
hasCol(java.lang.String string) |
boolean |
hasColFormat(C col_name) |
boolean |
hasColumnGroup(C name) |
boolean |
hasData() |
boolean |
hasRow(R key) |
java.lang.Object |
increment(C col_key,
R row_key,
int value)
increment a integer entry
|
boolean |
isPrintHeadings() |
int |
nCols() |
int |
nRows() |
void |
packAllColumnGroups()
For all column groups.
|
void |
packColumnGroup(C name)
place all members of a column group after the first member of the group.
|
boolean |
printKeys()
Should the table keys be printed as part of the table.
|
java.lang.Object |
put(C col_key,
R row_key,
java.lang.Object value) |
java.lang.Object |
putAfter(C col_key,
R row_key,
R after,
java.lang.Object value) |
void |
removeCol(C key)
remove a col from display data is retained and will return if key is
replaced.
|
void |
removeRow(R key) |
void |
rowOperation(R result_row,
Operator op,
R left_row,
R right_row) |
java.util.Collection<R> |
rows()
Deprecated.
|
void |
rowToString(R row_name)
convert all elements in a row to strings so they don't count against
additional col totals
|
void |
setCategoryRow(C target_col,
C cat_Col,
Transform cat_to_key,
Transform cat_to_val) |
void |
setCol(C key,
int ind)
Set col to specified position
|
void |
setColAfter(C first,
C after)
set one col to follow another
|
Table.Formatter<C,R> |
setColFormat(C col_name,
Table.Formatter<C,R> t) |
Table.Formatter |
setColFormat(C col_name,
Transform t) |
void |
setColLast(C key)
set col to last position
|
void |
setColName(C key,
java.lang.String name) |
void |
setColumns(java.util.List<C> v) |
void |
setFormat(Table.Formatter<C,R> t)
Set a printing format for all columns
|
void |
setFormat(Transform t) |
void |
setHighlight(R row_key,
boolean value)
mark a row to be highlighted
|
void |
setId(java.lang.String id) |
void |
setKeyName(java.lang.String keyName)
Set the column name for the keys column this also causes the key column
to be printed
|
void |
setKeyTransform(Transform t)
Set a Transform used to print the keys.
|
void |
setPrintHeadings(boolean printHeadings) |
void |
setRow(R key,
int ind)
set row to specified position
|
void |
setRowAfter(R key,
R after) |
void |
setRowLast(R key)
set row to last position
|
void |
setTypeDebug(boolean flag)
add Java type information to output for debugging purposes.
|
void |
setWarning(R row_key,
boolean value)
mark a row to be highlighted
|
void |
sortCols(java.util.Comparator c)
Sort columns according to a specified comparator
|
void |
sortRows()
sort rows using natural ordering of row keys
|
void |
sortRows(C[] keys,
boolean reverse)
Sort Rows by the natural ordering of a set of column values.
|
void |
sortRows(java.util.Comparator c)
Sort rows according to row keys using a specified comparator
|
double |
sumCol(C key)
sum the numerical values in a column
|
<T> void |
thresholdRows(C col,
MatchCondition cond,
T value)
Remove all rows based on values in a column
row is removed if col-value Condition value = true
|
java.lang.String |
toString() |
void |
transformCol(C col_name,
Transform t)
Apply a
Transform to a column selected by name. |
void |
transformCol(int col_index,
Transform t)
apply a
Transform to a column selected by index. |
void |
transformKeys(C dest,
Transform t)
Create a new column based on a
Transform applied to the
current row keys. |
public <X> void addColumnAsRow(R row_key, X col_key, Table<X,C> t)
row_key
- row to addcol_key
- remote column to taket
- public <X> void addTable(Transform key_transform, Table<C,X> donor)
key_transform
- Transform
to map donor rows to local rowstable
- public <X> void addTable(C key_col, Table<C,X> donor)
key_col
- column in donor table containing row key values to usetable
- public void addRows(Table<C,R> t)
t
- public void addAttribute(C col, R row, java.lang.String name, java.lang.String value)
col
- row
- name
- value
- public void addCategoryTotals(C sum_col, C cat_Col, Transform cat_to_key)
sum_col
- cat_Col
- cat_to_key
- Transform to convert the category value into the keypublic void addCategoryTotals(C sum_col, C cat_Col, Transform cat_to_key, C label_col, java.lang.Boolean highlight)
sum_col
- cat_Col
- cat_to_key
- label_col
- highlight
- public void setCategoryRow(C target_col, C cat_Col, Transform cat_to_key, Transform cat_to_val)
public void addCategoryTotalToCol(C sum_col, C cat_Col, java.util.Map selection)
sum_col
- name of col to be summedcat_Col
- name of column specifying categoriesselection
- map specifying categories to sum. keyed by the category and
defining the keys to use for the sumspublic void addColAttribute(C col, java.lang.String name, java.lang.String value)
col
- name
- value
- public void addMap(C col_name, java.util.Map<R,?> data)
Map
of data into a column
If the data is a Number it is accumulated.col_name
- data
- Map
of datapublic void addMap(C col_name, java.util.Map<R,R> row_mapping, java.util.Map<R,?> data)
Map
of data into a column
If the data is a Number it is accumulated.
Row mapping translate the data keys into table row-keys
if no mapping exists the data-key is used unchanged.col_name
- row_mapping
- (optional row translations).data
- Map
of datapublic void addPercentCol(C old_name, C new_name)
old_name
- new_name
- public void addPercentCol(C old_name, C new_name, java.lang.Double sum)
old_name
- new_name
- sum
- public void addPercentCol(C old_name, C new_name, java.lang.Double sum, java.text.NumberFormat nf)
public void addPercentCol(C old_name, C new_name, java.text.NumberFormat nf)
old_name
- new_name
- nf
- NumberFormat to format colpublic void addRow(R key)
public void addRow(R key, java.util.Map<C,java.lang.Object> data)
key
- Row keydata
- Row datapublic java.lang.Double addTotalToCol(C col_name, R key)
col_name
- String key of column to modifykey
- Object key to use for totalpublic void addTotalToCol(int col_index, R key)
col_index
- int index of colkey
- key to use for Total@Deprecated public java.util.Collection<C> cols()
public boolean containsCol(C col_name)
col_name
- public java.util.Map<java.lang.String,java.lang.String> getAttributes(C col_key, R row_key)
public Table.Col getCol(C col_key)
col_key
- public Table.Formatter getColFormat(C col_key)
public java.util.List<C> getCols()
public java.util.List<C> getColumNames()
public java.util.Hashtable<java.lang.String,java.lang.Number> getHashtable(C col_key) throws InvalidArgument
InvalidArgument
public java.util.Hashtable<java.lang.String,java.lang.Number> getHashtable(C col_key, C label_key) throws InvalidArgument
col_key
- label_key
- InvalidArgument
public boolean getHighlight(R row_key)
row_key
- public java.lang.String getKeyName()
public java.lang.Object getKeyText(R key)
key
- public java.util.List<R> getRows()
public java.lang.String getString()
public boolean getWarning(R row_key)
row_key
- public boolean hasCol(java.lang.String string)
public boolean hasColFormat(C col_name)
public boolean hasData()
public boolean hasRow(R key)
public java.lang.Object increment(C col_key, R row_key, int value)
col_key
- row_key
- value
- public boolean isPrintHeadings()
public int nCols()
public int nRows()
public boolean printKeys()
public void removeCol(C key)
key
- public void removeRow(R key)
@Deprecated public java.util.Collection<R> rows()
public void rowToString(R row_name)
row_name
- public void setCol(C key, int ind)
key
- ind
- public void setColAfter(C first, C after)
first
- Column we are to followafter
- Column to movepublic Table.Formatter<C,R> setColFormat(C col_name, Table.Formatter<C,R> t)
public Table.Formatter setColFormat(C col_name, Transform t)
public void setColLast(C key)
key
- public void setColName(C key, java.lang.String name)
public void setColumns(java.util.List<C> v)
public void setFormat(Table.Formatter<C,R> t)
t
- Transform to usepublic void setFormat(Transform t)
public void setHighlight(R row_key, boolean value)
row_key
- value
- public void setKeyName(java.lang.String keyName)
keyName
- Stringpublic void setKeyTransform(Transform t)
t
- public void setPrintHeadings(boolean printHeadings)
public void setRow(R key, int ind)
key
- ind
- public void setRowLast(R key)
key
- public void setTypeDebug(boolean flag)
flag
- public void setWarning(R row_key, boolean value)
row_key
- value
- public void sortCols(java.util.Comparator c)
c
- public void sortRows()
public void sortRows(C[] keys, boolean reverse)
keys
- Array of column keysreverse
- boolean should order be reversedpublic void sortRows(java.util.Comparator c)
c
- public double sumCol(C key)
key
- public java.lang.String toString()
toString
in class java.lang.Object
public void transformCol(C col_name, Transform t)
Transform
to a column selected by name.col_name
- t
- public void transformCol(int col_index, Transform t)
Transform
to a column selected by index.col_index
- t
- public void transformKeys(C dest, Transform t)
Transform
applied to the
current row keys.dest
- t
- public java.lang.String getId()
public void setId(java.lang.String id)
public <T> void thresholdRows(C col, MatchCondition cond, T value)
col
- Column to querycond
- MatchCondition
to comparevalue
- valuepublic void addToGroup(C group, C col) throws InvalidArgument
InvalidArgument
public java.lang.Iterable<C> getColumnGroups()
public boolean hasColumnGroup(C name)
public void packColumnGroup(C name)
name
- public void packAllColumnGroups()