org.apache.cocoon.forms.formmodel
Interface CalculatedFieldAlgorithm

All Known Implementing Classes:
AbstractBaseAlgorithm, JavaScript, RepeatedFormula, SimpleFormula

public interface CalculatedFieldAlgorithm

Common interface for an algorithm to calculate the value of a CalculatedField.

Version:
$Id: CalculatedFieldAlgorithm.html 1304258 2012-03-23 10:09:27Z ilgrosso $

Method Summary
 Object calculate(Form form, Widget parent, Datatype datatype)
          Performs the actual calculation.
 Iterator getTriggerWidgets()
          Returns an iterator on trigger widget paths.
 boolean isSuitableFor(Datatype dataType)
          Checks wether this algorithm is able to return the given datatype.
 

Method Detail

isSuitableFor

boolean isSuitableFor(Datatype dataType)
Checks wether this algorithm is able to return the given datatype. For example, an arithmetic algorithm like sum should check that the given datatype is a number.

Parameters:
dataType - The target datatype.
Returns:
true if this algorithm can return a compatible value, false otherwise.

calculate

Object calculate(Form form,
                 Widget parent,
                 Datatype datatype)
Performs the actual calculation.

Parameters:
form - The form.
parent - The parent widget of the CalculatedField widget (may be the same as form)
datatype - The target datatype.
Returns:
the calculated value for the CalculatedField.

getTriggerWidgets

Iterator getTriggerWidgets()
Returns an iterator on trigger widget paths. When the value of a trigger widget changes, then the CalculatedField value must be recalculated.

Returns:
An iterator of Strings representing widget paths as interpreted by WidgetFinder.


Copyright © 1999-2010 The Apache Software Foundation. All Rights Reserved.