KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mmbase > util > functions > Function


1 /*
2
3 This software is OSI Certified Open Source Software.
4 OSI Certified is a certification mark of the Open Source Initiative.
5
6 The license (Mozilla version 1.0) can be read at the MMBase site.
7 See http://www.MMBase.org/license
8
9 */

10 package org.mmbase.util.functions;
11
12 import java.util.*;
13
14
15 /**
16  * A representation of a piece of functionality (a 'function'). A function has a name, a
17  * return type, and a parameter-definition (which is a {@link Parameter} array).
18  *
19  * The goal of a Function object is to call its {@link #getFunctionValue(Parameters)} method, which
20  * executes it, given the specified parameters.
21  *
22  * @author Pierre van Rooden
23  * @author Daniel Ockeloen
24  * @author Michiel Meeuwissen
25  * @version $Id: Function.java,v 1.6 2005/07/08 12:23:46 pierre Exp $
26  * @since MMBase-1.7
27  * @see Parameter
28  * @see Parameters
29  */

30 public interface Function {
31     /**
32      * Creates an empty 'Parameters' object for you, which you have to fill and feed back to getFunctionValue
33      * @see #getFunctionValue(Parameters)
34      */

35     public Parameters createParameters();
36
37     /**
38      * Executes the defined function supplying the given arguments.
39      * @see #createParameters
40      * @param parameters The parameters for the function. To specify an empty parameter list use {@link Parameters#VOID}.
41      * Implementors are encouraged to support <code>null</code> too.
42      * @return The function value, which can be of any type compatible to {@link #getReturnType}
43      */

44     public Object JavaDoc getFunctionValue(Parameters parameters);
45
46     /**
47      * Executes the defined function supplying the given List of arguments.
48      * This is a convenience method, as the List is mapped to a Parameters type and passed to {@link #getFunctionValue(Parameters)}.
49      * @param parameters The parameters for the function. To specify an empty parameter list use {@link Parameters#VOID}.
50      *
51      * @return The function value, which can be of any type compatible to {@link #getReturnType}
52      */

53     public Object JavaDoc getFunctionValueWithList(List parameters);
54
55     /**
56      * For documentational purposes a function object needs a description too.
57      */

58     public void setDescription(String JavaDoc description);
59
60     /**
61      * @see #setDescription(String)
62      */

63     public String JavaDoc getDescription();
64
65     /**
66      * A function <em>must</em> have a name. This is the name which was used to aquire the function object.
67      * @return The function's name, never <code>null</code>
68      */

69     public String JavaDoc getName();
70
71     /**
72      * @return The currently set Parameter definition array, or <code>null</code> if not set already.
73      */

74     public Parameter[] getParameterDefinition();
75
76     /**
77      * A function object is of no use, as long as it lacks a definition.
78      * @param params An array of Parameter objects.
79      * @throws IllegalStateException if there was already set a parameter definition for this function object.
80      */

81     public void setParameterDefinition(Parameter[] params);
82
83     /**
84      * @return The return type of the function's result value, or <code>null</code> if unknown.
85      */

86     public ReturnType getReturnType();
87
88     /**
89      * Sets the return type of the function's result value.
90      * @param type A ReturnType object. For void functions that could be {@link ReturnType#VOID}.
91      * @throws IllegalStateException if there was already set a return type for this function object.
92      */

93     public void setReturnType(ReturnType type);
94
95 }
96
Popular Tags