net.sf.saffron.core
Interface AggregationExtender

All Known Implementing Classes:
LocaleMin, Median, Nth

public interface AggregationExtender

An AggregationExtender allows end-users to define their own aggregate functions.

An aggregation extender supports one or more sets of argument types, T. T can be a single type (such as String or int), several types (such as String, int), or empty. For each set T, it declares 4 methods:

(The merge method is actually optional. If it is not present, ExtenderAggregation.canMerge() returns false.)

Consider the query

Locale locale = Locale.getDefault();
 Collator collator = Collator.getInstance(locale);
 LocaleMin localeMin = new LocaleMin(collator);
 select {localeMin.aggregate(emp.name)}
 group by {emp.deptno}
 from emps as emp

Here T is String, and so LocaleMin.start(String) will be called when a group starts, LocaleMin.next(String,Object) on each row, and so forth.

Note that the aggregation object is evaluated each time a group starts. If each department has its own locale, one could write

select {new LocaleMin(Collator.getInstance(emp.dept.locale))
                 .aggregate(emp.name) }
 group by {emp.dept}
 from emps as emp

Since:
26 January, 2001
Version:
$Id: //open/saffron/src/net/sf/saffron/core/AggregationExtender.java#5 $
Author:
jhyde

Field Summary
static String METHOD_AGGREGATE
          The name of the "aggregate" method.
static String METHOD_MERGE
          The name of the "merge" method.
static String METHOD_NEXT
          The name of the "next" method.
static String METHOD_RESULT
          The name of the "result" method.
static String METHOD_START
          The name of the "start" method.
 

Field Detail

METHOD_AGGREGATE

public static final String METHOD_AGGREGATE
The name of the "aggregate" method.

See Also:
Constant Field Values

METHOD_START

public static final String METHOD_START
The name of the "start" method.

See Also:
Constant Field Values

METHOD_NEXT

public static final String METHOD_NEXT
The name of the "next" method.

See Also:
Constant Field Values

METHOD_RESULT

public static final String METHOD_RESULT
The name of the "result" method.

See Also:
Constant Field Values

METHOD_MERGE

public static final String METHOD_MERGE
The name of the "merge" method.

See Also:
Constant Field Values

SourceForge.net_Logo