KickJava   Java API By Example, From Geeks To Geeks.

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


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.List JavaDoc;
13
14 /**
15  * A wrapped function is a base class for function objects based on an other function object.
16  *
17  * @since MMBase-1.8
18  * @author Pierre van Rooden
19  * @version $Id: WrappedFunction.java,v 1.9.2.1 2006/10/09 14:44:50 pierre Exp $
20  */

21 public abstract class WrappedFunction implements Function {
22
23     protected Function wrappedFunction;
24
25     /**
26      * Constructor for Basic Function
27      * @param function The function to wrap
28      */

29     public WrappedFunction(Function function) {
30          wrappedFunction = function;
31     }
32
33     public Parameters createParameters() {
34         return wrappedFunction.createParameters();
35     }
36
37     public Object JavaDoc getFunctionValue(Parameters parameters) {
38          return wrappedFunction.getFunctionValue(parameters);
39     }
40
41     public Object JavaDoc getFunctionValueWithList(List JavaDoc parameters) {
42          if (parameters instanceof Parameters) {
43              return getFunctionValue((Parameters)parameters);
44          } else {
45              Parameters params = wrappedFunction.createParameters();
46              params.setAutoCasting(true);
47              params.setAll(parameters);
48              return getFunctionValue(params);
49          }
50     }
51
52     public void setDescription(String JavaDoc description) {
53         wrappedFunction.setDescription(description);
54     }
55
56     public String JavaDoc getDescription() {
57         return wrappedFunction.getDescription();
58     }
59
60     public String JavaDoc getName() {
61         return wrappedFunction.getName();
62     }
63
64     public Parameter[] getParameterDefinition() {
65         return wrappedFunction.getParameterDefinition();
66     }
67
68     public void setParameterDefinition(Parameter[] params) {
69         wrappedFunction.setParameterDefinition(params);
70     }
71
72     public ReturnType getReturnType() {
73         return wrappedFunction.getReturnType();
74     }
75
76     public void setReturnType(ReturnType type) {
77         wrappedFunction.setReturnType(type);
78     }
79
80     public int hashCode() {
81         return getName().hashCode();
82     }
83     public String JavaDoc toString() {
84         return "WRAPPED " + getReturnType() + " " + getName() + java.util.Arrays.asList(getParameterDefinition());
85     }
86
87
88 }
89
Popular Tags