To accomplish the aggregate functionality desired, the Aggregations class uses a cache of Aggregator objects that perform the actual aggregation calculations. These Aggregator objects are analogous to the Oracle object types that can be created for custom aggregation functions. The Aggregator class itself is an abstract class that does the following:
Subclasses of Aggregator implement the abstract methods init, iterate, merge, and terminate that do the actual aggregation. They also implement the abstract method replicate to return a new Aggregator of the same type, but un-initialized.
Additionally, subclasses of Aggregator may use other Aggregators internally to facilitate calculations. These would typically need to create a numeric result precisely. Optionally, some Aggregators override the terminateDoubleDouble method. This allows an Aggregator subclass to be used internally by other Aggregators, to maintain a high level of precision during internal calculations.
The Aggregator class defines a static Factory Method called getAggregator that takes as its only argument an aggregator specification string, in the format "aggname(property)", where "aggname" is name of the Aggregator class, minus the suffix "Aggregator", and "property" is the property string normally sent to the Aggregator's constructor. This factory method is an alternative to directly instantiating Aggregators in code. It may return an existing, unused Aggregator that is already in the internal cache. Such a cached Aggregator would be the desired type and have the same property to process.