Class SummationSummaryProvider
- java.lang.Object
-
- org.eclipse.nebula.widgets.nattable.summaryrow.SummationSummaryProvider
-
- All Implemented Interfaces:
ISummaryProvider
public class SummationSummaryProvider extends Object implements ISummaryProvider
Implementation of ISummaryProvider that summarizes all values in a column if they are of type Number and return the sum as Double value.If a column contains mixed values, e.g. Strings and Integers, the SummationSummaryProvider will return
ISummaryProvider.DEFAULT_SUMMARY_VALUE
by default, as a summation is not possible this way. You are able to change that behaviour by creating the SummationSummaryProvider with the parameter strict set tofalse
. In that case the non Number values will be ignored.
-
-
Field Summary
-
Fields inherited from interface org.eclipse.nebula.widgets.nattable.summaryrow.ISummaryProvider
DEFAULT, DEFAULT_SUMMARY_VALUE, NONE
-
-
Constructor Summary
Constructors Constructor Description SummationSummaryProvider(IDataProvider dataProvider)
Create a newSummationSummaryProvider
by using the givenIDataProvider
.SummationSummaryProvider(IDataProvider dataProvider, boolean strict)
Create a newSummationSummaryProvider
by using the givenIDataProvider
and strict mode configuration.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
summarize(int columnIndex)
Calculates the sum of the values in the column.
-
-
-
Constructor Detail
-
SummationSummaryProvider
public SummationSummaryProvider(IDataProvider dataProvider)
Create a newSummationSummaryProvider
by using the givenIDataProvider
.Using this constructor will set the
SummationSummaryProvider
in strict mode which means that if a column contains non Number values,ISummaryProvider.DEFAULT_SUMMARY_VALUE
will be returned.- Parameters:
dataProvider
- TheIDataProvider
that should be used to calculate the sum.
-
SummationSummaryProvider
public SummationSummaryProvider(IDataProvider dataProvider, boolean strict)
Create a newSummationSummaryProvider
by using the givenIDataProvider
and strict mode configuration.Using this constructor will set the
SummationSummaryProvider
in strict mode which means that if a column contains non Number values,ISummaryProvider.DEFAULT_SUMMARY_VALUE
will be returned.- Parameters:
dataProvider
- TheIDataProvider
that should be used to calculate the sum.strict
- If strict is set totrue
and one or more of the values in the column is not of type Number, thenISummaryProvider.DEFAULT_SUMMARY_VALUE
will be returned. If strict is set tofalse
, this method will return the sum of all the values in the column that are of type Number, ignoring the non Number values.
-
-
Method Detail
-
summarize
public Object summarize(int columnIndex)
Calculates the sum of the values in the column.- Specified by:
summarize
in interfaceISummaryProvider
- Parameters:
columnIndex
- The column index of the column for which the summary should be calculated.- Returns:
- The sum of all Number values in the column as Double or
ISummaryProvider.DEFAULT_SUMMARY_VALUE
if the column contains non Number values and this SummationSummaryProvider is configured to be strict.
-
-