01: /* Function.java
02:
03: {{IS_NOTE
04: Purpose:
05:
06: Description:
07:
08: History:
09: Thu Aug 30 10:24:49 2007, Created by tomyeh
10: }}IS_NOTE
11:
12: Copyright (C) 2007 Potix Corporation. All Rights Reserved.
13:
14: {{IS_RIGHT
15: This program is distributed under GPL Version 2.0 in the hope that
16: it will be useful, but WITHOUT ANY WARRANTY.
17: }}IS_RIGHT
18: */
19: package org.zkoss.xel;
20:
21: import java.lang.reflect.Method;
22:
23: /**
24: * Represents a XEL function.
25: *
26: * @author tomyeh
27: * @since 3.0.0
28: */
29: public interface Function {
30: /** Returns an array of Class objects that represent the formal
31: * parameter types, in declaration order, of the method represented
32: * by this Method object.
33: *
34: * <p>Returns an array of length 0 if the underlying method
35: * takes no parameters.
36: */
37: public Class[] getParameterTypes();
38:
39: /** Returns a Class object that represents the formal return type
40: * of the method
41: * represented by this Method object.
42: */
43: public Class getReturnType();
44:
45: /** Invokes this method with the specified arguments.
46: *
47: * @param obj the object the underlying method is invoked from.
48: * It is always null if this function is invoked in an XEL expression.
49: * It is reserved for more sophisticated expressions, such as
50: * ZK Spreadsheet's expressions.
51: * @param args the arguments used for the method call.
52: * If null, an Object array with zero length is assumed.
53: */
54: public Object invoke(Object obj, Object[] args) throws Exception;
55:
56: /** Converts this function to a method, or null if unable to convert.
57: */
58: public Method toMethod();
59: }
|