@ScriptApi public class TotalsTableBuilder extends Object implements Serializable
The builder is intended to be passed to the Table.setTotalsTable(TotalsTableBuilder)
operation after the
operations are applied.
Modifier and Type | Field and Description |
---|---|
static long |
serialVersionUID |
Constructor and Description |
---|
TotalsTableBuilder() |
Modifier and Type | Method and Description |
---|---|
TotalsTableBuilder |
addOperation(String column,
AggType operation)
Adds an operation for a column.
|
TotalsTableBuilder |
addOperation(String column,
AggType operation,
String format)
Adds an operation for a column.
|
TotalsTableBuilder |
addOperation(String column,
String operation)
Adds an operation for a column.
|
TotalsTableBuilder |
addOperation(String column,
String operation,
String format)
Adds an operation for a column.
|
String |
buildDirective()
Creates the string directive used to set the Table attribute.
|
static TotalsTableBuilder |
fromDirective(String directive)
Produce a TotalsTableBuilder from a directive string.
|
static TotalsTableBuilder |
get(Table source)
Produce a totals table builder from the source table.
|
AggType |
getDefaultOperation()
Gets the operation to use for columns without an operation specified.
|
Map<AggType,String> |
getFormats(String column)
Gets the format for an aggregated column.
|
Set<AggType> |
getOperations(String column)
Gets the operations for a given column.
|
boolean |
getShowGrandTotalsByDefault()
Should grand totals be shown by default?
|
boolean |
getShowTotalsByDefault()
Should totals be shown by default?
|
static boolean |
hasDefinedTotals(Table source)
Does a table have a totals table defined?
|
static ComboAggregateFactory |
makeAggregationFactory(Table source,
TotalsTableBuilder builder)
Produce a ComboAggregateFactory from a source table and builder.
|
static Table |
makeTotalsTable(Table source)
Create a totals table from a source table.
|
static Table |
makeTotalsTable(Table source,
TotalsTableBuilder builder,
String... groupByColumns)
Given a source table, builder and aggregation columns build a totals table with multiple rows.
|
static boolean |
operationApplies(Class type,
AggType operation)
Does the operation apply to type?
|
TotalsTableBuilder |
setDefaultOperation(AggType defaultOperation)
Sets the operation for columns which are not otherwise specified.
|
TotalsTableBuilder |
setDefaultOperation(String defaultOperation)
Sets the operation for columns which are not otherwise specified.
|
TotalsTableBuilder |
setFormat(String column,
AggType agg,
String format)
Sets the format of a column.
|
TotalsTableBuilder |
setFormat(String column,
String agg,
String format)
Sets the format of a column.
|
TotalsTableBuilder |
setOperation(String column,
AggType operation)
Sets the operation for a column.
|
TotalsTableBuilder |
setOperation(String column,
AggType operation,
String format)
Sets the operation for a column.
|
TotalsTableBuilder |
setOperation(String column,
String operation)
Sets the operation for a column.
|
TotalsTableBuilder |
setOperation(String column,
String operation,
String format)
Sets the operation for a column.
|
TotalsTableBuilder |
setShowGrandTotalsByDefault(boolean showGrandTotalsByDefault)
Set whether grand totals are shown by default.
|
TotalsTableBuilder |
setShowTotalsByDefault(boolean showTotalsByDefault)
Set whether totals are shown by default.
|
String |
toString() |
public static final long serialVersionUID
public boolean getShowTotalsByDefault()
public boolean getShowGrandTotalsByDefault()
@ScriptApi public TotalsTableBuilder setShowTotalsByDefault(boolean showTotalsByDefault)
showTotalsByDefault
- whether totals are shown by default@ScriptApi public TotalsTableBuilder setShowGrandTotalsByDefault(boolean showGrandTotalsByDefault)
showGrandTotalsByDefault
- whether grand totals are shown by default@ScriptApi public TotalsTableBuilder setDefaultOperation(AggType defaultOperation)
defaultOperation
- the default operation@ScriptApi public TotalsTableBuilder setDefaultOperation(String defaultOperation)
defaultOperation
- the default operation@ScriptApi public TotalsTableBuilder setOperation(String column, AggType operation, String format)
column
- the name of the column to operate onoperation
- the aggregation operation for this columnformat
- the format string for this column@ScriptApi public TotalsTableBuilder setOperation(String column, AggType operation)
column
- the name of the column to operate onoperation
- the aggregation operation for this column@ScriptApi public TotalsTableBuilder setOperation(String column, String operation)
column
- the name of the column to operate onoperation
- the aggregation operation for this column@ScriptApi public TotalsTableBuilder setOperation(String column, String operation, String format)
column
- the name of the column to operate onoperation
- the aggregation operation for this columnformat
- the format string for this column@ScriptApi public TotalsTableBuilder addOperation(String column, AggType operation)
The add method is used instead of the TotalsTableBuilder.setOperation(String, String)
method when more than one
aggregation per input column is desired.
column
- the name of the column to operate onoperation
- the aggregation operation for this column@ScriptApi public TotalsTableBuilder addOperation(String column, AggType operation, String format)
The add method is used instead of the TotalsTableBuilder.setOperation(String, AggType, String)
method when more than one
aggregation per input column is desired.
column
- the name of the column to operate onoperation
- the aggregation operation for this columnformat
- the format string for this column@ScriptApi public TotalsTableBuilder addOperation(String column, String operation, String format)
The add method is used instead of the TotalsTableBuilder.setOperation(String, String, String)
method when more than one
aggregation per input column is desired.
column
- the name of the column to operate onoperation
- the aggregation operation for this columnformat
- the format string for this column@ScriptApi public TotalsTableBuilder addOperation(String column, String operation)
The add method is used instead of the TotalsTableBuilder.setOperation(String, String)
method when more than one
aggregation per input column is desired.
column
- the name of the column to operate onoperation
- the aggregation operation for this column@NotNull public Set<AggType> getOperations(String column)
column
- the column to get the operations forpublic AggType getDefaultOperation()
@ScriptApi public TotalsTableBuilder setFormat(String column, AggType agg, String format)
column
- the column to set the format foragg
- the aggregation type the format is relevant forformat
- the format string@ScriptApi public TotalsTableBuilder setFormat(String column, String agg, String format)
column
- the column to set the format foragg
- the aggregation type the format is relevant for, "*" for all aggregationsformat
- the format string@NotNull public Map<AggType,String> getFormats(String column)
column
- the column to get the format forpublic String buildDirective()
public static Table makeTotalsTable(Table source)
Given a source table that has had a TotalsTableBuilder applied, create a new totals table from the table. If no TotalsTableBuilder has been applied, then the columns are summed.
source
- the source tablepublic static TotalsTableBuilder get(Table source)
source
- the source tablepublic static TotalsTableBuilder fromDirective(String directive)
The TotalsTableBuilder.buildDirective()
method produces a String representation of a TotalsTableBuilder, this function
is its inverse.
directive
- the directive.public static boolean hasDefinedTotals(Table source)
source
- the source tablepublic static Table makeTotalsTable(Table source, TotalsTableBuilder builder, String... groupByColumns)
source
- the source tablebuilder
- the TotalsTableBuildergroupByColumns
- the columns to group bypublic static ComboAggregateFactory makeAggregationFactory(Table source, TotalsTableBuilder builder)
source
- the source tablebuilder
- the TotalsTableBuilderComboAggregateFactory
described by source and builder.