org.mmbase.util.functions
Interface Function<R>

All Known Implementing Classes:
AbstractFunction, BeanFunction, CloneNodeFunction, CombinedFunction, ContrastFunction, CreateCachesFunction, FileServlet.DirectoryFunction, FlashGuiFunction, GuiFunction, GuiFunction, MethodFunction, MMObjectNodeFunction, NodeFunction, PatternNodeFunctionProvider.PatternNodeFunction, ProcessorModule.GetNodeListFunction, ProcessorModule.ProcessFunction, ProcessorModule.ReplaceFunction, SetFunction, WaitUntilRecognizedFunction, WaitUntilTranscodingFunction, WrappedFunction

public interface Function<R>

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 40451 2010-01-11 09:29:46Z michiel $
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()
           
 R getFunctionValue(Parameters parameters)
          Executes the defined function supplying the given arguments.
 R getFunctionValueWithArgs(Object... parameters)
          A 'varargs' version of getFunctionValueWithList.
 R getFunctionValueWithList(List<?> parameters)
          Executes the defined function supplying the given List of arguments.
 String getName()
          A function must have a name.
 Parameter<?>[] getParameterDefinition()
           
 ReturnType<R> 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<R> type)
          Sets the return type of the function's result value.
 

Method Detail

createParameters

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

See Also:
getFunctionValue(Parameters)

getFunctionValue

R 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

R 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()

getFunctionValueWithArgs

R getFunctionValueWithArgs(Object... parameters)
A 'varargs' version of getFunctionValueWithList.

Since:
MMBase-2.0

setDescription

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


getDescription

String getDescription()
See Also:
setDescription(String)

getName

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

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

setParameterDefinition

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

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

setReturnType

void setReturnType(ReturnType<R> 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 2.0-SNAPSHOT - null