org.mmbase.util.functions
Interface Function

All Known Implementing Classes:
AbstractFunction, WrappedFunction

public interface Function

A representation of a piece of functionality (a 'function'). A function has a name, a return type, and a parameter-definition (which is a Parameter array). The goal of a Function object is to call its getFunctionValue(Parameters) method, which executes it, given the specified parameters.

Since:
MMBase-1.7
Version:
$Id: Function.java,v 1.6 2005/07/08 12:23:46 pierre Exp $
Author:
Pierre van Rooden, Daniel Ockeloen, Michiel Meeuwissen
See Also:
Parameter, Parameters

Method Summary
 Parameters createParameters()
          Creates an empty 'Parameters' object for you, which you have to fill and feed back to getFunctionValue
 String getDescription()
           
 Object getFunctionValue(Parameters parameters)
          Executes the defined function supplying the given arguments.
 Object getFunctionValueWithList(List parameters)
          Executes the defined function supplying the given List of arguments.
 String getName()
          A function must have a name.
 Parameter[] getParameterDefinition()
           
 ReturnType getReturnType()
           
 void setDescription(String description)
          For documentational purposes a function object needs a description too.
 void setParameterDefinition(Parameter[] params)
          A function object is of no use, as long as it lacks a definition.
 void setReturnType(ReturnType type)
          Sets the return type of the function's result value.
 

Method Detail

createParameters

public Parameters createParameters()
Creates an empty 'Parameters' object for you, which you have to fill and feed back to getFunctionValue

See Also:
getFunctionValue(Parameters)

getFunctionValue

public Object getFunctionValue(Parameters parameters)
Executes the defined function supplying the given arguments.

Parameters:
parameters - The parameters for the function. To specify an empty parameter list use Parameters.VOID. Implementors are encouraged to support null too.
Returns:
The function value, which can be of any type compatible to getReturnType()
See Also:
createParameters()

getFunctionValueWithList

public Object getFunctionValueWithList(List parameters)
Executes the defined function supplying the given List of arguments. This is a convenience method, as the List is mapped to a Parameters type and passed to getFunctionValue(Parameters).

Parameters:
parameters - The parameters for the function. To specify an empty parameter list use Parameters.VOID.
Returns:
The function value, which can be of any type compatible to getReturnType()

setDescription

public void setDescription(String description)
For documentational purposes a function object needs a description too.


getDescription

public String getDescription()
See Also:
setDescription(String)

getName

public String getName()
A function must have a name. This is the name which was used to aquire the function object.

Returns:
The function's name, never null

getParameterDefinition

public Parameter[] getParameterDefinition()
Returns:
The currently set Parameter definition array, or null if not set already.

setParameterDefinition

public void setParameterDefinition(Parameter[] params)
A function object is of no use, as long as it lacks a definition.

Parameters:
params - An array of Parameter objects.
Throws:
IllegalStateException - if there was already set a parameter definition for this function object.

getReturnType

public ReturnType getReturnType()
Returns:
The return type of the function's result value, or null if unknown.

setReturnType

public void setReturnType(ReturnType type)
Sets the return type of the function's result value.

Parameters:
type - A ReturnType object. For void functions that could be ReturnType.VOID.
Throws:
IllegalStateException - if there was already set a return type for this function object.


MMBase build 1.8.1.20060716