borland Packages  Class Hierarchy  dx.dataset Package 

CalcAggFieldsListener interface

java.util.EventListener
   +----com.borland.dx.dataset.CalcAggFieldsListener

About the CalcAggFieldsListener interface

Methods  

Implemented by CalcAggFieldsAdapter

This interface is used for notification of a row being added or deleted on a DataSet having a calculation on an aggregate column. The CalcAggFieldsListener listens for this notification in order to recompute the calculation based on the aggregation.

For example, your application uses a sum aggregator to compute the total value of an order as the sum of the extended price column for all the rows for that order. It then uses a CalcAggFieldsListener to compute the tax and shipping charges on top of the total. When a row is added or deleted from the order, the CalcAggFieldsListener is aware of this and recalculates the tax and shipping charges. In this example, you

  1. Set a column's calcType to CalcType.Aggregate.
  2. Supply an aggDescriptor to specify sorting (not target column or aggregation operation).
  3. Add a CalcAggFieldsListener to compute the calculation based on the aggregated column.

This class differs from the CalcFieldsListener in that this class is used to do calculations on maintained aggregates. The CalcFieldsListener class is used for calculations on rows.

Once this listener is set on a StorageDataSet, the name of the listener class is remembered. If another StorageDataSet opens the same table stream without having set a listener with the same class name, the StorageDataSet will be marked readOnly. The StorageDataSet can be made writable again by doing one of the following:

For more information, see DataSetException.NEEDS_RECALC.

CalcAggFieldsListener methods

Methods defined in this interface


CalcAggFieldsListener methods

calcAggAdd(com.borland.dx.dataset.ReadRow, com.borland.dx.dataset.ReadWriteRow)

  public void calcAggAdd(ReadRow row, ReadWriteRow resultRow)

Called when a new or modified row is posted. In the case of a modified row, both calcAggDelete() and calcAggAdd() are called.

Parameters:

row
The contents of the newly added or modified row.
resultRow
The values you want posted to the row. When calcAggAdd() is called, resultRow has the same values an row. Typically, you only change the values in columns that are calculations on aggregate columns.

calcAggDelete(com.borland.dx.dataset.ReadRow, com.borland.dx.dataset.ReadWriteRow)

  public void calcAggDelete(ReadRow row, ReadWriteRow resultRow)

Called when a row is deleted from the data set or a modified row is posted. In the case of a modified row, calcAggAdd() is also called.

Parameters:

row
The contents of the deleted or modified row.
resultRow
The contents of the deleted or modified row, including any changes you make to the columns that are calculations on aggregate columns. Values that you place in these columns will be duplicated into other rows in the same group before the row is deleted.