AggregateValue Class
The "AggregateValue" class is a value object that holds the result of any and all
aggregate operations. Category values and aggregate values are available using the
methods of this class. This class contains a reference to one of the original data
objects, to supply category/property data. Additional data is also available for
identifying "all values" categories if super aggregation is used, i.e. grouping sets,
rollups, or cubes. Here are the methods of the AggregateValue class.
- getAggregateValue(AggregateFunction agg) - Return the aggregate value as
calculated by the given AggregateFunction. Use an original AggregateFunction
object that was supplied to the Builder method.
- getAggregateValue(int index) - Return the aggregate value as
calculated by the AggregateFunction referenced by the given 0-based
index. This index references the original list of AggregateFunctions supplied to the
Builder object.
- getObject() - This method retrieves the property value associated
with this grouping. jAgg uses the first object in the group that it encounters
when calculating aggregate values. This method is not recommended if
super-aggregation is used. In super-aggregation, such as rollups or cubes,
some properties may represent "all values", so the original value for the
property may be invalid. Returning the actual object used would allow the user
to retrieve the original property value, would may be invalid for
super-aggregation. Use either of the overloaded getPropertyValue
methods instead. However, if Aggregation.groupByComparable was
called, then this is the only way to retrieve "group by" property values.
- getPropertyValue(String property) - Retrieve the property value by
name from the aggregate value. If this AggregateValue represents
"all values" for this property, then this will return null instead
of the actual property value.
- getPropertyValue(int index) - Retrieve the property value by
referencing the property with a 0-based index into the original list of
properties supplied to the Builder object. If no properties were supplied, and
groupByComparable was called, then this method will always return
null. If this AggregateValue represents "all values"
for this property, then this will return null instead of the
actual property value. If Aggregation.groupByComparable was
called, then there are no properties to reference and this method returns
null.
- isGrouping(String propertyName) - For AggregateValue objects that
represent super-aggregate values, i.e. rollups or cubes, then this method
determines whether the given property represents "all values". For
AggregateValue objects that represent normal aggregate values, no properties
represent "all values" so this method returns false.
- isGrouping(int index) - Returns the same boolean value as the
overloaded method above, but refers to properties with a 0-based index into the
original list of properties supplied to the Builder. If no properties were
supplied, and groupByComparable was called, then this method will
always return false.
- getGroupingId(List<?> fields) - Distinguishes different
grouping sets that contain the given fields during super-aggregation. Returns
a distinct integer for each different grouping set, e.g. rollup or cube. Each
of the given fields may be String property names or 0-based integer references
to the original List of properties supplied to the Builder. For
AggregateValues that represent normal aggregation, this always returns 0.