org.apache.cocoon.forms.formmodel
Interface CalculatedFieldAlgorithm

All Known Implementing Classes:
AbstractBaseAlgorithm, JavaScript

public interface CalculatedFieldAlgorithm

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

Version:
$Id: CalculatedFieldAlgorithm.html 1304280 2012-03-23 11:18:01Z 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

public 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

public 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

public 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-2008 The Apache Software Foundation. All Rights Reserved.