1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.onemind.commons.invoke;
22
23 import org.onemind.commons.java.lang.reflect.ReflectUtils;
24 /***
25 * An abstract implementation of InvocableFunction
26 * @author TiongHiang Lee (thlee@onemindsoft.org)
27 * @version $Id: AbstractInvocableFunction.java,v 1.6 2005/01/24 05:51:54 thlee Exp $ $Name: $
28 */
29 public abstract class AbstractInvocableFunction implements InvocableFunction
30 {
31
32 /*** the name **/
33 private String _name;
34
35 /*** the method **/
36 private Class[] _argTypes;
37
38 /***
39 * Constructor
40 * @param name the name
41 */
42 public AbstractInvocableFunction(String name)
43 {
44 this(name, null);
45 }
46
47 /***
48 * Constructor
49 * @param name the name
50 * @param argTypes the argument types
51 */
52 public AbstractInvocableFunction(String name, Class[] argTypes)
53 {
54 _name = name;
55 _argTypes = argTypes;
56 }
57
58 /***
59 * {@inheritDoc}
60 */
61 public boolean canInvokeOn(Class[] argTypes)
62 {
63 return ReflectUtils.isCompatible(_argTypes, argTypes);
64 }
65
66 /***
67 * Return the argTypes
68 * @return the argTypes.
69 */
70 public final Class[] getArgTypes()
71 {
72 return _argTypes;
73 }
74
75 /***
76 * Return the name
77 * @return the name.
78 */
79 public final String getName()
80 {
81 return _name;
82 }
83
84 /***
85 * {@inheritDoc}
86 */
87 public String toString()
88 {
89 return ReflectUtils.toMethodString(_name, _argTypes);
90 }
91 }