Entry Point

The "Analytic" class is the entry point for a developer attempting to present a view of analytic data in an application. It defines a static nested class "Builder" that follows the Builder Pattern. This Builder class builds an Analytic object that can be used to perform analytic operations.

Builder Class

The "Builder" class builds Analytic objects. It has some methods that can be used to control how the resultant Analytic object behaves.

  • setAnalytics(List<AnalyticAggregators> analytics) - This method is required, or build() will throw an Exception. This method supplies all AnalyticAggregators to be used in the analytic operation. Create AnalyticAggregators by passing an AnalyticFunction, or by using the AnalyticAggregator class's factory method for creating them using analytic specification strings:
    • AnalyticAggregator agg1 = new AnalyticAggregator.Builder()
          .setAnalyticFunction(new LeadAnalytic("qty")
          .setPartition(new PartitionClause(Arrays.asList("year", "quarter"))))
    • AnalyticAggregator agg2 = AnaltyicAggregator.getAnalytic("Lead(qty) partitionBy(year, quarter)");
  • build() - This method builds an Analytic object that can be used to perform the actual analytic operations. This method should be called after "setAnalytics" has been called.

The "setAnalytics" method returns the same Builder object, so that calls may be chained, e.g.

Analytic ana = new Analytic.Builder().setAnalytics(anaList).build();

Analytic Class

The "Analytic" object is responsible for performing all analytic operations. It has the method that performs the actual analytics operations.

  • <T> analyze(List<T> values) - The Analytic object "lines up" all objects for each AnalyticFunction using the Collections.sort overloading that takes a Comparator. jAgg supplies its own PartitionAndOrderByComparator, which compares the value objects based on the partition and order by clauses of each AnalyticFunction.

This method returns a List of AnalyticValues, which contain the completed analytic results.