org.mmbase.util.functions
Class FunctionProvider

java.lang.Object
  extended by org.mmbase.util.functions.FunctionProvider
Direct Known Subclasses:
BeanFunctionProvider, ClassFunctionProvider, DescribedFunctionProvider, FunctionSet, IndexFunction, MMTable, PatternNodeFunctionProvider

public abstract class FunctionProvider
extends Object

A function provider maintains a set of Function objects.

Since:
MMBase-1.8
Version:
$Id: FunctionProvider.java 41943 2010-04-16 17:18:19Z michiel $
Author:
Pierre van Rooden

Field Summary
protected  Map<String,Function<?>> functions
           
protected  Function<Collection<Function<?>>> getFunctions
          Every Function Provider provides least the 'getFunctions' function, which returns a Set of all functions which it provides.
 
Constructor Summary
FunctionProvider()
          The constructor of an FunctionProvider guesses the functions using reflection.
 
Method Summary
 Function<?> addFunction(Function<?> function)
          Adds a function to the FunctionProvider.
 Parameters createParameters(String functionName)
          Creates a new empty Parameters object for given function.
 Function<?> getFunction(String functionName)
          Returns the Function object with given name.
 Collection<Function<?>> getFunctions()
          Returns a Collection of all functions currently provided by the FunctionProvider.
 Object getFunctionValue(String functionName, List<?> parameters)
          Executes a function, and returns the function value.
protected  Function<?> newFunctionInstance(String name, Parameter<?>[] parameters, ReturnType returnType)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

functions

protected Map<String,Function<?>> functions

getFunctions

protected Function<Collection<Function<?>>> getFunctions
Every Function Provider provides least the 'getFunctions' function, which returns a Set of all functions which it provides.

Constructor Detail

FunctionProvider

public FunctionProvider()
The constructor of an FunctionProvider guesses the functions using reflection.

To Do:
Should this last thing not only be done on MMObjectBuilders?
Method Detail

newFunctionInstance

protected Function<?> newFunctionInstance(String name,
                                          Parameter<?>[] parameters,
                                          ReturnType returnType)

addFunction

public Function<?> addFunction(Function<?> function)
Adds a function to the FunctionProvider. So, you can implement any function and add it to the provider, to make it provide this function too.

Returns:
The function previously assigned with this name or null if no such function.

createParameters

public Parameters createParameters(String functionName)
Creates a new empty Parameters object for given function.

Returns:
A new empty Parameters object, or null if no such function.

getFunctionValue

public Object getFunctionValue(String functionName,
                               List<?> parameters)
Executes a function, and returns the function value.

Returns:
The function value or null if no such function.

getFunction

public Function<?> getFunction(String functionName)
Returns the Function object with given name.

Returns:
Function object or null if no such function is provided.

getFunctions

public Collection<Function<?>> getFunctions()
Returns a Collection of all functions currently provided by the FunctionProvider.



MMBase 2.0-SNAPSHOT - null