Class BucketingService
- java.lang.Object
-
- net.sf.jasperreports.crosstabs.fill.calculation.BucketingService
-
- Direct Known Subclasses:
CrosstabBucketingService
,MultiAxisDataService.MultiAxisBucketingService
public abstract class BucketingService extends Object
Bidimensional bucketing engine.- Author:
- Lucian Chirita (lucianc@users.sourceforge.net)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
BucketingService.BucketListMap
class
BucketingService.BucketMap
protected class
BucketingService.BucketMapMap
protected static class
BucketingService.MapEntry
-
Field Summary
-
Constructor Summary
Constructors Constructor Description BucketingService(BucketingServiceContext serviceContext, List<BucketDefinition> rowBuckets, List<BucketDefinition> columnBuckets, List<MeasureDefinition> measures, boolean sorted, boolean[][] retrieveTotal)
Creates a crosstab bucketing engine.
-
Method Summary
-
-
-
Field Detail
-
EXCEPTION_MESSAGE_KEY_BUCKET_MEASURE_LIMIT
public static final String EXCEPTION_MESSAGE_KEY_BUCKET_MEASURE_LIMIT
- See Also:
- Constant Field Values
-
EXCEPTION_MESSAGE_KEY_BUCKET_DATA_PROCESSED
public static final String EXCEPTION_MESSAGE_KEY_BUCKET_DATA_PROCESSED
- See Also:
- Constant Field Values
-
PROPERTY_BUCKET_MEASURE_LIMIT
public static final String PROPERTY_BUCKET_MEASURE_LIMIT
- See Also:
- Constant Field Values
-
DIMENSION_ROW
protected static final byte DIMENSION_ROW
- See Also:
- Constant Field Values
-
DIMENSION_COLUMN
protected static final byte DIMENSION_COLUMN
- See Also:
- Constant Field Values
-
DIMENSIONS
protected static final int DIMENSIONS
- See Also:
- Constant Field Values
-
serviceContext
protected final BucketingServiceContext serviceContext
-
allBuckets
protected final BucketDefinition[] allBuckets
-
buckets
protected final BucketDefinition[][] buckets
-
rowBucketCount
protected final int rowBucketCount
-
colBucketCount
protected final int colBucketCount
-
retrieveTotal
protected final boolean[][] retrieveTotal
-
rowRetrTotals
protected boolean[] rowRetrTotals
-
rowRetrTotalMin
protected int rowRetrTotalMin
-
rowRetrTotalMax
protected int rowRetrTotalMax
-
rowRetrColMax
protected int[] rowRetrColMax
-
measures
protected final MeasureDefinition[] measures
-
origMeasureCount
protected final int origMeasureCount
-
measureIndexes
protected final int[] measureIndexes
-
sorted
protected final boolean sorted
-
bucketValueMap
protected final BucketingService.BucketMap bucketValueMap
-
columnBucketMap
protected final BucketingService.BucketMap columnBucketMap
-
dataCount
protected long dataCount
-
processed
protected boolean processed
-
zeroMeasureValues
protected final MeasureDefinition.MeasureValue[] zeroMeasureValues
-
zeroUserMeasureValues
protected final MeasureDefinition.MeasureValue[] zeroUserMeasureValues
-
bucketMeasureLimit
protected final int bucketMeasureLimit
-
-
Constructor Detail
-
BucketingService
public BucketingService(BucketingServiceContext serviceContext, List<BucketDefinition> rowBuckets, List<BucketDefinition> columnBuckets, List<MeasureDefinition> measures, boolean sorted, boolean[][] retrieveTotal)
Creates a crosstab bucketing engine.- Parameters:
serviceContext
- the bucketing service contextrowBuckets
- the row bucket definitionscolumnBuckets
- the column bucket definitionsmeasures
- the measure definitionssorted
- whether the data is presortedretrieveTotal
- totals to retrieve along with the cell values
-
-
Method Detail
-
checkTotals
protected void checkTotals()
-
clear
public void clear()
Clears all the accumulated and computed data.
-
createBucketMap
protected BucketingService.BucketMap createBucketMap(int level)
-
createBucketMapMap
protected BucketingService.BucketMapMap createBucketMapMap(int level)
-
createRowTotalsBucketMap
protected BucketingService.BucketMapMap createRowTotalsBucketMap()
-
addMeasure
protected void addMeasure(MeasureDefinition measure, int index, List<MeasureDefinition> measuresList, List<Integer> measureIndexList)
-
addData
public void addData(Object[] bucketValues, Object[] measureValues) throws JRException
Feeds data to the engine.- Parameters:
bucketValues
- the bucket valuesmeasureValues
- the measure values- Throws:
JRException
-
bucketMeasuresCreated
protected void bucketMeasuresCreated()
-
getBucketValues
protected BucketDefinition.Bucket[] getBucketValues(Object[] bucketValues)
-
initMeasureValues
protected MeasureDefinition.MeasureValue[] initMeasureValues()
-
initUserMeasureValues
protected MeasureDefinition.MeasureValue[] initUserMeasureValues()
-
processData
public void processData() throws JRException
Processes the data which was fed to the engine.This method should be called after the data has been exhausted. The processing consists of total calculations and crosstab table creation.
- Throws:
JRException
-
hasData
public boolean hasData()
Checks whether there is any data accumulated by the engine.- Returns:
true
if and only if the engine has any accumulated data
-
getMeasureValues
public MeasureDefinition.MeasureValue[] getMeasureValues(BucketDefinition.Bucket[] bucketValues)
Returns the measure values for a set of bucket values.- Parameters:
bucketValues
- the bucket values- Returns:
- the measure values corresponding to the bucket values
-
getUserMeasureValues
public MeasureDefinition.MeasureValue[] getUserMeasureValues(MeasureDefinition.MeasureValue[] values)
-
getZeroUserMeasureValues
public MeasureDefinition.MeasureValue[] getZeroUserMeasureValues()
-
getGrandTotals
public MeasureDefinition.MeasureValue[] getGrandTotals()
Returns the grand total measure values.- Returns:
- the grand total measure values
-
computeTotals
protected void computeTotals(BucketingService.BucketMap bucketMap) throws JRException
- Throws:
JRException
-
sumVals
protected void sumVals(MeasureDefinition.MeasureValue[] totals, MeasureDefinition.MeasureValue[] vals) throws JRException
- Throws:
JRException
-
computeColumnTotal
protected void computeColumnTotal(BucketingService.BucketMap bucketMap) throws JRException
- Throws:
JRException
-
computeRowTotals
protected void computeRowTotals(BucketingService.BucketMap bucketMap) throws JRException
- Throws:
JRException
-
checkBucketMeasureCount
protected void checkBucketMeasureCount(int bucketMeasureCount)
-
getRowBuckets
public BucketDefinition[] getRowBuckets()
-
-