Class TotalsTableBuilder
- All Implemented Interfaces:
Serializable
@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.
- See Also:
- Serialized Form
-
Field Summary
Fields Modifier and Type Field Description static long
serialVersionUID
-
Constructor Summary
Constructors Constructor Description TotalsTableBuilder()
-
Method Summary
Modifier and Type Method 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()
-
Field Details
-
serialVersionUID
public static final long serialVersionUID- See Also:
- Constant Field Values
-
-
Constructor Details
-
TotalsTableBuilder
public TotalsTableBuilder()
-
-
Method Details
-
getShowTotalsByDefault
public boolean getShowTotalsByDefault()Should totals be shown by default?- Returns:
- true if totals should be shown by default
-
getShowGrandTotalsByDefault
public boolean getShowGrandTotalsByDefault()Should grand totals be shown by default?- Returns:
- true if grand totals should be shown by default
-
setShowTotalsByDefault
Set whether totals are shown by default.- Parameters:
showTotalsByDefault
- whether totals are shown by default- Returns:
- this TotalsTableBuilder
-
setShowGrandTotalsByDefault
Set whether grand totals are shown by default.- Parameters:
showGrandTotalsByDefault
- whether grand totals are shown by default- Returns:
- this TotalsTableBuilder
-
setDefaultOperation
Sets the operation for columns which are not otherwise specified.- Parameters:
defaultOperation
- the default operation- Returns:
- this TotalsTableBuilder
-
setDefaultOperation
Sets the operation for columns which are not otherwise specified.- Parameters:
defaultOperation
- the default operation- Returns:
- this TotalsTableBuilder
-
setOperation
Sets the operation for a column.- Parameters:
column
- the name of the column to operate onoperation
- the aggregation operation for this columnformat
- the format string for this column- Returns:
- this TotalsTableBuilder
-
setOperation
Sets the operation for a column.- Parameters:
column
- the name of the column to operate onoperation
- the aggregation operation for this column- Returns:
- this TotalsTableBuilder
-
setOperation
Sets the operation for a column.- Parameters:
column
- the name of the column to operate onoperation
- the aggregation operation for this column- Returns:
- this TotalsTableBuilder
-
setOperation
Sets the operation for a column.- Parameters:
column
- the name of the column to operate onoperation
- the aggregation operation for this columnformat
- the format string for this column- Returns:
- this TotalsTableBuilder
-
addOperation
Adds an operation for a column.The add method is used instead of the
setOperation(String, String)
method when more than one aggregation per input column is desired.- Parameters:
column
- the name of the column to operate onoperation
- the aggregation operation for this column- Returns:
- this TotalsTableBuilder
-
addOperation
Adds an operation for a column.The add method is used instead of the
setOperation(String, AggType, String)
method when more than one aggregation per input column is desired.- Parameters:
column
- the name of the column to operate onoperation
- the aggregation operation for this columnformat
- the format string for this column- Returns:
- this TotalsTableBuilder
-
addOperation
Adds an operation for a column.The add method is used instead of the
setOperation(String, String, String)
method when more than one aggregation per input column is desired.- Parameters:
column
- the name of the column to operate onoperation
- the aggregation operation for this columnformat
- the format string for this column- Returns:
- this TotalsTableBuilder
-
addOperation
Adds an operation for a column.The add method is used instead of the
setOperation(String, String)
method when more than one aggregation per input column is desired.- Parameters:
column
- the name of the column to operate onoperation
- the aggregation operation for this column- Returns:
- this TotalsTableBuilder
-
getOperations
Gets the operations for a given column.- Parameters:
column
- the column to get the operations for- Returns:
- a set of aggregations for the column
-
getDefaultOperation
Gets the operation to use for columns without an operation specified.- Returns:
- the default operation
-
setFormat
Sets the format of a column.- Parameters:
column
- the column to set the format foragg
- the aggregation type the format is relevant forformat
- the format string- Returns:
- this TotalsTableBuilder
-
setFormat
Sets the format of a column.- Parameters:
column
- the column to set the format foragg
- the aggregation type the format is relevant for, "*" for all aggregationsformat
- the format string- Returns:
- this TotalsTableBuilder
-
getFormats
Gets the format for an aggregated column.- Parameters:
column
- the column to get the format for- Returns:
- a map from AggType to the corresponding format string
-
buildDirective
Creates the string directive used to set the Table attribute.- Returns:
- the attribute string representing this TotalsTableBuilder.
-
toString
-
makeTotalsTable
Create a totals table from a source table.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.
- Parameters:
source
- the source table- Returns:
- an aggregated totals table
-
get
Produce a totals table builder from the source table.- Parameters:
source
- the source table- Returns:
- a TotalsTableBuilder derived from the source table's totals table attribute
-
fromDirective
Produce a TotalsTableBuilder from a directive string.The
buildDirective()
method produces a String representation of a TotalsTableBuilder, this function is its inverse.- Parameters:
directive
- the directive.- Returns:
- a TotalsTableBuilder
-
hasDefinedTotals
Does a table have a totals table defined?- Parameters:
source
- the source table- Returns:
- true if source has a totals table defined
-
makeTotalsTable
public static Table makeTotalsTable(Table source, TotalsTableBuilder builder, String... groupByColumns)Given a source table, builder and aggregation columns build a totals table with multiple rows.- Parameters:
source
- the source tablebuilder
- the TotalsTableBuildergroupByColumns
- the columns to group by- Returns:
- an aggregated totals table
-
makeAggregationFactory
public static ComboAggregateFactory makeAggregationFactory(Table source, TotalsTableBuilder builder)Produce a ComboAggregateFactory from a source table and builder.- Parameters:
source
- the source tablebuilder
- the TotalsTableBuilder- Returns:
- the
ComboAggregateFactory
described by source and builder.
-
operationApplies
Does the operation apply to type?- Parameters:
type
- the column typeoperation
- the aggregation operation- Returns:
- true if the operation is applicable to columns of this type
-