org.mmbase.util.functions
Class Functions

java.lang.Object
  extended byorg.mmbase.util.functions.Functions

public class Functions
extends Object

This class defines static methods for defining Function and Parameters objects. These methods include ways to retrieve Function definitions for a class using reflection, and methods to convert a List to a Parameters object, and a Parameter array to a List.

Since:
MMBase-1.8
Version:
$Id: Functions.java,v 1.12 2006/01/13 15:37:24 pierre Exp $
Author:
Pierre van Rooden, Daniel Ockeloen, Michiel Meeuwissen

Constructor Summary
Functions()
           
 
Method Summary
static Parameters buildParameters(Parameter[] def, List args)
          Converts a certain List to an Parameters if it is not already one.
static List define(Parameter[] def, List list)
          Adds the definitions to a List.
static Method getMethodFromClass(Class claz, String name)
           
static Map getParameterDefinitonsByReflection(Class clazz, Map map)
          Generates a map of Parameter[] objects for a given class through reflection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Functions

public Functions()
Method Detail

buildParameters

public static Parameters buildParameters(Parameter[] def,
                                         List args)
Converts a certain List to an Parameters if it is not already one.


define

public static List define(Parameter[] def,
                          List list)
Adds the definitions to a List. Resolves the Parameter.Wrapper's (recursively).

Returns:
List with only simple Parameter's.

getMethodFromClass

public static Method getMethodFromClass(Class claz,
                                        String name)
Warning: No Java Documentation Available.

getParameterDefinitonsByReflection

public static Map getParameterDefinitonsByReflection(Class clazz,
                                                     Map map)
Generates a map of Parameter[] objects for a given class through reflection. The map keys are the names of te function the Parameter[] object belongs to.
The method parses the given class for constants (final static public members) of type Parameter[]. The member name up to the first underscore in that name is considered the name for a function supported by that class. i.e. :
    public final static Parameter[] AGE_PARAMETERS = {};
 
defines a function 'age' which takes no parameters.
    public final static Parameter[] GUI_PARAMETERS = {
        new Parameter("field", String.class),
        Parameter.LANGUAGE
    }
 
defines a function 'gui' which two parameters: 'field' and 'language'. Results form reflection are stored in an internal cache. The method returns the Parameter[] value (if any) of the function whose name was given in the call. If the function cannot be derived through reflection, the method returns null.
Note that, since this way of determining functions cannot determine return value types, it is advised to use FunctionProvider.addFunction(org.mmbase.util.functions.Function) instead.

Parameters:
clazz - the class to perform reflection on.
map -
Returns:
A map of parameter definitions (Parameter[] objects), keys by function name (String)
See Also:
Parameter


MMBase build 1.8.1.20060716